@jackgreen2018/pdf-engine 1.0.107 → 1.0.109
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 +25 -5
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +24 -0
- package/package.json +1 -1
- package/src/index.ts +40 -0
- package/src/lib.rs +96 -1
- package/pkg/LICENSE +0 -21
- package/pkg/README.md +0 -176
- package/pkg/package.json +0 -16
- package/pkg/pdf_engine.d.ts +0 -14
- package/pkg/pdf_engine.js +0 -9
- package/pkg/pdf_engine_bg.js +0 -220
- package/pkg/pdf_engine_bg.wasm +0 -0
- package/pkg/pdf_engine_bg.wasm.d.ts +0 -14
package/README.md
CHANGED
|
@@ -15,6 +15,9 @@ A high-performance PDF processing library for Node.js and the browser. Built wit
|
|
|
15
15
|
- **Text Extraction**: Extract text content from PDF files with accurate parsing
|
|
16
16
|
- **PDF Merge**: Combine multiple PDFs into a single file
|
|
17
17
|
- **PDF Split**: Split PDFs by page range
|
|
18
|
+
- **PDF Encryption**: Encrypt PDFs with RC4 (V1/V2) or AES-128 (V4) using user/owner passwords
|
|
19
|
+
- **PDF Decryption**: Decrypt password-protected PDFs
|
|
20
|
+
- **Encrypted Detection**: Check if a PDF is encrypted with `isEncrypted()`
|
|
18
21
|
- **Privacy**: All processing happens in the user's browser or local environment
|
|
19
22
|
- **Performance**: Rust-powered with WASM for maximum speed
|
|
20
23
|
|
|
@@ -59,6 +62,20 @@ const mergedPdf = await pdfEngine.merge([pdf1Buffer, pdf2Buffer, pdf3Buffer]);
|
|
|
59
62
|
// Split a PDF by page numbers
|
|
60
63
|
const pagesToExtract = [1, 3, 5];
|
|
61
64
|
const splitParts = await pdfEngine.split(new Uint8Array(arrayBuffer), pagesToExtract);
|
|
65
|
+
|
|
66
|
+
// Encrypt a PDF (V4 = AES-128)
|
|
67
|
+
const encrypted = await pdfEngine.encrypt(
|
|
68
|
+
new Uint8Array(arrayBuffer),
|
|
69
|
+
"user-password",
|
|
70
|
+
"owner-password",
|
|
71
|
+
4, // version: 1=RC4, 2=RC4-40bit, 4=AES-128
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
// Check if encrypted
|
|
75
|
+
const isEnc = await pdfEngine.isEncrypted(new Uint8Array(arrayBuffer));
|
|
76
|
+
|
|
77
|
+
// Decrypt a password-protected PDF
|
|
78
|
+
const decrypted = await pdfEngine.decrypt(encrypted, "user-password");
|
|
62
79
|
```
|
|
63
80
|
|
|
64
81
|
### Node.js
|
|
@@ -114,14 +131,16 @@ npm run benchmark
|
|
|
114
131
|
|
|
115
132
|
| Operation | pdf-engine (ms) | pdf-lib (ms) |
|
|
116
133
|
|-----------|-----------------|--------------|
|
|
117
|
-
| Page Count | 0.
|
|
118
|
-
| Text Extraction | 0.
|
|
119
|
-
| Merge (2 files) |
|
|
120
|
-
| Split (pages [0,1]) | 0.
|
|
134
|
+
| Page Count | 0.85 | 2.67 |
|
|
135
|
+
| Text Extraction | 0.30 | — |
|
|
136
|
+
| Merge (2 files) | 0.78 | 3.93 |
|
|
137
|
+
| Split (pages [0,1]) | 0.23 | 1.62 |
|
|
138
|
+
| Encrypt (V4 AES-128) | 0.77 | — |
|
|
139
|
+
| Decrypt | 0.36 | — |
|
|
121
140
|
|
|
122
141
|
*extractText correctness: PASS — gated via `tests/fixtures/text-fixture.pdf` (FlateDecode-compressed, real-world content stream). v1.0.30 fixes extractText to return actual text instead of "No text extracted."*
|
|
123
142
|
|
|
124
|
-
*Run 2026-08-03 (v1.0.
|
|
143
|
+
*Run 2026-08-03 (v1.0.109); raw JSON at benchmark-results.json.*
|
|
125
144
|
|
|
126
145
|
## Commercial license & support
|
|
127
146
|
|
|
@@ -160,6 +179,7 @@ m.initialize().then(() => m.getPageCount(new Uint8Array(buf)))
|
|
|
160
179
|
| AC-6 | Scoped package metadata has version, license, repository, correct artifact entry points, and `.d.ts`; package is public under `@jackgreen2018/pdf-engine`. | `package.json`, `evidence/npm-whoami.log`, `evidence/npm-publish.log`, `evidence/npm-view.log`, `evidence/npm-page.log` |
|
|
161
180
|
| AC-7 | README provides the install command, working example, measured benchmark table, npm URL, and direct AC-to-evidence index with no unsupported "verified" claim. | This README, `evidence/AC-SUMMARY.md`, all referenced files present |
|
|
162
181
|
| AC-8 | Final app repository commit is tagged `v1.0.0`; cycle scratch is absent and no web-deployment artifacts were added. | `evidence/git-tag.log`, final tree inspection |
|
|
182
|
+
| AC-9 | Encrypt/decrypt round-trip preserves page count; `isEncrypted` correctly reports true for encrypted and false for unencrypted PDFs. | `tests/smoke.js` encrypt/decrypt tests, benchmark `encrypt` gate |
|
|
163
183
|
|
|
164
184
|
## Launch post
|
|
165
185
|
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,9 @@ export declare function getPageCount(buffer: Uint8Array): Promise<number>;
|
|
|
3
3
|
export declare function extractText(buffer: Uint8Array): Promise<string>;
|
|
4
4
|
export declare function merge(pdfBuffers: Uint8Array[]): Promise<Uint8Array>;
|
|
5
5
|
export declare function split(buffer: Uint8Array, pages: number[]): Promise<Uint8Array[]>;
|
|
6
|
+
export declare function isEncrypted(buffer: Uint8Array): Promise<boolean>;
|
|
7
|
+
export declare function encrypt(buffer: Uint8Array, userPassword: string, ownerPassword: string, version?: number): Promise<Uint8Array>;
|
|
8
|
+
export declare function decrypt(buffer: Uint8Array, password: string): Promise<Uint8Array>;
|
|
6
9
|
export declare class PdfEngineImpl {
|
|
7
10
|
constructor();
|
|
8
11
|
private initialized;
|
|
@@ -11,6 +14,9 @@ export declare class PdfEngineImpl {
|
|
|
11
14
|
extractText(buffer: Uint8Array): Promise<string>;
|
|
12
15
|
merge(pdfBuffers: Uint8Array[]): Promise<Uint8Array>;
|
|
13
16
|
split(buffer: Uint8Array, pages: number[]): Promise<Uint8Array[]>;
|
|
17
|
+
isEncrypted(buffer: Uint8Array): Promise<boolean>;
|
|
18
|
+
encrypt(buffer: Uint8Array, userPassword: string, ownerPassword: string, version?: number): Promise<Uint8Array>;
|
|
19
|
+
decrypt(buffer: Uint8Array, password: string): Promise<Uint8Array>;
|
|
14
20
|
}
|
|
15
21
|
declare const pdfEngine: PdfEngineImpl;
|
|
16
22
|
export default pdfEngine;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,wBAAsB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAEhD;AAED,wBAAsB,YAAY,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAEtE;AAED,wBAAsB,WAAW,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAErE;AAED,wBAAsB,KAAK,CAAC,UAAU,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CAGzE;AAED,wBAAsB,KAAK,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CAGtF;AAED,qBAAa,aAAa;IACtB,cAEC;IACD,OAAO,CAAC,WAAW,CAAS;IAEtB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAK1B;IAEK,YAAY,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAGtD;IAEK,WAAW,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAGrD;IAEK,KAAK,CAAC,UAAU,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CAGzD;IAEK,KAAK,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CAGtE;CACJ;AAED,QAAA,MAAM,SAAS,eAAsB,CAAC;eACvB,SAAS"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,wBAAsB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAEhD;AAED,wBAAsB,YAAY,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAEtE;AAED,wBAAsB,WAAW,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAErE;AAED,wBAAsB,KAAK,CAAC,UAAU,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CAGzE;AAED,wBAAsB,KAAK,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CAGtF;AAED,wBAAsB,WAAW,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,CAGtE;AAED,wBAAsB,OAAO,CACzB,MAAM,EAAE,UAAU,EAClB,YAAY,EAAE,MAAM,EACpB,aAAa,EAAE,MAAM,EACrB,OAAO,SAAI,GACZ,OAAO,CAAC,UAAU,CAAC,CAGrB;AAED,wBAAsB,OAAO,CAAC,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAGvF;AAED,qBAAa,aAAa;IACtB,cAEC;IACD,OAAO,CAAC,WAAW,CAAS;IAEtB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAK1B;IAEK,YAAY,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAGtD;IAEK,WAAW,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAGrD;IAEK,KAAK,CAAC,UAAU,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CAGzD;IAEK,KAAK,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CAGtE;IAEK,WAAW,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,CAGtD;IAEK,OAAO,CACT,MAAM,EAAE,UAAU,EAClB,YAAY,EAAE,MAAM,EACpB,aAAa,EAAE,MAAM,EACrB,OAAO,SAAI,GACZ,OAAO,CAAC,UAAU,CAAC,CAGrB;IAEK,OAAO,CAAC,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAGvE;CACJ;AAED,QAAA,MAAM,SAAS,eAAsB,CAAC;eACvB,SAAS"}
|
package/dist/index.js
CHANGED
|
@@ -17,6 +17,18 @@ export async function split(buffer, pages) {
|
|
|
17
17
|
const resultArray = await wasm.split(buffer, pages);
|
|
18
18
|
return Array.from(resultArray).map(arr => arr);
|
|
19
19
|
}
|
|
20
|
+
export async function isEncrypted(buffer) {
|
|
21
|
+
const result = await wasm.is_encrypted(buffer);
|
|
22
|
+
return result;
|
|
23
|
+
}
|
|
24
|
+
export async function encrypt(buffer, userPassword, ownerPassword, version = 4) {
|
|
25
|
+
const result = await wasm.encrypt(buffer, userPassword, ownerPassword, version);
|
|
26
|
+
return result;
|
|
27
|
+
}
|
|
28
|
+
export async function decrypt(buffer, password) {
|
|
29
|
+
const result = await wasm.decrypt(buffer, password);
|
|
30
|
+
return result;
|
|
31
|
+
}
|
|
20
32
|
export class PdfEngineImpl {
|
|
21
33
|
constructor() {
|
|
22
34
|
this.initialized = false;
|
|
@@ -44,6 +56,18 @@ export class PdfEngineImpl {
|
|
|
44
56
|
await this.init();
|
|
45
57
|
return await split(buffer, pages);
|
|
46
58
|
}
|
|
59
|
+
async isEncrypted(buffer) {
|
|
60
|
+
await this.init();
|
|
61
|
+
return await isEncrypted(buffer);
|
|
62
|
+
}
|
|
63
|
+
async encrypt(buffer, userPassword, ownerPassword, version = 4) {
|
|
64
|
+
await this.init();
|
|
65
|
+
return await encrypt(buffer, userPassword, ownerPassword, version);
|
|
66
|
+
}
|
|
67
|
+
async decrypt(buffer, password) {
|
|
68
|
+
await this.init();
|
|
69
|
+
return await decrypt(buffer, password);
|
|
70
|
+
}
|
|
47
71
|
}
|
|
48
72
|
const pdfEngine = new PdfEngineImpl();
|
|
49
73
|
export default pdfEngine;
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -24,6 +24,26 @@ export async function split(buffer: Uint8Array, pages: number[]): Promise<Uint8A
|
|
|
24
24
|
return Array.from(resultArray).map(arr => arr as Uint8Array);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
export async function isEncrypted(buffer: Uint8Array): Promise<boolean> {
|
|
28
|
+
const result = await wasm.is_encrypted(buffer);
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export async function encrypt(
|
|
33
|
+
buffer: Uint8Array,
|
|
34
|
+
userPassword: string,
|
|
35
|
+
ownerPassword: string,
|
|
36
|
+
version = 4,
|
|
37
|
+
): Promise<Uint8Array> {
|
|
38
|
+
const result = await wasm.encrypt(buffer, userPassword, ownerPassword, version);
|
|
39
|
+
return result;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export async function decrypt(buffer: Uint8Array, password: string): Promise<Uint8Array> {
|
|
43
|
+
const result = await wasm.decrypt(buffer, password);
|
|
44
|
+
return result;
|
|
45
|
+
}
|
|
46
|
+
|
|
27
47
|
export class PdfEngineImpl {
|
|
28
48
|
constructor() {
|
|
29
49
|
this.initialized = false;
|
|
@@ -56,6 +76,26 @@ export class PdfEngineImpl {
|
|
|
56
76
|
await this.init();
|
|
57
77
|
return await split(buffer, pages);
|
|
58
78
|
}
|
|
79
|
+
|
|
80
|
+
async isEncrypted(buffer: Uint8Array): Promise<boolean> {
|
|
81
|
+
await this.init();
|
|
82
|
+
return await isEncrypted(buffer);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
async encrypt(
|
|
86
|
+
buffer: Uint8Array,
|
|
87
|
+
userPassword: string,
|
|
88
|
+
ownerPassword: string,
|
|
89
|
+
version = 4,
|
|
90
|
+
): Promise<Uint8Array> {
|
|
91
|
+
await this.init();
|
|
92
|
+
return await encrypt(buffer, userPassword, ownerPassword, version);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
async decrypt(buffer: Uint8Array, password: string): Promise<Uint8Array> {
|
|
96
|
+
await this.init();
|
|
97
|
+
return await decrypt(buffer, password);
|
|
98
|
+
}
|
|
59
99
|
}
|
|
60
100
|
|
|
61
101
|
const pdfEngine = new PdfEngineImpl();
|
package/src/lib.rs
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
use wasm_bindgen::prelude::*;
|
|
2
2
|
use js_sys::{Array, Uint8Array};
|
|
3
|
-
use lopdf::{Document, Object, ObjectId};
|
|
3
|
+
use lopdf::{Document, Object, ObjectId, encryption::{EncryptionState, EncryptionVersion, Permissions}};
|
|
4
|
+
use lopdf::encryption::crypt_filters::{CryptFilter, Aes128CryptFilter};
|
|
4
5
|
use std::collections::BTreeMap;
|
|
6
|
+
use std::sync::Arc;
|
|
5
7
|
|
|
6
8
|
#[wasm_bindgen]
|
|
7
9
|
pub fn init() -> Result<(), JsValue> {
|
|
@@ -281,6 +283,99 @@ pub fn get_pdf_info(buffer: &[u8]) -> Result<String, JsValue> {
|
|
|
281
283
|
Ok(format!("PDF with {} pages", count))
|
|
282
284
|
}
|
|
283
285
|
|
|
286
|
+
#[wasm_bindgen]
|
|
287
|
+
pub fn is_encrypted(buffer: &[u8]) -> Result<bool, JsValue> {
|
|
288
|
+
let doc = Document::load_mem(buffer)
|
|
289
|
+
.map_err(|e| JsValue::from_str(&format!("PDF load error: {}", e)))?;
|
|
290
|
+
Ok(doc.is_encrypted())
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
#[wasm_bindgen]
|
|
294
|
+
pub fn encrypt(
|
|
295
|
+
buffer: &[u8],
|
|
296
|
+
user_password: &str,
|
|
297
|
+
owner_password: &str,
|
|
298
|
+
version: u32,
|
|
299
|
+
) -> Result<Uint8Array, JsValue> {
|
|
300
|
+
let doc = Document::load_mem(buffer)
|
|
301
|
+
.map_err(|e| JsValue::from_str(&format!("PDF load error: {}", e)))?;
|
|
302
|
+
|
|
303
|
+
// Ensure /ID trailer entry exists (required by PDF encryption spec)
|
|
304
|
+
let mut doc = doc;
|
|
305
|
+
if doc.trailer.get(b"ID").is_err() {
|
|
306
|
+
doc.trailer.set(b"ID", Object::Array(vec![
|
|
307
|
+
Object::string_literal(b"pdf-engine-2024-08-03-encrypt-id-1"),
|
|
308
|
+
Object::string_literal(b"pdf-engine-2024-08-03-encrypt-id-2"),
|
|
309
|
+
]));
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
// ponytail: version arg maps 1→V1/RC4, 2→V2/RC4-40bit, 4→V4/AES-128
|
|
313
|
+
// V5 requires raw file_encryption_key from user; omitted for now
|
|
314
|
+
let state = match version {
|
|
315
|
+
1 => {
|
|
316
|
+
EncryptionState::try_from(EncryptionVersion::V1 {
|
|
317
|
+
document: &doc,
|
|
318
|
+
owner_password,
|
|
319
|
+
user_password,
|
|
320
|
+
permissions: Permissions::default(),
|
|
321
|
+
})
|
|
322
|
+
.map_err(|e| JsValue::from_str(&format!("Encrypt setup error: {}", e)))?
|
|
323
|
+
}
|
|
324
|
+
2 => {
|
|
325
|
+
EncryptionState::try_from(EncryptionVersion::V2 {
|
|
326
|
+
document: &doc,
|
|
327
|
+
owner_password,
|
|
328
|
+
user_password,
|
|
329
|
+
key_length: 40,
|
|
330
|
+
permissions: Permissions::default(),
|
|
331
|
+
})
|
|
332
|
+
.map_err(|e| JsValue::from_str(&format!("Encrypt setup error: {}", e)))?
|
|
333
|
+
}
|
|
334
|
+
4 => {
|
|
335
|
+
let crypt_filter: Arc<dyn CryptFilter> = Arc::new(Aes128CryptFilter);
|
|
336
|
+
let mut crypt_filters = BTreeMap::new();
|
|
337
|
+
crypt_filters.insert(b"StdCF".to_vec(), crypt_filter);
|
|
338
|
+
EncryptionState::try_from(EncryptionVersion::V4 {
|
|
339
|
+
document: &doc,
|
|
340
|
+
encrypt_metadata: false,
|
|
341
|
+
crypt_filters,
|
|
342
|
+
stream_filter: b"StdCF".to_vec(),
|
|
343
|
+
string_filter: b"StdCF".to_vec(),
|
|
344
|
+
owner_password,
|
|
345
|
+
user_password,
|
|
346
|
+
permissions: Permissions::default(),
|
|
347
|
+
})
|
|
348
|
+
.map_err(|e| JsValue::from_str(&format!("Encrypt setup error: {}", e)))?
|
|
349
|
+
}
|
|
350
|
+
_ => return Err(JsValue::from_str("unsupported encryption version")),
|
|
351
|
+
};
|
|
352
|
+
|
|
353
|
+
doc.encrypt(&state)
|
|
354
|
+
.map_err(|e| JsValue::from_str(&format!("Encryption failed: {}", e)))?;
|
|
355
|
+
|
|
356
|
+
let mut buf = Vec::new();
|
|
357
|
+
doc.save_to(&mut buf)
|
|
358
|
+
.map_err(|e| JsValue::from_str(&format!("Save error: {}", e)))?;
|
|
359
|
+
Ok(Uint8Array::new_from_slice(&buf))
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
#[wasm_bindgen]
|
|
363
|
+
pub fn decrypt(buffer: &[u8], password: &str) -> Result<Uint8Array, JsValue> {
|
|
364
|
+
let mut doc = Document::load_mem(buffer)
|
|
365
|
+
.map_err(|e| JsValue::from_str(&format!("PDF load error: {}", e)))?;
|
|
366
|
+
|
|
367
|
+
if !doc.is_encrypted() {
|
|
368
|
+
return Err(JsValue::from_str("PDF is not encrypted"));
|
|
369
|
+
}
|
|
370
|
+
doc.decrypt(password)
|
|
371
|
+
.map_err(|e| JsValue::from_str(&format!("Decryption failed: {}", e)))?;
|
|
372
|
+
|
|
373
|
+
let mut buf = Vec::new();
|
|
374
|
+
doc.save_to(&mut buf)
|
|
375
|
+
.map_err(|e| JsValue::from_str(&format!("Save error: {}", e)))?;
|
|
376
|
+
Ok(Uint8Array::new_from_slice(&buf))
|
|
377
|
+
}
|
|
378
|
+
|
|
284
379
|
#[cfg(test)]
|
|
285
380
|
mod tests {
|
|
286
381
|
use super::*;
|
package/pkg/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024 Jack Green
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
package/pkg/README.md
DELETED
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
> Scope: full engine (see [SCOPE.md](./SCOPE.md)).
|
|
2
|
-
|
|
3
|
-
# pdf-engine — Rust/WASM PDF Processing Library
|
|
4
|
-
|
|
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).
|
|
11
|
-
|
|
12
|
-
## Features
|
|
13
|
-
|
|
14
|
-
- **Page Count**: Quickly determine the number of pages in a PDF using a proper PDF parser
|
|
15
|
-
- **Text Extraction**: Extract text content from PDF files with accurate parsing
|
|
16
|
-
- **PDF Merge**: Combine multiple PDFs into a single file
|
|
17
|
-
- **PDF Split**: Split PDFs by page range
|
|
18
|
-
- **Privacy**: All processing happens in the user's browser or local environment
|
|
19
|
-
- **Performance**: Rust-powered with WASM for maximum speed
|
|
20
|
-
|
|
21
|
-
## Installation
|
|
22
|
-
|
|
23
|
-
```bash
|
|
24
|
-
npm install @jackgreen2018/pdf-engine
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
Or build from source:
|
|
28
|
-
|
|
29
|
-
```bash
|
|
30
|
-
git clone <this-repo>
|
|
31
|
-
cd pdf-engine
|
|
32
|
-
npm install
|
|
33
|
-
npm run build
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
## Usage
|
|
37
|
-
|
|
38
|
-
### Browser
|
|
39
|
-
|
|
40
|
-
```javascript
|
|
41
|
-
import pdfEngine from '@jackgreen2018/pdf-engine';
|
|
42
|
-
|
|
43
|
-
// Initialize the engine
|
|
44
|
-
await pdfEngine.init();
|
|
45
|
-
|
|
46
|
-
// Get page count of a PDF file
|
|
47
|
-
const file = document.querySelector('input[type="file"]').files[0];
|
|
48
|
-
const arrayBuffer = await file.arrayBuffer();
|
|
49
|
-
const pageCount = await pdfEngine.getPageCount(new Uint8Array(arrayBuffer));
|
|
50
|
-
console.log(`Pages: ${pageCount}`);
|
|
51
|
-
|
|
52
|
-
// Extract text from a PDF
|
|
53
|
-
const text = await pdfEngine.extractText(new Uint8Array(arrayBuffer));
|
|
54
|
-
console.log(text);
|
|
55
|
-
|
|
56
|
-
// Merge multiple PDFs
|
|
57
|
-
const mergedPdf = await pdfEngine.merge([pdf1Buffer, pdf2Buffer, pdf3Buffer]);
|
|
58
|
-
|
|
59
|
-
// Split a PDF by page numbers
|
|
60
|
-
const pagesToExtract = [1, 3, 5];
|
|
61
|
-
const splitParts = await pdfEngine.split(new Uint8Array(arrayBuffer), pagesToExtract);
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
### Node.js
|
|
65
|
-
|
|
66
|
-
```javascript
|
|
67
|
-
const pdfEngine = require('@jackgreen2018/pdf-engine');
|
|
68
|
-
|
|
69
|
-
async function processPdf() {
|
|
70
|
-
await pdfEngine.init();
|
|
71
|
-
|
|
72
|
-
const buffer = require('fs').readFileSync('document.pdf');
|
|
73
|
-
const pageCount = await pdfEngine.getPageCount(buffer);
|
|
74
|
-
console.log(`Pages: ${pageCount}`);
|
|
75
|
-
|
|
76
|
-
const text = await pdfEngine.extractText(buffer);
|
|
77
|
-
console.log(text);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
processPdf().catch(console.error);
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
## Build
|
|
84
|
-
|
|
85
|
-
```bash
|
|
86
|
-
npm run build
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
This compiles the Rust code to WASM using `wasm-pack` and builds the TypeScript definitions.
|
|
90
|
-
|
|
91
|
-
## Development
|
|
92
|
-
|
|
93
|
-
```bash
|
|
94
|
-
# Install dependencies
|
|
95
|
-
npm install
|
|
96
|
-
|
|
97
|
-
# Build the project
|
|
98
|
-
npm run build
|
|
99
|
-
|
|
100
|
-
# Run benchmarks
|
|
101
|
-
npm run benchmark
|
|
102
|
-
|
|
103
|
-
# Test locally
|
|
104
|
-
npm test
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
## Benchmark
|
|
108
|
-
|
|
109
|
-
Performance benchmarks for pdf-engine operations:
|
|
110
|
-
|
|
111
|
-
```
|
|
112
|
-
npm run benchmark
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
| Operation | pdf-engine (ms) | pdf-lib (ms) |
|
|
116
|
-
|-----------|-----------------|--------------|
|
|
117
|
-
| Page Count | 0.72 | 1.44 |
|
|
118
|
-
| Text Extraction | 0.50 | — |
|
|
119
|
-
| Merge (2 files) | 0.99 | 3.78 |
|
|
120
|
-
| Split (pages [0,1]) | 0.20 | 2.01 |
|
|
121
|
-
|
|
122
|
-
*extractText correctness: PASS — gated via `tests/fixtures/text-fixture.pdf` (FlateDecode-compressed, real-world content stream). v1.0.30 fixes extractText to return actual text instead of "No text extracted."*
|
|
123
|
-
|
|
124
|
-
*Run 2026-08-03 (v1.0.104); raw JSON at benchmark-results.json.*
|
|
125
|
-
|
|
126
|
-
## Commercial license & support
|
|
127
|
-
|
|
128
|
-
Need to ship `pdf-engine` in closed-source software without the MIT attribution requirement, or need it for procurement/legal sign-off? A perpetual, per-seat commercial license is $49 one-time.
|
|
129
|
-
|
|
130
|
-
**[Buy the commercial license →](https://creem.io/product/prod_3ZlNAxFzbn9vwfT4Ho3OKJ)**
|
|
131
|
-
|
|
132
|
-
See [COMMERCIAL-LICENSE.md](./COMMERCIAL-LICENSE.md) for full terms. Team licenses, POs, or questions: `jackgreen2018+sponsors@gmail.com`.
|
|
133
|
-
|
|
134
|
-
## License
|
|
135
|
-
|
|
136
|
-
MIT
|
|
137
|
-
|
|
138
|
-
## Verify locally
|
|
139
|
-
|
|
140
|
-
```bash
|
|
141
|
-
npm install @jackgreen2018/pdf-engine
|
|
142
|
-
node -e '
|
|
143
|
-
const fs = require("fs");
|
|
144
|
-
const m = require("@jackgreen2018/pdf-engine");
|
|
145
|
-
const buf = fs.readFileSync("test.pdf");
|
|
146
|
-
m.initialize().then(() => m.getPageCount(new Uint8Array(buf)))
|
|
147
|
-
.then(n => console.log("pages:", n));
|
|
148
|
-
'
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
## Acceptance Criteria Evidence
|
|
152
|
-
|
|
153
|
-
| AC | Verifiable requirement | Committed proof |
|
|
154
|
-
|---|---|---|
|
|
155
|
-
| AC-1 | Real Rust source with `lopdf` domain dependency compiles to a non-stub WASM artifact; JS and TypeScript declarations build. | `Cargo.toml`, `src/`, `pkg/`, `dist/`, `evidence/cargo-build.log`, `evidence/wasm-pack-build.log`, `evidence/gate-artifact.log` |
|
|
156
|
-
| AC-2 | Rust and package tests pass on the final source. | `evidence/cargo-test.log`, `evidence/npm-test.log` |
|
|
157
|
-
| AC-3 | The exact npm tarball installs in a clean consumer and page count, merge, and split return valid PDFs with correct page counts. | `jackgreen2018-pdf-engine-1.0.18.tgz`, `evidence/npm-pack.log`, `evidence/local-install-smoke.log`, `evidence/gate-behavior.log` |
|
|
158
|
-
| AC-4 | A runnable head-to-head benchmark against `pdf-lib` uses realistic identical input, validates output, and produces real numbers matching README. | `benchmark.mjs`, `evidence/benchmark.log`, `evidence/benchmark.json`, benchmark table above |
|
|
159
|
-
| AC-5 | Both required hard gates pass for `/apps/pdf-engine` before publication. | `evidence/gate-artifact.log` (exit 0), `evidence/gate-behavior.log` (exit 0) |
|
|
160
|
-
| AC-6 | Scoped package metadata has version, license, repository, correct artifact entry points, and `.d.ts`; package is public under `@jackgreen2018/pdf-engine`. | `package.json`, `evidence/npm-whoami.log`, `evidence/npm-publish.log`, `evidence/npm-view.log`, `evidence/npm-page.log` |
|
|
161
|
-
| AC-7 | README provides the install command, working example, measured benchmark table, npm URL, and direct AC-to-evidence index with no unsupported "verified" claim. | This README, `evidence/AC-SUMMARY.md`, all referenced files present |
|
|
162
|
-
| AC-8 | Final app repository commit is tagged `v1.0.0`; cycle scratch is absent and no web-deployment artifacts were added. | `evidence/git-tag.log`, final tree inspection |
|
|
163
|
-
|
|
164
|
-
## Launch post
|
|
165
|
-
|
|
166
|
-
Draft lives at [`evidence/devto-launch-post.md`](./evidence/devto-launch-post.md).
|
|
167
|
-
Posting requires a `DEVTO_API_KEY` (manual step). README's published benchmark
|
|
168
|
-
numbers (`evidence/benchmark.log`) are the source of truth until the dev.to URL exists.
|
|
169
|
-
|
|
170
|
-
## See Also
|
|
171
|
-
|
|
172
|
-
- [pdf-lib](https://www.npmjs.com/package/pdf-lib) — A popular JavaScript PDF library for comparison
|
|
173
|
-
|
|
174
|
-
## Backlinks
|
|
175
|
-
|
|
176
|
-
- Dev.to launch post (canonical for this version): https://www.npmjs.com/package/@jackgreen2018/pdf-engine
|
package/pkg/package.json
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "pdf_engine",
|
|
3
|
-
"version": "1.0.105",
|
|
4
|
-
"files": [
|
|
5
|
-
"pdf_engine_bg.wasm",
|
|
6
|
-
"pdf_engine.js",
|
|
7
|
-
"pdf_engine_bg.js",
|
|
8
|
-
"pdf_engine.d.ts"
|
|
9
|
-
],
|
|
10
|
-
"module": "pdf_engine.js",
|
|
11
|
-
"types": "pdf_engine.d.ts",
|
|
12
|
-
"sideEffects": [
|
|
13
|
-
"./pdf_engine.js",
|
|
14
|
-
"./snippets/*"
|
|
15
|
-
]
|
|
16
|
-
}
|
package/pkg/pdf_engine.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/* tslint:disable */
|
|
2
|
-
/* eslint-disable */
|
|
3
|
-
|
|
4
|
-
export function extract_text(buffer: Uint8Array): string;
|
|
5
|
-
|
|
6
|
-
export function get_page_count(buffer: Uint8Array): number;
|
|
7
|
-
|
|
8
|
-
export function get_pdf_info(buffer: Uint8Array): string;
|
|
9
|
-
|
|
10
|
-
export function init(): void;
|
|
11
|
-
|
|
12
|
-
export function merge(pdf_buffers: Array<any>): Uint8Array;
|
|
13
|
-
|
|
14
|
-
export function split(buffer: Uint8Array, pages: Array<any>): Array<any>;
|
package/pkg/pdf_engine.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/* @ts-self-types="./pdf_engine.d.ts" */
|
|
2
|
-
import * as wasm from "./pdf_engine_bg.wasm";
|
|
3
|
-
import { __wbg_set_wasm } from "./pdf_engine_bg.js";
|
|
4
|
-
|
|
5
|
-
__wbg_set_wasm(wasm);
|
|
6
|
-
wasm.__wbindgen_start();
|
|
7
|
-
export {
|
|
8
|
-
extract_text, get_page_count, get_pdf_info, init, merge, split
|
|
9
|
-
} from "./pdf_engine_bg.js";
|
package/pkg/pdf_engine_bg.js
DELETED
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @param {Uint8Array} buffer
|
|
3
|
-
* @returns {string}
|
|
4
|
-
*/
|
|
5
|
-
export function extract_text(buffer) {
|
|
6
|
-
let deferred3_0;
|
|
7
|
-
let deferred3_1;
|
|
8
|
-
try {
|
|
9
|
-
const ptr0 = passArray8ToWasm0(buffer, wasm.__wbindgen_malloc);
|
|
10
|
-
const len0 = WASM_VECTOR_LEN;
|
|
11
|
-
const ret = wasm.extract_text(ptr0, len0);
|
|
12
|
-
var ptr2 = ret[0];
|
|
13
|
-
var len2 = ret[1];
|
|
14
|
-
if (ret[3]) {
|
|
15
|
-
ptr2 = 0; len2 = 0;
|
|
16
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
17
|
-
}
|
|
18
|
-
deferred3_0 = ptr2;
|
|
19
|
-
deferred3_1 = len2;
|
|
20
|
-
return getStringFromWasm0(ptr2, len2);
|
|
21
|
-
} finally {
|
|
22
|
-
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* @param {Uint8Array} buffer
|
|
28
|
-
* @returns {number}
|
|
29
|
-
*/
|
|
30
|
-
export function get_page_count(buffer) {
|
|
31
|
-
const ptr0 = passArray8ToWasm0(buffer, wasm.__wbindgen_malloc);
|
|
32
|
-
const len0 = WASM_VECTOR_LEN;
|
|
33
|
-
const ret = wasm.get_page_count(ptr0, len0);
|
|
34
|
-
if (ret[2]) {
|
|
35
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
36
|
-
}
|
|
37
|
-
return ret[0] >>> 0;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* @param {Uint8Array} buffer
|
|
42
|
-
* @returns {string}
|
|
43
|
-
*/
|
|
44
|
-
export function get_pdf_info(buffer) {
|
|
45
|
-
let deferred3_0;
|
|
46
|
-
let deferred3_1;
|
|
47
|
-
try {
|
|
48
|
-
const ptr0 = passArray8ToWasm0(buffer, wasm.__wbindgen_malloc);
|
|
49
|
-
const len0 = WASM_VECTOR_LEN;
|
|
50
|
-
const ret = wasm.get_pdf_info(ptr0, len0);
|
|
51
|
-
var ptr2 = ret[0];
|
|
52
|
-
var len2 = ret[1];
|
|
53
|
-
if (ret[3]) {
|
|
54
|
-
ptr2 = 0; len2 = 0;
|
|
55
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
56
|
-
}
|
|
57
|
-
deferred3_0 = ptr2;
|
|
58
|
-
deferred3_1 = len2;
|
|
59
|
-
return getStringFromWasm0(ptr2, len2);
|
|
60
|
-
} finally {
|
|
61
|
-
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export function init() {
|
|
66
|
-
const ret = wasm.init();
|
|
67
|
-
if (ret[1]) {
|
|
68
|
-
throw takeFromExternrefTable0(ret[0]);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* @param {Array<any>} pdf_buffers
|
|
74
|
-
* @returns {Uint8Array}
|
|
75
|
-
*/
|
|
76
|
-
export function merge(pdf_buffers) {
|
|
77
|
-
const ret = wasm.merge(pdf_buffers);
|
|
78
|
-
if (ret[2]) {
|
|
79
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
80
|
-
}
|
|
81
|
-
return takeFromExternrefTable0(ret[0]);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* @param {Uint8Array} buffer
|
|
86
|
-
* @param {Array<any>} pages
|
|
87
|
-
* @returns {Array<any>}
|
|
88
|
-
*/
|
|
89
|
-
export function split(buffer, pages) {
|
|
90
|
-
const ptr0 = passArray8ToWasm0(buffer, wasm.__wbindgen_malloc);
|
|
91
|
-
const len0 = WASM_VECTOR_LEN;
|
|
92
|
-
const ret = wasm.split(ptr0, len0, pages);
|
|
93
|
-
if (ret[2]) {
|
|
94
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
95
|
-
}
|
|
96
|
-
return takeFromExternrefTable0(ret[0]);
|
|
97
|
-
}
|
|
98
|
-
export function __wbg___wbindgen_number_get_394265ed1e1b84ee(arg0, arg1) {
|
|
99
|
-
const obj = arg1;
|
|
100
|
-
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
101
|
-
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
102
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
103
|
-
}
|
|
104
|
-
export function __wbg___wbindgen_throw_344f42d3211c4765(arg0, arg1) {
|
|
105
|
-
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
106
|
-
}
|
|
107
|
-
export function __wbg_get_507a50627bffa49b(arg0, arg1) {
|
|
108
|
-
const ret = arg0[arg1 >>> 0];
|
|
109
|
-
return ret;
|
|
110
|
-
}
|
|
111
|
-
export function __wbg_instanceof_Uint8Array_309b927aaf7a3fc7(arg0) {
|
|
112
|
-
let result;
|
|
113
|
-
try {
|
|
114
|
-
result = arg0 instanceof Uint8Array;
|
|
115
|
-
} catch (_) {
|
|
116
|
-
result = false;
|
|
117
|
-
}
|
|
118
|
-
const ret = result;
|
|
119
|
-
return ret;
|
|
120
|
-
}
|
|
121
|
-
export function __wbg_length_1f0964f4a5e2c6d8(arg0) {
|
|
122
|
-
const ret = arg0.length;
|
|
123
|
-
return ret;
|
|
124
|
-
}
|
|
125
|
-
export function __wbg_length_370319915dc99107(arg0) {
|
|
126
|
-
const ret = arg0.length;
|
|
127
|
-
return ret;
|
|
128
|
-
}
|
|
129
|
-
export function __wbg_new_32b398fb48b6d94a() {
|
|
130
|
-
const ret = new Array();
|
|
131
|
-
return ret;
|
|
132
|
-
}
|
|
133
|
-
export function __wbg_new_from_slice_77cdfb7977362f3c(arg0, arg1) {
|
|
134
|
-
const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
|
|
135
|
-
return ret;
|
|
136
|
-
}
|
|
137
|
-
export function __wbg_prototypesetcall_4770620bbe4688a0(arg0, arg1, arg2) {
|
|
138
|
-
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
139
|
-
}
|
|
140
|
-
export function __wbg_push_d2ae3af0c1217ae6(arg0, arg1) {
|
|
141
|
-
const ret = arg0.push(arg1);
|
|
142
|
-
return ret;
|
|
143
|
-
}
|
|
144
|
-
export function __wbindgen_cast_0000000000000001(arg0, arg1) {
|
|
145
|
-
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
146
|
-
const ret = getStringFromWasm0(arg0, arg1);
|
|
147
|
-
return ret;
|
|
148
|
-
}
|
|
149
|
-
export function __wbindgen_init_externref_table() {
|
|
150
|
-
const table = wasm.__wbindgen_externrefs;
|
|
151
|
-
const offset = table.grow(4);
|
|
152
|
-
table.set(0, undefined);
|
|
153
|
-
table.set(offset + 0, undefined);
|
|
154
|
-
table.set(offset + 1, null);
|
|
155
|
-
table.set(offset + 2, true);
|
|
156
|
-
table.set(offset + 3, false);
|
|
157
|
-
}
|
|
158
|
-
function getArrayU8FromWasm0(ptr, len) {
|
|
159
|
-
ptr = ptr >>> 0;
|
|
160
|
-
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
let cachedDataViewMemory0 = null;
|
|
164
|
-
function getDataViewMemory0() {
|
|
165
|
-
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
166
|
-
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
167
|
-
}
|
|
168
|
-
return cachedDataViewMemory0;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
function getStringFromWasm0(ptr, len) {
|
|
172
|
-
return decodeText(ptr >>> 0, len);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
let cachedUint8ArrayMemory0 = null;
|
|
176
|
-
function getUint8ArrayMemory0() {
|
|
177
|
-
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
178
|
-
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
179
|
-
}
|
|
180
|
-
return cachedUint8ArrayMemory0;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
function isLikeNone(x) {
|
|
184
|
-
return x === undefined || x === null;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
function passArray8ToWasm0(arg, malloc) {
|
|
188
|
-
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
189
|
-
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
190
|
-
WASM_VECTOR_LEN = arg.length;
|
|
191
|
-
return ptr;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
function takeFromExternrefTable0(idx) {
|
|
195
|
-
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
196
|
-
wasm.__externref_table_dealloc(idx);
|
|
197
|
-
return value;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
201
|
-
cachedTextDecoder.decode();
|
|
202
|
-
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
203
|
-
let numBytesDecoded = 0;
|
|
204
|
-
function decodeText(ptr, len) {
|
|
205
|
-
numBytesDecoded += len;
|
|
206
|
-
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
207
|
-
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
208
|
-
cachedTextDecoder.decode();
|
|
209
|
-
numBytesDecoded = len;
|
|
210
|
-
}
|
|
211
|
-
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
let WASM_VECTOR_LEN = 0;
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
let wasm;
|
|
218
|
-
export function __wbg_set_wasm(val) {
|
|
219
|
-
wasm = val;
|
|
220
|
-
}
|
package/pkg/pdf_engine_bg.wasm
DELETED
|
Binary file
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/* tslint:disable */
|
|
2
|
-
/* eslint-disable */
|
|
3
|
-
export const memory: WebAssembly.Memory;
|
|
4
|
-
export const extract_text: (a: number, b: number) => [number, number, number, number];
|
|
5
|
-
export const get_page_count: (a: number, b: number) => [number, number, number];
|
|
6
|
-
export const get_pdf_info: (a: number, b: number) => [number, number, number, number];
|
|
7
|
-
export const init: () => [number, number];
|
|
8
|
-
export const merge: (a: any) => [number, number, number];
|
|
9
|
-
export const split: (a: number, b: number, c: any) => [number, number, number];
|
|
10
|
-
export const __wbindgen_externrefs: WebAssembly.Table;
|
|
11
|
-
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
12
|
-
export const __externref_table_dealloc: (a: number) => void;
|
|
13
|
-
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
14
|
-
export const __wbindgen_start: () => void;
|