@iyulab/unpdf 0.17.0 → 0.18.0
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 +11 -8
- package/package.json +1 -1
- package/unpdf_wasm_bg.wasm +0 -0
package/README.md
CHANGED
|
@@ -10,12 +10,14 @@ npm install @iyulab/unpdf
|
|
|
10
10
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
13
|
+
> This package is built with `wasm-pack --target bundler`. It is an ES module and the
|
|
14
|
+
> WebAssembly binary is initialised for you, so there is no `init()` to await — import
|
|
15
|
+
> the functions and call them. Use it through a bundler (webpack, Vite, Rollup, esbuild).
|
|
16
|
+
|
|
13
17
|
### Browser / Bundler (webpack, vite)
|
|
14
18
|
|
|
15
19
|
```js
|
|
16
|
-
import
|
|
17
|
-
|
|
18
|
-
await init();
|
|
20
|
+
import { parse } from '@iyulab/unpdf';
|
|
19
21
|
|
|
20
22
|
const response = await fetch('document.pdf');
|
|
21
23
|
const bytes = new Uint8Array(await response.arrayBuffer());
|
|
@@ -29,9 +31,7 @@ console.log(`Pages: ${doc.pageCount()}`);
|
|
|
29
31
|
### With Options
|
|
30
32
|
|
|
31
33
|
```js
|
|
32
|
-
import
|
|
33
|
-
|
|
34
|
-
await init();
|
|
34
|
+
import { parseWithOptions, ParseOptions } from '@iyulab/unpdf';
|
|
35
35
|
|
|
36
36
|
const opts = new ParseOptions()
|
|
37
37
|
.lenient()
|
|
@@ -44,9 +44,12 @@ console.log(doc.toMarkdown());
|
|
|
44
44
|
|
|
45
45
|
### Node.js
|
|
46
46
|
|
|
47
|
+
The bundler target is an ES module, so import it rather than `require` it, and run it
|
|
48
|
+
through a bundler.
|
|
49
|
+
|
|
47
50
|
```js
|
|
48
|
-
|
|
49
|
-
|
|
51
|
+
import { parse } from '@iyulab/unpdf';
|
|
52
|
+
import fs from 'node:fs';
|
|
50
53
|
|
|
51
54
|
const bytes = fs.readFileSync('document.pdf');
|
|
52
55
|
const doc = parse(new Uint8Array(bytes));
|
package/package.json
CHANGED
package/unpdf_wasm_bg.wasm
CHANGED
|
Binary file
|