pdf-oxide-fips 0.3.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE-APACHE +176 -0
- package/LICENSE-MIT +25 -0
- package/README.md +218 -0
- package/lib/builders/annotation-builder.d.ts +198 -0
- package/lib/builders/annotation-builder.js +317 -0
- package/lib/builders/conversion-options-builder.d.ts +106 -0
- package/lib/builders/conversion-options-builder.js +214 -0
- package/lib/builders/document-builder.d.ts +381 -0
- package/lib/builders/document-builder.js +770 -0
- package/lib/builders/index.d.ts +13 -0
- package/lib/builders/index.js +13 -0
- package/lib/builders/metadata-builder.d.ts +201 -0
- package/lib/builders/metadata-builder.js +285 -0
- package/lib/builders/pdf-builder.d.ts +216 -0
- package/lib/builders/pdf-builder.js +350 -0
- package/lib/builders/search-options-builder.d.ts +73 -0
- package/lib/builders/search-options-builder.js +129 -0
- package/lib/builders/streaming-table.d.ts +64 -0
- package/lib/builders/streaming-table.js +140 -0
- package/lib/document-editor-manager.d.ts +139 -0
- package/lib/document-editor-manager.js +256 -0
- package/lib/document-editor.d.ts +124 -0
- package/lib/document-editor.js +318 -0
- package/lib/errors.d.ts +382 -0
- package/lib/errors.js +1115 -0
- package/lib/form-field-manager.d.ts +299 -0
- package/lib/form-field-manager.js +568 -0
- package/lib/hybrid-ml-manager.d.ts +142 -0
- package/lib/hybrid-ml-manager.js +208 -0
- package/lib/index.d.ts +205 -0
- package/lib/index.js +693 -0
- package/lib/managers/accessibility-manager.d.ts +148 -0
- package/lib/managers/accessibility-manager.js +234 -0
- package/lib/managers/annotation-manager.d.ts +219 -0
- package/lib/managers/annotation-manager.js +359 -0
- package/lib/managers/barcode-manager.d.ts +82 -0
- package/lib/managers/barcode-manager.js +263 -0
- package/lib/managers/batch-manager.d.ts +185 -0
- package/lib/managers/batch-manager.js +385 -0
- package/lib/managers/cache-manager.d.ts +181 -0
- package/lib/managers/cache-manager.js +384 -0
- package/lib/managers/compliance-manager.d.ts +103 -0
- package/lib/managers/compliance-manager.js +453 -0
- package/lib/managers/content-manager.d.ts +120 -0
- package/lib/managers/content-manager.js +294 -0
- package/lib/managers/document-utility-manager.d.ts +369 -0
- package/lib/managers/document-utility-manager.js +730 -0
- package/lib/managers/dom-pdf-creator.d.ts +104 -0
- package/lib/managers/dom-pdf-creator.js +299 -0
- package/lib/managers/editing-manager.d.ts +248 -0
- package/lib/managers/editing-manager.js +387 -0
- package/lib/managers/enterprise-manager.d.ts +192 -0
- package/lib/managers/enterprise-manager.js +307 -0
- package/lib/managers/extended-managers.d.ts +122 -0
- package/lib/managers/extended-managers.js +664 -0
- package/lib/managers/extraction-manager.d.ts +246 -0
- package/lib/managers/extraction-manager.js +482 -0
- package/lib/managers/final-utilities.d.ts +127 -0
- package/lib/managers/final-utilities.js +657 -0
- package/lib/managers/hybrid-ml-advanced.d.ts +136 -0
- package/lib/managers/hybrid-ml-advanced.js +722 -0
- package/lib/managers/index.d.ts +64 -0
- package/lib/managers/index.js +69 -0
- package/lib/managers/layer-manager.d.ts +203 -0
- package/lib/managers/layer-manager.js +401 -0
- package/lib/managers/metadata-manager.d.ts +148 -0
- package/lib/managers/metadata-manager.js +280 -0
- package/lib/managers/ocr-manager.d.ts +194 -0
- package/lib/managers/ocr-manager.js +582 -0
- package/lib/managers/optimization-manager.d.ts +102 -0
- package/lib/managers/optimization-manager.js +213 -0
- package/lib/managers/outline-manager.d.ts +101 -0
- package/lib/managers/outline-manager.js +169 -0
- package/lib/managers/page-manager.d.ts +142 -0
- package/lib/managers/page-manager.js +235 -0
- package/lib/managers/pattern-detection.d.ts +169 -0
- package/lib/managers/pattern-detection.js +322 -0
- package/lib/managers/rendering-manager.d.ts +353 -0
- package/lib/managers/rendering-manager.js +679 -0
- package/lib/managers/search-manager.d.ts +235 -0
- package/lib/managers/search-manager.js +329 -0
- package/lib/managers/security-manager.d.ts +161 -0
- package/lib/managers/security-manager.js +292 -0
- package/lib/managers/signature-manager.d.ts +738 -0
- package/lib/managers/signature-manager.js +1509 -0
- package/lib/managers/streams.d.ts +262 -0
- package/lib/managers/streams.js +477 -0
- package/lib/managers/xfa-manager.d.ts +227 -0
- package/lib/managers/xfa-manager.js +539 -0
- package/lib/native-loader.d.ts +7 -0
- package/lib/native-loader.js +62 -0
- package/lib/native.d.ts +16 -0
- package/lib/native.js +69 -0
- package/lib/pdf-creator-manager.d.ts +200 -0
- package/lib/pdf-creator-manager.js +381 -0
- package/lib/properties.d.ts +79 -0
- package/lib/properties.js +454 -0
- package/lib/result-accessors-manager.d.ts +346 -0
- package/lib/result-accessors-manager.js +706 -0
- package/lib/thumbnail-manager.d.ts +121 -0
- package/lib/thumbnail-manager.js +205 -0
- package/lib/timestamp.d.ts +54 -0
- package/lib/timestamp.js +115 -0
- package/lib/tsa-client.d.ts +44 -0
- package/lib/tsa-client.js +67 -0
- package/lib/types/common.d.ts +189 -0
- package/lib/types/common.js +17 -0
- package/lib/types/document-types.d.ts +352 -0
- package/lib/types/document-types.js +82 -0
- package/lib/types/index.d.ts +5 -0
- package/lib/types/index.js +5 -0
- package/lib/types/manager-types.d.ts +179 -0
- package/lib/types/manager-types.js +100 -0
- package/lib/types/native-bindings.d.ts +439 -0
- package/lib/types/native-bindings.js +7 -0
- package/lib/workers/index.d.ts +6 -0
- package/lib/workers/index.js +5 -0
- package/lib/workers/pool.d.ts +64 -0
- package/lib/workers/pool.js +192 -0
- package/lib/workers/worker.d.ts +5 -0
- package/lib/workers/worker.js +99 -0
- package/package.json +79 -0
- package/prebuilds/darwin-arm64/pdf_oxide.node +0 -0
- package/prebuilds/darwin-x64/pdf_oxide.node +0 -0
- package/prebuilds/linux-arm64/pdf_oxide.node +0 -0
- package/prebuilds/linux-x64/pdf_oxide.node +0 -0
- package/prebuilds/win32-x64/pdf_oxide.node +0 -0
package/LICENSE-APACHE
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
package/LICENSE-MIT
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
Copyright (c) 2025-present Yury Fedoseev
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any
|
|
4
|
+
person obtaining a copy of this software and associated
|
|
5
|
+
documentation files (the "Software"), to deal in the
|
|
6
|
+
Software without restriction, including without
|
|
7
|
+
limitation the rights to use, copy, modify, merge,
|
|
8
|
+
publish, distribute, sublicense, and/or sell copies of
|
|
9
|
+
the Software, and to permit persons to whom the Software
|
|
10
|
+
is furnished to do so, subject to the following
|
|
11
|
+
conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice
|
|
14
|
+
shall be included in all copies or substantial portions
|
|
15
|
+
of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
|
|
18
|
+
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
|
19
|
+
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
|
20
|
+
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
|
|
21
|
+
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
22
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
23
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
|
|
24
|
+
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
25
|
+
DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
# PDF Oxide for Node.js — The Fastest PDF Toolkit for JavaScript & TypeScript
|
|
2
|
+
|
|
3
|
+
The fastest Node.js PDF library for text extraction, image extraction, and markdown conversion. Powered by a pure-Rust core, exposed to Node.js through a native N-API addon. 0.8ms mean per document, 5× faster than PyMuPDF, 15× faster than pypdf. 100% pass rate on 3,830 real-world PDFs. MIT / Apache-2.0 licensed.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/pdf-oxide)
|
|
6
|
+
[](https://opensource.org/licenses)
|
|
7
|
+
|
|
8
|
+
> **Part of the [PDF Oxide](https://github.com/yfedoseev/pdf_oxide) toolkit.** Same Rust core, same speed, same 100% pass rate as the [Rust](https://docs.rs/pdf_oxide), [Python](../python/README.md), [Go](../go/README.md), [C# / .NET](../csharp/README.md), and [WASM](../wasm-pkg/README.md) bindings.
|
|
9
|
+
>
|
|
10
|
+
> Need to run in browsers, Deno, Bun, or Cloudflare Workers? Use the [WASM build](../wasm-pkg/README.md) instead — same API, no native binaries.
|
|
11
|
+
|
|
12
|
+
## Quick Start
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install pdf-oxide
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
```javascript
|
|
19
|
+
const { PdfDocument } = require("pdf-oxide");
|
|
20
|
+
|
|
21
|
+
const doc = new PdfDocument("paper.pdf");
|
|
22
|
+
const text = doc.extractText(0);
|
|
23
|
+
const markdown = doc.toMarkdown(0);
|
|
24
|
+
doc.close();
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
TypeScript:
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
import { PdfDocument } from "pdf-oxide";
|
|
31
|
+
|
|
32
|
+
const doc = new PdfDocument("paper.pdf");
|
|
33
|
+
const text: string = doc.extractText(0);
|
|
34
|
+
const markdown: string = doc.toMarkdown(0);
|
|
35
|
+
doc.close();
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Why pdf_oxide?
|
|
39
|
+
|
|
40
|
+
- **Fast** — 0.8ms mean per document, 5× faster than PyMuPDF, 15× faster than pypdf, 29× faster than pdfplumber
|
|
41
|
+
- **Reliable** — 100% pass rate on 3,830 test PDFs, zero panics, zero timeouts, no segfaults
|
|
42
|
+
- **Complete** — Text extraction, image extraction, search, form fields, PDF creation, and editing in one package
|
|
43
|
+
- **Permissive license** — MIT / Apache-2.0 — use freely in commercial and closed-source projects
|
|
44
|
+
- **Pure Rust core** — Memory-safe, panic-free, no C dependencies beyond the N-API glue
|
|
45
|
+
- **Native binaries** — Pre-built `.node` addons for Linux, macOS, and Windows (x64 + ARM64)
|
|
46
|
+
- **Full TypeScript support** — Type definitions ship in the package
|
|
47
|
+
|
|
48
|
+
## Performance
|
|
49
|
+
|
|
50
|
+
Benchmarked on 3,830 PDFs from three independent public test suites (veraPDF, Mozilla pdf.js, DARPA SafeDocs). Text extraction libraries only. Single-thread, 60s timeout, no warm-up.
|
|
51
|
+
|
|
52
|
+
| Library | Mean | p99 | Pass Rate | License |
|
|
53
|
+
|---------|------|-----|-----------|---------|
|
|
54
|
+
| **PDF Oxide** | **0.8ms** | **9ms** | **100%** | **MIT / Apache-2.0** |
|
|
55
|
+
| PyMuPDF | 4.6ms | 28ms | 99.3% | AGPL-3.0 |
|
|
56
|
+
| pypdfium2 | 4.1ms | 42ms | 99.2% | Apache-2.0 |
|
|
57
|
+
| pdftext | 7.3ms | 82ms | 99.0% | GPL-3.0 |
|
|
58
|
+
| pdfminer | 16.8ms | 124ms | 98.8% | MIT |
|
|
59
|
+
| pypdf | 12.1ms | 97ms | 98.4% | BSD-3 |
|
|
60
|
+
|
|
61
|
+
99.5% text parity vs PyMuPDF and pypdfium2 across the full corpus. The Node.js binding adds negligible overhead — extraction stays within ~25% of direct Rust calls on real-world fixtures.
|
|
62
|
+
|
|
63
|
+
## Installation
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
npm install pdf-oxide
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Pre-built native addons for:
|
|
70
|
+
|
|
71
|
+
| Platform | x64 | ARM64 |
|
|
72
|
+
|---|---|---|
|
|
73
|
+
| Linux (glibc) | Yes | Yes |
|
|
74
|
+
| Linux (musl) | Yes | Yes |
|
|
75
|
+
| macOS | Yes | Yes (Apple Silicon) |
|
|
76
|
+
| Windows | Yes | Yes |
|
|
77
|
+
|
|
78
|
+
Requires Node.js 18 or newer. No system dependencies. No Rust toolchain required.
|
|
79
|
+
|
|
80
|
+
## API Tour
|
|
81
|
+
|
|
82
|
+
### Open a document
|
|
83
|
+
|
|
84
|
+
```javascript
|
|
85
|
+
const { PdfDocument } = require("pdf-oxide");
|
|
86
|
+
|
|
87
|
+
const doc = new PdfDocument("report.pdf");
|
|
88
|
+
console.log(`Pages: ${doc.getPageCount()}`);
|
|
89
|
+
|
|
90
|
+
const { major, minor } = doc.getVersion();
|
|
91
|
+
console.log(`PDF version: ${major}.${minor}`);
|
|
92
|
+
|
|
93
|
+
doc.close();
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Use `using` for automatic cleanup (Node.js 22+):
|
|
97
|
+
|
|
98
|
+
```javascript
|
|
99
|
+
{
|
|
100
|
+
using doc = new PdfDocument("report.pdf");
|
|
101
|
+
const text = doc.extractText(0);
|
|
102
|
+
} // doc.close() called automatically
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Text extraction
|
|
106
|
+
|
|
107
|
+
```javascript
|
|
108
|
+
const text = doc.extractText(0); // single page
|
|
109
|
+
const markdown = doc.toMarkdown(0); // single page → Markdown
|
|
110
|
+
const html = doc.toHtml(0); // single page → HTML
|
|
111
|
+
const plain = doc.toPlainText(0); // single page → plain text
|
|
112
|
+
|
|
113
|
+
const allMarkdown = doc.toMarkdownAll(); // entire document
|
|
114
|
+
const allHtml = doc.toHtmlAll();
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Iterate all pages
|
|
118
|
+
|
|
119
|
+
```javascript
|
|
120
|
+
const doc = new PdfDocument("document.pdf");
|
|
121
|
+
const pageCount = doc.getPageCount();
|
|
122
|
+
|
|
123
|
+
const pages = [];
|
|
124
|
+
for (let i = 0; i < pageCount; i++) {
|
|
125
|
+
pages.push(doc.extractText(i));
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
doc.close();
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Async wrapper
|
|
132
|
+
|
|
133
|
+
```javascript
|
|
134
|
+
async function extractAll(filePath) {
|
|
135
|
+
const doc = new PdfDocument(filePath);
|
|
136
|
+
try {
|
|
137
|
+
const pageCount = doc.getPageCount();
|
|
138
|
+
const pages = [];
|
|
139
|
+
for (let i = 0; i < pageCount; i++) {
|
|
140
|
+
pages.push(doc.extractText(i));
|
|
141
|
+
}
|
|
142
|
+
return pages;
|
|
143
|
+
} finally {
|
|
144
|
+
doc.close();
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const pages = await extractAll("document.pdf");
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Error handling
|
|
152
|
+
|
|
153
|
+
All methods throw on failure. Catch with try/catch:
|
|
154
|
+
|
|
155
|
+
```javascript
|
|
156
|
+
try {
|
|
157
|
+
const text = doc.extractText(0);
|
|
158
|
+
} catch (err) {
|
|
159
|
+
console.error("Extraction failed:", err.message);
|
|
160
|
+
} finally {
|
|
161
|
+
doc.close();
|
|
162
|
+
}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## Other languages
|
|
166
|
+
|
|
167
|
+
PDF Oxide ships the same Rust core through six bindings:
|
|
168
|
+
|
|
169
|
+
- **Rust** — `cargo add pdf_oxide` — see [docs.rs/pdf_oxide](https://docs.rs/pdf_oxide)
|
|
170
|
+
- **Python** — `pip install pdf_oxide` — see [python/README.md](../python/README.md)
|
|
171
|
+
- **Go** — `go get github.com/yfedoseev/pdf_oxide/go` — see [go/README.md](../go/README.md)
|
|
172
|
+
- **C# / .NET** — `dotnet add package PdfOxide` — see [csharp/README.md](../csharp/README.md)
|
|
173
|
+
- **WASM (browsers, Deno, Bun, edge runtimes)** — `npm install pdf-oxide-wasm` — see [wasm-pkg/README.md](../wasm-pkg/README.md)
|
|
174
|
+
|
|
175
|
+
A bug fix in the Rust core lands in every binding on the next release.
|
|
176
|
+
|
|
177
|
+
## Documentation
|
|
178
|
+
|
|
179
|
+
- **[Full Documentation](https://pdf.oxide.fyi)** — Complete documentation site
|
|
180
|
+
- **[JavaScript Getting Started](https://pdf.oxide.fyi/docs/getting-started/javascript)** — Step-by-step Node.js guide
|
|
181
|
+
- **[Main Repository](https://github.com/yfedoseev/pdf_oxide)** — Rust core, CLI, MCP server, all bindings
|
|
182
|
+
- **[Performance Benchmarks](https://pdf.oxide.fyi/docs/performance)** — Full benchmark methodology and results
|
|
183
|
+
- **[GitHub Issues](https://github.com/yfedoseev/pdf_oxide/issues)** — Bug reports and feature requests
|
|
184
|
+
|
|
185
|
+
## Use Cases
|
|
186
|
+
|
|
187
|
+
- **RAG / LLM pipelines** — Convert PDFs to clean Markdown for retrieval-augmented generation with LangChain.js, LlamaIndex.js, or any framework
|
|
188
|
+
- **Document processing at scale** — Extract text, images, and metadata from thousands of PDFs in seconds
|
|
189
|
+
- **Server-side PDF rendering** — Extract structured content for search indexing, archival, or transformation pipelines
|
|
190
|
+
- **PDF generation** — Create invoices, reports, certificates, and templated documents programmatically
|
|
191
|
+
- **PyMuPDF alternative** — MIT licensed, 5× faster, no AGPL restrictions, no Python required
|
|
192
|
+
|
|
193
|
+
## Why I built this
|
|
194
|
+
|
|
195
|
+
I needed PyMuPDF's speed without its AGPL license, and I needed it in more than one language. Nothing existed that ticked all three boxes — fast, MIT, multi-language — so I wrote it. The Rust core is what does the real work; the bindings for Python, Go, JS/TS, C#, and WASM are thin shells around the same code, so a bug fix in one lands in all of them. It now passes 100% of the veraPDF + Mozilla pdf.js + DARPA SafeDocs test corpora (3,830 PDFs) on every platform I've tested.
|
|
196
|
+
|
|
197
|
+
If it's useful to you, a star on GitHub genuinely helps. If something's broken or missing, [open an issue](https://github.com/yfedoseev/pdf_oxide/issues) — I read all of them.
|
|
198
|
+
|
|
199
|
+
— Yury
|
|
200
|
+
|
|
201
|
+
## License
|
|
202
|
+
|
|
203
|
+
Dual-licensed under [MIT](https://github.com/yfedoseev/pdf_oxide/blob/main/LICENSE-MIT) or [Apache-2.0](https://github.com/yfedoseev/pdf_oxide/blob/main/LICENSE-APACHE) at your option. Unlike AGPL-licensed alternatives, pdf_oxide can be used freely in any project — commercial or open-source — with no copyleft restrictions.
|
|
204
|
+
|
|
205
|
+
## Citation
|
|
206
|
+
|
|
207
|
+
```bibtex
|
|
208
|
+
@software{pdf_oxide,
|
|
209
|
+
title = {PDF Oxide: Fast PDF Toolkit for Rust, Python, Go, JavaScript, and C#},
|
|
210
|
+
author = {Yury Fedoseev},
|
|
211
|
+
year = {2025},
|
|
212
|
+
url = {https://github.com/yfedoseev/pdf_oxide}
|
|
213
|
+
}
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
---
|
|
217
|
+
|
|
218
|
+
**JavaScript** + **TypeScript** + **Rust core** | MIT / Apache-2.0 | 100% pass rate on 3,830 PDFs | 0.8ms mean | 5× faster than the industry leaders
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builder for creating PDF annotations
|
|
3
|
+
*
|
|
4
|
+
* Configures annotation properties like content, appearance, author, and behavior.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* import { AnnotationBuilder } from 'pdf_oxide';
|
|
9
|
+
*
|
|
10
|
+
* const annotation = AnnotationBuilder.create()
|
|
11
|
+
* .type('highlight')
|
|
12
|
+
* .content('Important section')
|
|
13
|
+
* .author('Reviewer')
|
|
14
|
+
* .color([1, 1, 0]) // Yellow
|
|
15
|
+
* .build();
|
|
16
|
+
*
|
|
17
|
+
* pdf.addAnnotation(annotation);
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
interface AnnotationBounds {
|
|
21
|
+
x: number;
|
|
22
|
+
y: number;
|
|
23
|
+
width: number;
|
|
24
|
+
height: number;
|
|
25
|
+
}
|
|
26
|
+
export interface Annotation {
|
|
27
|
+
type: string;
|
|
28
|
+
content: string;
|
|
29
|
+
author?: string;
|
|
30
|
+
subject?: string;
|
|
31
|
+
color: number[];
|
|
32
|
+
opacity: number;
|
|
33
|
+
bounds?: AnnotationBounds;
|
|
34
|
+
creationDate: Date;
|
|
35
|
+
modificationDate: Date;
|
|
36
|
+
flags: number;
|
|
37
|
+
reply?: string;
|
|
38
|
+
}
|
|
39
|
+
export declare class AnnotationBuilder {
|
|
40
|
+
private _type;
|
|
41
|
+
private _content;
|
|
42
|
+
private _author?;
|
|
43
|
+
private _subject?;
|
|
44
|
+
private _color;
|
|
45
|
+
private _opacity;
|
|
46
|
+
private _bounds?;
|
|
47
|
+
private _creationDate;
|
|
48
|
+
private _modificationDate;
|
|
49
|
+
private _flags;
|
|
50
|
+
private _reply?;
|
|
51
|
+
/**
|
|
52
|
+
* Creates a new AnnotationBuilder instance
|
|
53
|
+
* @private
|
|
54
|
+
*/
|
|
55
|
+
private constructor();
|
|
56
|
+
/**
|
|
57
|
+
* Creates a new AnnotationBuilder instance
|
|
58
|
+
* @returns New builder instance
|
|
59
|
+
*/
|
|
60
|
+
static create(): AnnotationBuilder;
|
|
61
|
+
/**
|
|
62
|
+
* Creates a text annotation (comment/note)
|
|
63
|
+
* @returns This builder for chaining
|
|
64
|
+
*/
|
|
65
|
+
asText(): this;
|
|
66
|
+
/**
|
|
67
|
+
* Creates a highlight annotation
|
|
68
|
+
* @returns This builder for chaining
|
|
69
|
+
*/
|
|
70
|
+
asHighlight(): this;
|
|
71
|
+
/**
|
|
72
|
+
* Creates an underline annotation
|
|
73
|
+
* @returns This builder for chaining
|
|
74
|
+
*/
|
|
75
|
+
asUnderline(): this;
|
|
76
|
+
/**
|
|
77
|
+
* Creates a strikeout annotation
|
|
78
|
+
* @returns This builder for chaining
|
|
79
|
+
*/
|
|
80
|
+
asStrikeout(): this;
|
|
81
|
+
/**
|
|
82
|
+
* Creates a squiggly (wavy underline) annotation
|
|
83
|
+
* @returns This builder for chaining
|
|
84
|
+
*/
|
|
85
|
+
asSquiggly(): this;
|
|
86
|
+
/**
|
|
87
|
+
* Sets the annotation type
|
|
88
|
+
* @param type - Annotation type ('text', 'highlight', 'underline', 'strikeout', 'squiggly')
|
|
89
|
+
* @returns This builder for chaining
|
|
90
|
+
*/
|
|
91
|
+
type(type: string): this;
|
|
92
|
+
/**
|
|
93
|
+
* Sets the annotation content/text
|
|
94
|
+
* @param content - The annotation content
|
|
95
|
+
* @returns This builder for chaining
|
|
96
|
+
*/
|
|
97
|
+
content(content: string): this;
|
|
98
|
+
/**
|
|
99
|
+
* Sets the author of the annotation
|
|
100
|
+
* @param author - The author name
|
|
101
|
+
* @returns This builder for chaining
|
|
102
|
+
*/
|
|
103
|
+
author(author: string): this;
|
|
104
|
+
/**
|
|
105
|
+
* Sets the subject/title of the annotation
|
|
106
|
+
* @param subject - The annotation subject
|
|
107
|
+
* @returns This builder for chaining
|
|
108
|
+
*/
|
|
109
|
+
subject(subject: string): this;
|
|
110
|
+
/**
|
|
111
|
+
* Sets the color of the annotation (RGB, normalized 0-1)
|
|
112
|
+
* @param rgb - RGB color array [r, g, b] with values 0-1
|
|
113
|
+
* @returns This builder for chaining
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* ```typescript
|
|
117
|
+
* builder.color([1, 1, 0]); // Yellow
|
|
118
|
+
* builder.color([1, 0, 0]); // Red
|
|
119
|
+
* builder.color([0, 1, 0]); // Green
|
|
120
|
+
* ```
|
|
121
|
+
*/
|
|
122
|
+
color(rgb: number[]): this;
|
|
123
|
+
/**
|
|
124
|
+
* Sets the color using common color names
|
|
125
|
+
* @param colorName - Color name (e.g., 'red', 'yellow', 'green', 'blue')
|
|
126
|
+
* @returns This builder for chaining
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* ```typescript
|
|
130
|
+
* builder.colorName('yellow');
|
|
131
|
+
* builder.colorName('red');
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
134
|
+
colorName(colorName: string): this;
|
|
135
|
+
/**
|
|
136
|
+
* Sets the opacity/transparency (0-1)
|
|
137
|
+
* @param opacity - Opacity value (0=transparent, 1=opaque)
|
|
138
|
+
* @returns This builder for chaining
|
|
139
|
+
*/
|
|
140
|
+
opacity(opacity: number): this;
|
|
141
|
+
/**
|
|
142
|
+
* Sets the bounding box for the annotation
|
|
143
|
+
* @param bounds - Bounding box {x, y, width, height}
|
|
144
|
+
* @returns This builder for chaining
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* ```typescript
|
|
148
|
+
* builder.bounds({x: 100, y: 200, width: 150, height: 30});
|
|
149
|
+
* ```
|
|
150
|
+
*/
|
|
151
|
+
bounds(bounds: AnnotationBounds): this;
|
|
152
|
+
/**
|
|
153
|
+
* Sets the creation date
|
|
154
|
+
* @param date - The creation date
|
|
155
|
+
* @returns This builder for chaining
|
|
156
|
+
*/
|
|
157
|
+
creationDate(date: Date): this;
|
|
158
|
+
/**
|
|
159
|
+
* Sets the modification date
|
|
160
|
+
* @param date - The modification date
|
|
161
|
+
* @returns This builder for chaining
|
|
162
|
+
*/
|
|
163
|
+
modificationDate(date: Date): this;
|
|
164
|
+
/**
|
|
165
|
+
* Sets the annotation to be printed
|
|
166
|
+
* @returns This builder for chaining
|
|
167
|
+
*/
|
|
168
|
+
printable(): this;
|
|
169
|
+
/**
|
|
170
|
+
* Sets the annotation to NOT be printed
|
|
171
|
+
* @returns This builder for chaining
|
|
172
|
+
*/
|
|
173
|
+
notPrintable(): this;
|
|
174
|
+
/**
|
|
175
|
+
* Sets whether the annotation is locked (read-only)
|
|
176
|
+
* @param locked - Whether to lock the annotation
|
|
177
|
+
* @returns This builder for chaining
|
|
178
|
+
*/
|
|
179
|
+
locked(locked: boolean): this;
|
|
180
|
+
/**
|
|
181
|
+
* Sets a reply to this annotation
|
|
182
|
+
* @param replyContent - Content of the reply
|
|
183
|
+
* @returns This builder for chaining
|
|
184
|
+
*/
|
|
185
|
+
reply(replyContent: string): this;
|
|
186
|
+
/**
|
|
187
|
+
* Builds and returns the annotation object
|
|
188
|
+
* @returns Immutable annotation object
|
|
189
|
+
*/
|
|
190
|
+
build(): Annotation;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Create a new AnnotationBuilder with static factory
|
|
194
|
+
* @deprecated Use AnnotationBuilder.create() instead
|
|
195
|
+
* @returns New builder instance
|
|
196
|
+
*/
|
|
197
|
+
export declare function createAnnotationBuilder(): AnnotationBuilder;
|
|
198
|
+
export {};
|