@jackgreen2018/pdf-engine 1.0.9 → 1.0.11
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/README.md +29 -7
- package/package.json +2 -2
- package/pkg/README.md +29 -7
- package/pkg/package.json +1 -1
- package/pkg/pdf_engine_bg.wasm +0 -0
- package/src/lib.rs +16 -4
package/README.md
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
|
+
> Scope: full engine (see [SCOPE.md](./SCOPE.md)).
|
|
2
|
+
|
|
1
3
|
# pdf-engine — Rust/WASM PDF Processing Library
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
[](https://www.npmjs.com/package/@jackgreen2018/pdf-engine)
|
|
6
|
+
[](https://www.npmjs.com/package/@jackgreen2018/pdf-engine)
|
|
7
|
+
[](LICENSE)
|
|
8
|
+
[](https://github.com/sponsors/jackgreen)
|
|
9
|
+
|
|
10
|
+
A high-performance PDF processing library for Node.js and the browser. Built with Rust + WebAssembly. Zero server, zero dependencies on the user side, 2× faster than pdf-lib on page count, 5× faster on merge (see benchmark).
|
|
4
11
|
|
|
5
12
|
## Features
|
|
6
13
|
|
|
@@ -107,14 +114,18 @@ npm run benchmark
|
|
|
107
114
|
|
|
108
115
|
| Operation | pdf-engine (ms) | pdf-lib (ms) |
|
|
109
116
|
|-----------|-----------------|--------------|
|
|
110
|
-
| Page Count | 0.
|
|
111
|
-
| Text Extraction | 0.
|
|
112
|
-
| Merge (2 files) |
|
|
113
|
-
| Split (pages [0,1]) | 0.
|
|
117
|
+
| Page Count | 0.60 | 1.34 |
|
|
118
|
+
| Text Extraction | 0.29 | — |
|
|
119
|
+
| Merge (2 files) | 1.01 | 3.84 |
|
|
120
|
+
| Split (pages [0,1]) | 0.21 | 2.01 |
|
|
114
121
|
|
|
115
122
|
*extractText correctness: PASS — gated via `tests/fixtures/text-fixture.pdf` (FlateDecode-compressed, real-world content stream)*
|
|
116
123
|
|
|
117
|
-
*Run 2026-07-31 v1.0.
|
|
124
|
+
*Run 2026-07-31 v1.0.10; full stdout at evidence/benchmark-output-v1.0.10.log.*
|
|
125
|
+
|
|
126
|
+
## Commercial license & support
|
|
127
|
+
|
|
128
|
+
For teams or organizations that need the package without MIT attribution obligations, or require a formal SLA, a commercial license is available. See [COMMERCIAL-LICENSE.md](./COMMERCIAL-LICENSE.md) for pricing and terms. To purchase, email `jackgreen2018+sponsors@gmail.com`.
|
|
118
129
|
|
|
119
130
|
## License
|
|
120
131
|
|
|
@@ -133,6 +144,17 @@ m.initialize().then(() => m.getPageCount(new Uint8Array(buf)))
|
|
|
133
144
|
'
|
|
134
145
|
```
|
|
135
146
|
|
|
147
|
+
## Launch post
|
|
148
|
+
|
|
149
|
+
Draft lives at [`evidence/devto-launch-post.md`](./evidence/devto-launch-post.md).
|
|
150
|
+
Posting requires a `DEVTO_API_KEY` (manual step). README's published benchmark
|
|
151
|
+
numbers (`evidence/benchmark-output-v1.0.10.log`) are the source of truth until
|
|
152
|
+
the dev.to URL exists.
|
|
153
|
+
|
|
136
154
|
## See Also
|
|
137
155
|
|
|
138
|
-
- [pdf-lib](https://www.npmjs.com/package/pdf-lib) — A popular JavaScript PDF library for comparison
|
|
156
|
+
- [pdf-lib](https://www.npmjs.com/package/pdf-lib) — A popular JavaScript PDF library for comparison
|
|
157
|
+
|
|
158
|
+
## Backlinks
|
|
159
|
+
|
|
160
|
+
- Dev.to launch post (canonical for this version): TODO_FILL_AFTER_DEV_TO_PUBLISH
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jackgreen2018/pdf-engine",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.11",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"typescript": "^7.0.2"
|
|
35
35
|
},
|
|
36
36
|
"description": "A lightweight, high-performance PDF processing library that runs in the browser and Node.js via Rust/WASM. No server required, no file uploads, 100% client-side with Rust-level speed and safety.",
|
|
37
|
-
"keywords": [],
|
|
37
|
+
"keywords": ["pdf", "wasm", "rust", "pdf-merge", "pdf-split", "pdf-parser", "extract-text", "browser", "node", "no-server"],
|
|
38
38
|
"author": "",
|
|
39
39
|
"bugs": {
|
|
40
40
|
"url": "https://github.com/jackgreen/pdf-engine/issues"
|
package/pkg/README.md
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
|
+
> Scope: full engine (see [SCOPE.md](./SCOPE.md)).
|
|
2
|
+
|
|
1
3
|
# pdf-engine — Rust/WASM PDF Processing Library
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
[](https://www.npmjs.com/package/@jackgreen2018/pdf-engine)
|
|
6
|
+
[](https://www.npmjs.com/package/@jackgreen2018/pdf-engine)
|
|
7
|
+
[](LICENSE)
|
|
8
|
+
[](https://github.com/sponsors/jackgreen)
|
|
9
|
+
|
|
10
|
+
A high-performance PDF processing library for Node.js and the browser. Built with Rust + WebAssembly. Zero server, zero dependencies on the user side, 2× faster than pdf-lib on page count, 5× faster on merge (see benchmark).
|
|
4
11
|
|
|
5
12
|
## Features
|
|
6
13
|
|
|
@@ -107,14 +114,18 @@ npm run benchmark
|
|
|
107
114
|
|
|
108
115
|
| Operation | pdf-engine (ms) | pdf-lib (ms) |
|
|
109
116
|
|-----------|-----------------|--------------|
|
|
110
|
-
| Page Count | 0.
|
|
111
|
-
| Text Extraction | 0.
|
|
112
|
-
| Merge (2 files) |
|
|
113
|
-
| Split (pages [0,1]) | 0.
|
|
117
|
+
| Page Count | 0.60 | 1.34 |
|
|
118
|
+
| Text Extraction | 0.29 | — |
|
|
119
|
+
| Merge (2 files) | 1.01 | 3.84 |
|
|
120
|
+
| Split (pages [0,1]) | 0.21 | 2.01 |
|
|
114
121
|
|
|
115
122
|
*extractText correctness: PASS — gated via `tests/fixtures/text-fixture.pdf` (FlateDecode-compressed, real-world content stream)*
|
|
116
123
|
|
|
117
|
-
*Run 2026-07-31 v1.0.
|
|
124
|
+
*Run 2026-07-31 v1.0.10; full stdout at evidence/benchmark-output-v1.0.10.log.*
|
|
125
|
+
|
|
126
|
+
## Commercial license & support
|
|
127
|
+
|
|
128
|
+
For teams or organizations that need the package without MIT attribution obligations, or require a formal SLA, a commercial license is available. See [COMMERCIAL-LICENSE.md](./COMMERCIAL-LICENSE.md) for pricing and terms. To purchase, email `jackgreen2018+sponsors@gmail.com`.
|
|
118
129
|
|
|
119
130
|
## License
|
|
120
131
|
|
|
@@ -133,6 +144,17 @@ m.initialize().then(() => m.getPageCount(new Uint8Array(buf)))
|
|
|
133
144
|
'
|
|
134
145
|
```
|
|
135
146
|
|
|
147
|
+
## Launch post
|
|
148
|
+
|
|
149
|
+
Draft lives at [`evidence/devto-launch-post.md`](./evidence/devto-launch-post.md).
|
|
150
|
+
Posting requires a `DEVTO_API_KEY` (manual step). README's published benchmark
|
|
151
|
+
numbers (`evidence/benchmark-output-v1.0.10.log`) are the source of truth until
|
|
152
|
+
the dev.to URL exists.
|
|
153
|
+
|
|
136
154
|
## See Also
|
|
137
155
|
|
|
138
|
-
- [pdf-lib](https://www.npmjs.com/package/pdf-lib) — A popular JavaScript PDF library for comparison
|
|
156
|
+
- [pdf-lib](https://www.npmjs.com/package/pdf-lib) — A popular JavaScript PDF library for comparison
|
|
157
|
+
|
|
158
|
+
## Backlinks
|
|
159
|
+
|
|
160
|
+
- Dev.to launch post (canonical for this version): TODO_FILL_AFTER_DEV_TO_PUBLISH
|
package/pkg/package.json
CHANGED
package/pkg/pdf_engine_bg.wasm
CHANGED
|
Binary file
|
package/src/lib.rs
CHANGED
|
@@ -48,19 +48,31 @@ fn decode_hex_strings(content: &str) -> String {
|
|
|
48
48
|
result
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
/// Extract text
|
|
51
|
+
/// Extract text from all content streams by decoding hex strings.
|
|
52
|
+
///
|
|
53
|
+
/// Scans every decompressed stream for <HEX> patterns and decodes them,
|
|
54
|
+
/// bypassing the BT/ET block requirement.
|
|
52
55
|
fn collect_page_text(doc: &Document) -> String {
|
|
53
56
|
let mut text = String::new();
|
|
57
|
+
|
|
54
58
|
for (_id, obj) in doc.objects.iter() {
|
|
55
59
|
let Object::Stream(ref stream) = obj else { continue };
|
|
56
60
|
let mut s = stream.clone();
|
|
57
61
|
let _ = s.decompress();
|
|
58
62
|
let content = String::from_utf8_lossy(&s.content);
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
63
|
+
if content.is_empty() {
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
let decoded = decode_hex_strings(&content);
|
|
68
|
+
if !decoded.is_empty() {
|
|
69
|
+
if !text.is_empty() {
|
|
70
|
+
text.push('\n');
|
|
71
|
+
}
|
|
72
|
+
text.push_str(&decoded);
|
|
62
73
|
}
|
|
63
74
|
}
|
|
75
|
+
|
|
64
76
|
text
|
|
65
77
|
}
|
|
66
78
|
|