forked from yfedoseev/pdf_oxide
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCargo.toml
More file actions
236 lines (189 loc) · 7.55 KB
/
Copy pathCargo.toml
File metadata and controls
236 lines (189 loc) · 7.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
[workspace]
members = [".", "pdf_oxide_mcp", "pdf_oxide_cli"]
[package]
name = "pdf_oxide"
version = "0.3.17"
edition = "2021"
authors = ["Yury Fedoseev <yfedoseev@gmail.com>"]
license = "MIT OR Apache-2.0"
description = "The fastest Rust PDF library with text extraction: 0.8ms mean, 100% pass rate on 3,830 PDFs. 5× faster than pdf_extract, 17× faster than oxidize_pdf. Extract, create, and edit PDFs."
repository = "https://github.com/yfedoseev/pdf_oxide"
homepage = "https://oxide.fyi"
documentation = "https://pdf.oxide.fyi/docs/getting-started/rust"
readme = "README.md"
keywords = ["pdf", "text-extraction", "pdf-parser", "pdf-to-markdown", "document-parser"]
categories = ["parsing", "text-processing"]
[lib]
name = "pdf_oxide"
crate-type = ["cdylib", "rlib"] # cdylib for Python/WASM, rlib for Rust
[dependencies]
# Core dependencies
thiserror = "2.0"
log = "0.4"
env_logger = "0.11"
chrono = "0.4" # Timestamp generation for benchmark results
# Parsing
nom = "8.0"
regex = "1.12"
lazy_static = "1.4"
# Data structures
bytes = "1.5"
indexmap = "2.2"
memchr = "2" # SIMD-accelerated byte/substring search for content stream scanning
byteorder = "1.5" # For binary parsing (TrueType cmap tables)
bitflags = "2" # For form field flags
smallvec = "1.13" # Stack-allocated small vectors for content stream operands (#165)
# Compression/Decompression
flate2 = { version = "1.1", default-features = false, features = ["zlib-rs"] }
weezl = "0.1" # LZW compression
inflate = "0.4" # Alternative inflate for better error recovery
libflate = "2.1" # Another inflate implementation for error recovery
brotli = "8" # Brotli compression (PDF 2.0, ISO 32000-2:2020)
# Font parsing
ttf-parser = "0.25" # TrueType font parser for embedded font cmap tables
phf = { version = "0.13", features = ["macros"] } # Perfect hash maps for Adobe Glyph List
encoding_rs = "0.8" # Shift-JIS, EUC-JP, and other CJK encodings for predefined CMaps
# Image processing
image = { version = "0.24", default-features = false, features = ["png", "jpeg", "tiff"] }
base64 = "0.22" # For embedding images as data URIs
tiff = "0.11" # TIFF support including CCITT decompression
fax = "0.2" # CCITT Group 3/4 decompression for scanned PDFs (more lenient with malformed EOFB)
# Encryption support
aes = "0.8" # AES encryption for PDF 1.6+
cbc = "0.1" # CBC mode for AES
md-5 = "0.10" # MD5 for key derivation
sha2 = "0.10" # SHA-256 for newer encryption
stringprep = "0.1" # SASLprep for Unicode PDF passwords (R>=5)
# Digital signatures (optional)
x509-parser = { version = "0.18", optional = true } # X.509 certificate parsing
cms = { version = "0.2", optional = true } # CMS/PKCS#7 signatures
rsa = { version = "0.9", optional = true } # RSA signing
der = { version = "0.8", optional = true } # DER encoding
spki = { version = "0.7", optional = true } # SubjectPublicKeyInfo
pkcs1 = { version = "0.7", optional = true } # PKCS#1 RSA format
pkcs8 = { version = "0.10", optional = true } # PKCS#8 private keys
signature = { version = "2.2", optional = true } # Signature traits
sha1 = { version = "0.10", optional = true } # SHA-1 for legacy signatures
# Parallel extraction
rayon = { version = "1.10", optional = true }
# Math and algorithms
ndarray = { version = "0.17", optional = true, features = ["std"] }
linfa = { version = "0.7", optional = true }
linfa-clustering = { version = "0.8", optional = true }
# ML (CPU-only)
tract-onnx = { version = "0.22", optional = true }
tokenizers = { version = "0.15", optional = true, default-features = false, features = ["onig"] }
# OCR - PaddleOCR via ONNX Runtime (optional)
ort = { version = "2.0.0-rc.11", optional = true, default-features = false, features = ["ndarray"] }
imageproc = { version = "0.26", optional = true }
# Serialization
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
# XML parsing (for XMP metadata)
quick-xml = "0.39"
# Python bindings (optional)
# Using latest version to support Python 3.14+
pyo3 = { version = "0.27", features = ["abi3-py38"], optional = true }
# WASM support (optional)
wasm-bindgen = { version = "0.2", optional = true }
web-sys = { version = "0.3", optional = true, features = ["console"] }
js-sys = { version = "0.3", optional = true }
console_error_panic_hook = { version = "0.1", optional = true }
getrandom = { version = "0.4", optional = true, features = ["wasm_js"] }
serde-wasm-bindgen = { version = "0.6", optional = true }
# Table detection - page rendering (optional)
pdfium-render = { version = "0.8", optional = true }
# Rendering (optional - for page to image conversion)
tiny-skia = { version = "0.12", optional = true }
fontdb = { version = "0.23", optional = true }
rustybuzz = { version = "0.20", optional = true }
lzw = "0.10.0"
uuid = { version = "1.0", features = ["v4", "js"] }
# Barcode/QR code generation (optional)
qrcode = { version = "0.14", optional = true }
barcoders = { version = "2.0", optional = true, features = ["image"] }
# Office document conversion (optional)
calamine = { version = "0.33", optional = true }
zip = { version = "8.2", optional = true, default-features = false, features = ["deflate"] }
[dev-dependencies]
criterion = "0.8"
proptest = "1.4"
regex = "1.12"
tempfile = "3.10"
crc32fast = "1.3"
wasm-bindgen-test = "0.3"
[features]
default = []
# Enable logging for the extraction pipeline
logging = []
# Python bindings (v0.1.0)
python = ["pyo3"]
# The following features are planned for v1.0 and are not yet production-ready.
# We define them here to avoid check-cfg warnings, but their dependencies are commented out.
ml = ["dep:tract-onnx", "dep:ndarray", "dep:linfa", "dep:linfa-clustering", "dep:tokenizers"]
table-ml = ["ml", "dep:pdfium-render"]
ocr = ["dep:ort", "dep:imageproc", "dep:ndarray"]
gpu = ["dep:ort", "ml"]
wasm = ["dep:wasm-bindgen", "dep:web-sys", "dep:js-sys", "dep:console_error_panic_hook", "dep:getrandom", "dep:serde-wasm-bindgen"]
wasm-ml = ["wasm", "ml"]
# Debug feature for span merging analysis
debug-span-merging = []
# Page rendering to images (pure Rust via tiny-skia)
rendering = ["dep:tiny-skia", "dep:fontdb", "dep:rustybuzz"]
# Digital signatures (create and verify PDF signatures)
signatures = ["dep:x509-parser", "dep:cms", "dep:rsa", "dep:der", "dep:spki", "dep:pkcs1", "dep:pkcs8", "dep:signature", "dep:sha1"]
# Barcode/QR code generation
barcodes = ["dep:qrcode", "dep:barcoders"]
# Office document conversion (DOCX, XLSX, PPTX)
office = ["dep:calamine", "dep:zip"]
# Parallel page extraction via rayon
parallel = ["dep:rayon"]
[profile.release]
opt-level = 3
lto = true
codegen-units = 1
strip = true
# Size-optimized release (for WASM)
[profile.release-small]
inherits = "release"
opt-level = "z"
lto = true
codegen-units = 1
strip = true
panic = "abort"
[profile.bench]
opt-level = 3
lto = true
# Benchmarks
[[bench]]
name = "pdf_extraction_performance"
harness = false
[[bench]]
name = "word_boundary_benchmarks"
harness = false
[[bench]]
name = "script_detection_benchmarks"
harness = false
[[bench]]
name = "ligature_benchmarks"
harness = false
[[bench]]
name = "cjk_benchmarks"
harness = false
[[bench]]
name = "rtl_benchmarks"
harness = false
[[bench]]
name = "complex_script_benchmarks"
harness = false
[[bench]]
name = "full_pipeline_benchmarks"
harness = false
[package.metadata.docs.rs]
# Document with safe features only (tesseract-rs fails on docs.rs sandbox)
features = ["python", "logging", "debug-span-merging", "parallel"]
rustdoc-args = ["--cfg", "docsrs"]
# Python packaging (Maturin)
[package.metadata.maturin]
name = "pdf_oxide"
python-source = "python"