You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -351,13 +352,40 @@ See [`example/basic.esm.worker.html`](example/basic.esm.worker.html) for a worki
351
352
352
353
>**Benchmark Note:** The benchmark currently runs only against `pdf2json`. I don't know the current state of `pdf2json` — the original reason for creating `pdf-parse` was to work around stability issues with `pdf2json`. I deliberately did not include `pdf-parse` or other `pdf.js`-based packages in the benchmark because dependencies conflict. If you have recommendations for additional packages to include, please open an issue, see [`benchmark results`](https://mehmet-kozan.github.io/pdf-parse/bench.html).
Requires additional setup — import and configure a compatible CanvasFactory or worker implementation before initializing pdf-parse; see the examples below.
365
+
366
+
ESM
367
+
```js
368
+
import { CustomCanvasFactory } from 'pdf-parse/canvas'; // Import this before importing "pdf-parse"
369
+
import { PDFParse } from 'pdf-parse';
370
+
371
+
const parser = new PDFParse({ data: buffer, CanvasFactory: CustomCanvasFactory });
372
+
// then use parser
373
+
```
374
+
375
+
CommonJS
376
+
```js
377
+
const { CustomCanvasFactory } = require('pdf-parse/canvas'); // Import this before importing "pdf-parse"
378
+
const { PDFParse } = require('pdf-parse');
379
+
380
+
const parser = new PDFParse({ data: buffer, CanvasFactory: CustomCanvasFactory });
381
+
// then use parser
382
+
```
383
+
384
+
Unsupported tests run on Node.js 18, 19, 21, see [`test_unsupported.yml`](./.github/workflows/test_unsupported.yml).
385
+
Check: [`test_unsupported`](./test_unsupported)
386
+
387
+
388
+
361
389
## Contributing
362
390
363
391
When opening an issue, please attach the relevant PDF file if possible. Providing the file will help us reproduce and resolve your issue more efficiently. For detailed guidelines on how to contribute, report bugs, or submit pull requests, see: [`contributing to pdf-parse`](https://github.com/mehmet-kozan/pdf-parse?tab=contributing-ov-file#contributing-to-pdf-parse)
0 commit comments