node-poppler 9.1.1 → 9.1.2
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 +1 -1
- package/README.md +7 -7
- package/package.json +2 -2
- package/src/index.js +45 -34
- package/types/index.d.ts +17 -16
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2019-present Frazer Smith
|
|
3
|
+
Copyright (c) 2019-present Frazer Smith <frazer.dev@icloud.com>
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
|
@@ -6,36 +6,36 @@
|
|
|
6
6
|
[](https://coveralls.io/github/Fdawgs/node-poppler?branch=main)
|
|
7
7
|
[](https://github.com/prettier/prettier)
|
|
8
8
|
|
|
9
|
-
> Asynchronous Node.js wrapper for the Poppler PDF rendering
|
|
9
|
+
> Asynchronous Node.js wrapper for the Poppler PDF rendering utilities
|
|
10
10
|
|
|
11
11
|
## Overview
|
|
12
12
|
|
|
13
|
-
[Poppler](https://poppler.freedesktop.org/) is a PDF rendering library that also includes a collection of
|
|
13
|
+
[Poppler](https://poppler.freedesktop.org/) is a PDF rendering library that also includes a collection of utilities, which allows for the manipulation and extraction of data from PDF documents such as converting PDF files to HTML, TXT, or PostScript.
|
|
14
14
|
|
|
15
|
-
The `node-poppler` module provides an asynchronous Node.js wrapper around said
|
|
15
|
+
The `node-poppler` module provides an asynchronous Node.js wrapper around said binaries for easier use.
|
|
16
16
|
|
|
17
17
|
## Installation
|
|
18
18
|
|
|
19
19
|
Install using `npm`:
|
|
20
20
|
|
|
21
|
-
```
|
|
21
|
+
```sh
|
|
22
22
|
npm i node-poppler
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
### Linux and macOS/Darwin support
|
|
26
26
|
|
|
27
27
|
64-bit Windows binaries are provided via an optional dependency on the [`node-poppler-win32`](https://www.npmjs.com/package/node-poppler-win32) package.
|
|
28
|
-
For Linux and Mac users, the `poppler-data` and `poppler-utils` binaries
|
|
28
|
+
For Linux and Mac users, the `poppler-data` and `poppler-utils` binaries will need to be installed separately.
|
|
29
29
|
|
|
30
30
|
An example of downloading the binaries on a Debian system:
|
|
31
31
|
|
|
32
|
-
```
|
|
32
|
+
```sh
|
|
33
33
|
sudo apt-get install poppler-data poppler-utils
|
|
34
34
|
```
|
|
35
35
|
|
|
36
36
|
For macOS users, the binaries can be installed with [Homebrew](https://brew.sh/):
|
|
37
37
|
|
|
38
|
-
```
|
|
38
|
+
```sh
|
|
39
39
|
brew install poppler
|
|
40
40
|
```
|
|
41
41
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-poppler",
|
|
3
|
-
"version": "9.1.
|
|
4
|
-
"description": "Asynchronous Node.js wrapper for the Poppler PDF rendering
|
|
3
|
+
"version": "9.1.2",
|
|
4
|
+
"description": "Asynchronous Node.js wrapper for the Poppler PDF rendering utilities",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"async",
|
|
7
7
|
"attach",
|
package/src/index.js
CHANGED
|
@@ -34,7 +34,7 @@ const PDF_INFO_PATH_REG = /(.+)pdfinfo/u;
|
|
|
34
34
|
* @property {string} arg The argument to pass to the binary.
|
|
35
35
|
* @property {('boolean'|'number'|'string')} type The type of the option.
|
|
36
36
|
* @property {string} [minVersion] The minimum version of the binary that supports this option.
|
|
37
|
-
* @property {string} [maxVersion] The maximum version of the binary that supports this option
|
|
37
|
+
* @property {string} [maxVersion] The maximum version of the binary that supports this option.
|
|
38
38
|
*/
|
|
39
39
|
|
|
40
40
|
/**
|
|
@@ -489,6 +489,8 @@ const PDF_INFO_PATH_REG = /(.+)pdfinfo/u;
|
|
|
489
489
|
* @property {boolean} [printVersionInfo] Print copyright and version information.
|
|
490
490
|
*/
|
|
491
491
|
|
|
492
|
+
/** @typedef {(PdfAttachOptions|PdfDetachOptions|PdfFontsOptions|PdfImagesOptions|PdfInfoOptions|PdfSeparateOptions|PdfToCairoOptions|PdfToHtmlOptions|PdfToPpmOptions|PdfToPsOptions|PdfToTextOptions|PdfUniteOptions)} PopplerOptions */
|
|
493
|
+
|
|
492
494
|
/**
|
|
493
495
|
* @typedef {object} PopplerExtraOptions
|
|
494
496
|
* @property {AbortSignal} [signal] An `AbortSignal` that can be used to cancel the operation.
|
|
@@ -576,12 +578,13 @@ function execBinary(binary, args, file, options = {}) {
|
|
|
576
578
|
|
|
577
579
|
/**
|
|
578
580
|
* @author Frazer Smith
|
|
579
|
-
* @description Checks each option provided is valid, of the correct type, and can be used by
|
|
580
|
-
* version of binary.
|
|
581
|
+
* @description Checks each option provided is valid, of the correct type, and can be used by the
|
|
582
|
+
* specified version of the binary.
|
|
583
|
+
* @ignore
|
|
581
584
|
* @ignore
|
|
582
585
|
* @param {PopplerAcceptedOptions} acceptedOptions - Object containing accepted options.
|
|
583
|
-
* @param {
|
|
584
|
-
* @param {string} [version] -
|
|
586
|
+
* @param {PopplerOptions} options - Object containing options to pass to the binary.
|
|
587
|
+
* @param {string} [version] - Semantic version of the binary.
|
|
585
588
|
* @returns {string[]} Array of CLI arguments.
|
|
586
589
|
* @throws {Error} If invalid arguments provided.
|
|
587
590
|
*/
|
|
@@ -601,27 +604,34 @@ function parseOptions(acceptedOptions, options, version) {
|
|
|
601
604
|
continue;
|
|
602
605
|
}
|
|
603
606
|
|
|
604
|
-
// @ts-
|
|
607
|
+
// @ts-expect-error: Keys are from options, TS cannot infer this
|
|
605
608
|
const option = options[key];
|
|
606
609
|
const acceptedOption = acceptedOptions[key];
|
|
610
|
+
const optionType = typeof option;
|
|
607
611
|
|
|
608
|
-
if (
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
// Arg will be empty for some non-standard options
|
|
612
|
-
if (acceptedOption.arg !== "") {
|
|
613
|
-
args.push(acceptedOption.arg);
|
|
614
|
-
}
|
|
612
|
+
if (optionType === "undefined") {
|
|
613
|
+
continue;
|
|
614
|
+
}
|
|
615
615
|
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
616
|
+
if (acceptedOption.type === optionType) {
|
|
617
|
+
// Boolean options set to false won't be passed to the binary; skip arg and version checks
|
|
618
|
+
if (acceptedOption.type === "boolean" && !option) {
|
|
619
|
+
continue;
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
// Arg will be empty for some non-standard options
|
|
623
|
+
if (acceptedOption.arg !== "") {
|
|
624
|
+
args.push(acceptedOption.arg);
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
if (optionType !== "boolean") {
|
|
628
|
+
args.push(option);
|
|
619
629
|
}
|
|
620
630
|
} else {
|
|
621
631
|
invalidArgs.push(
|
|
622
632
|
`Invalid value type provided for option '${key}', expected ${
|
|
623
633
|
acceptedOption.type
|
|
624
|
-
} but received ${
|
|
634
|
+
} but received ${optionType}`
|
|
625
635
|
);
|
|
626
636
|
}
|
|
627
637
|
|
|
@@ -661,11 +671,11 @@ class Poppler {
|
|
|
661
671
|
#acceptedOptions = new Map();
|
|
662
672
|
|
|
663
673
|
/**
|
|
664
|
-
* @param {string} [binPath] - Path
|
|
674
|
+
* @param {string} [binPath] - Path to the directory containing the poppler-utils binaries.
|
|
665
675
|
* If not provided, the constructor will attempt to find the Poppler `pdfinfo` binary
|
|
666
676
|
* in the PATH environment variable and use that as the path for all binaries.
|
|
667
677
|
* For `win32` the binaries are bundled with the package and will be used
|
|
668
|
-
* if
|
|
678
|
+
* if local binaries cannot be found.
|
|
669
679
|
* @throws {Error} If the Poppler binaries cannot be found.
|
|
670
680
|
*/
|
|
671
681
|
constructor(binPath) {
|
|
@@ -676,6 +686,7 @@ class Poppler {
|
|
|
676
686
|
/** @type {string|undefined} */
|
|
677
687
|
this.#popplerPath = binPath;
|
|
678
688
|
} else {
|
|
689
|
+
// Use regex over dirname as `where` on Windows returns a newline-delimited list
|
|
679
690
|
const which = spawnSync(platform === "win32" ? "where" : "which", [
|
|
680
691
|
"pdfinfo",
|
|
681
692
|
]).stdout.toString();
|
|
@@ -698,7 +709,7 @@ class Poppler {
|
|
|
698
709
|
|
|
699
710
|
if (!this.#popplerPath) {
|
|
700
711
|
throw new Error(
|
|
701
|
-
`Unable to find ${platform} Poppler binaries, please pass the
|
|
712
|
+
`Unable to find ${platform} Poppler binaries, please pass the path to the binaries' directory as an argument to the Poppler constructor.`
|
|
702
713
|
);
|
|
703
714
|
}
|
|
704
715
|
this.#popplerPath = normalize(this.#popplerPath);
|
|
@@ -719,7 +730,7 @@ class Poppler {
|
|
|
719
730
|
|
|
720
731
|
/**
|
|
721
732
|
* @description Returns the path of the Poppler binaries.
|
|
722
|
-
* @returns {string} Path of Poppler binaries.
|
|
733
|
+
* @returns {string} Path of the Poppler binaries' directory.
|
|
723
734
|
*/
|
|
724
735
|
get path() {
|
|
725
736
|
return this.#popplerPath;
|
|
@@ -734,7 +745,7 @@ class Poppler {
|
|
|
734
745
|
async #getVersion(binary) {
|
|
735
746
|
if (!this.#binVersions.has(binary)) {
|
|
736
747
|
const { stderr } = await execFileAsync(binary, ["-v"]);
|
|
737
|
-
// @ts-
|
|
748
|
+
// @ts-expect-error: parseOptions checks if falsy
|
|
738
749
|
const version = POPPLER_VERSION_REG.exec(stderr)[1];
|
|
739
750
|
this.#binVersions.set(binary, version);
|
|
740
751
|
}
|
|
@@ -1230,7 +1241,7 @@ class Poppler {
|
|
|
1230
1241
|
* @param {string} file - Filepath of the PDF file to read.
|
|
1231
1242
|
* @param {string} fileToAttach - Filepath of the attachment to be embedded into the PDF file.
|
|
1232
1243
|
* @param {string} outputFile - Filepath of the file to output the results to.
|
|
1233
|
-
* @param {PdfAttachOptions} [options] - Options to pass to pdfattach binary.
|
|
1244
|
+
* @param {PdfAttachOptions} [options] - Options to pass to the pdfattach binary.
|
|
1234
1245
|
* @param {PopplerExtraOptions} [extras] - Extra options.
|
|
1235
1246
|
* @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
|
|
1236
1247
|
*/
|
|
@@ -1247,7 +1258,7 @@ class Poppler {
|
|
|
1247
1258
|
* @author Frazer Smith
|
|
1248
1259
|
* @description Lists or extracts embedded files (attachments) from a PDF file.
|
|
1249
1260
|
* @param {string} file - Filepath of the PDF file to read.
|
|
1250
|
-
* @param {PdfDetachOptions} [options] - Options to pass to pdfdetach binary.
|
|
1261
|
+
* @param {PdfDetachOptions} [options] - Options to pass to the pdfdetach binary.
|
|
1251
1262
|
* @param {PopplerExtraOptions} [extras] - Extra options.
|
|
1252
1263
|
* @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
|
|
1253
1264
|
*/
|
|
@@ -1267,7 +1278,7 @@ class Poppler {
|
|
|
1267
1278
|
* @author Frazer Smith
|
|
1268
1279
|
* @description Lists the fonts used in a PDF file along with various information for each font.
|
|
1269
1280
|
* @param {(Buffer|string)} file - PDF file as Buffer, or filepath of the PDF file to read.
|
|
1270
|
-
* @param {PdfFontsOptions} [options] - Options to pass to pdffonts binary.
|
|
1281
|
+
* @param {PdfFontsOptions} [options] - Options to pass to the pdffonts binary.
|
|
1271
1282
|
* @param {PopplerExtraOptions} [extras] - Extra options.
|
|
1272
1283
|
* @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
|
|
1273
1284
|
*/
|
|
@@ -1286,7 +1297,7 @@ class Poppler {
|
|
|
1286
1297
|
* @description Saves images from a PDF file as PPM, PBM, PNG, TIFF, JPEG, JPEG2000, or JBIG2 files.
|
|
1287
1298
|
* @param {(Buffer|string)} file - PDF file as Buffer, or filepath of the PDF file to read.
|
|
1288
1299
|
* @param {string} [outputPrefix] - Filename prefix of output files.
|
|
1289
|
-
* @param {PdfImagesOptions} [options] - Options to pass to pdfimages binary.
|
|
1300
|
+
* @param {PdfImagesOptions} [options] - Options to pass to the pdfimages binary.
|
|
1290
1301
|
* @param {PopplerExtraOptions} [extras] - Extra options.
|
|
1291
1302
|
* @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
|
|
1292
1303
|
*/
|
|
@@ -1309,7 +1320,7 @@ class Poppler {
|
|
|
1309
1320
|
* @author Frazer Smith
|
|
1310
1321
|
* @description Prints the contents of the `Info` dictionary from a PDF file.
|
|
1311
1322
|
* @param {(Buffer|string)} file - PDF file as Buffer, or filepath of the PDF file to read.
|
|
1312
|
-
* @param {PdfInfoOptions} [options] - Options to pass to pdfinfo binary.
|
|
1323
|
+
* @param {PdfInfoOptions} [options] - Options to pass to the pdfinfo binary.
|
|
1313
1324
|
* @param {PopplerExtraOptions} [extras] - Extra options.
|
|
1314
1325
|
* @returns {Promise<Record<string, string>|string>} A promise that resolves with a stdout string or JSON object if
|
|
1315
1326
|
* `options.printAsJson` is `true`, or rejects with an `Error` object.
|
|
@@ -1413,7 +1424,7 @@ class Poppler {
|
|
|
1413
1424
|
* @param {string} outputPattern - Should contain %d (or any variant respecting printf format),
|
|
1414
1425
|
* since %d is replaced by the page number.
|
|
1415
1426
|
* As an example, `sample-%d.pdf` will produce `sample-1.pdf` for a single page document.
|
|
1416
|
-
* @param {PdfSeparateOptions} [options] - Options to pass to pdfseparate binary.
|
|
1427
|
+
* @param {PdfSeparateOptions} [options] - Options to pass to the pdfseparate binary.
|
|
1417
1428
|
* @param {PopplerExtraOptions} [extras] - Extra options.
|
|
1418
1429
|
* @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
|
|
1419
1430
|
*/
|
|
@@ -1438,7 +1449,7 @@ class Poppler {
|
|
|
1438
1449
|
* Encoding is set to `binary` if used with `options.singleFile` or `options.pdfFile`.
|
|
1439
1450
|
*
|
|
1440
1451
|
* If not set then the output filename will be derived from the PDF file name.
|
|
1441
|
-
* @param {PdfToCairoOptions} [options] - Options to pass to pdftocairo binary.
|
|
1452
|
+
* @param {PdfToCairoOptions} [options] - Options to pass to the pdftocairo binary.
|
|
1442
1453
|
* @param {PopplerExtraOptions} [extras] - Extra options.
|
|
1443
1454
|
* @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
|
|
1444
1455
|
*/
|
|
@@ -1468,7 +1479,7 @@ class Poppler {
|
|
|
1468
1479
|
* and create a new file, with `-html` appended to the end of the filename.
|
|
1469
1480
|
*
|
|
1470
1481
|
* Required if `file` is a Buffer.
|
|
1471
|
-
* @param {PdfToHtmlOptions} [options] - Options to pass to pdftohtml binary.
|
|
1482
|
+
* @param {PdfToHtmlOptions} [options] - Options to pass to the pdftohtml binary.
|
|
1472
1483
|
* @param {PopplerExtraOptions} [extras] - Extra options.
|
|
1473
1484
|
* @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
|
|
1474
1485
|
*/
|
|
@@ -1496,7 +1507,7 @@ class Poppler {
|
|
|
1496
1507
|
* in Portable Bitmap (PBM) format.
|
|
1497
1508
|
* @param {(Buffer|string)} file - PDF file as Buffer, or filepath of the PDF file to read.
|
|
1498
1509
|
* @param {string} outputPath - Filepath to output the results to.
|
|
1499
|
-
* @param {PdfToPpmOptions} [options] - Options to pass to pdftoppm binary.
|
|
1510
|
+
* @param {PdfToPpmOptions} [options] - Options to pass to the pdftoppm binary.
|
|
1500
1511
|
* @param {PopplerExtraOptions} [extras] - Extra options.
|
|
1501
1512
|
* @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
|
|
1502
1513
|
*/
|
|
@@ -1516,7 +1527,7 @@ class Poppler {
|
|
|
1516
1527
|
* @param {(Buffer|string)} file - PDF file as Buffer, or filepath of the PDF file to read.
|
|
1517
1528
|
* @param {string} [outputFile] - Filepath of the file to output the results to.
|
|
1518
1529
|
* If `undefined` then will write output to stdout.
|
|
1519
|
-
* @param {PdfToPsOptions} [options] - Options to pass to pdftops binary.
|
|
1530
|
+
* @param {PdfToPsOptions} [options] - Options to pass to the pdftops binary.
|
|
1520
1531
|
* @param {PopplerExtraOptions} [extras] - Extra options.
|
|
1521
1532
|
* @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
|
|
1522
1533
|
*/
|
|
@@ -1536,7 +1547,7 @@ class Poppler {
|
|
|
1536
1547
|
* @param {(Buffer|string)} file - PDF file as Buffer, or filepath of the PDF file to read.
|
|
1537
1548
|
* @param {string} [outputFile] - Filepath of the file to output the results to.
|
|
1538
1549
|
* If `undefined` then will write output to stdout.
|
|
1539
|
-
* @param {PdfToTextOptions} [options] - Options to pass to pdftotext binary.
|
|
1550
|
+
* @param {PdfToTextOptions} [options] - Options to pass to the pdftotext binary.
|
|
1540
1551
|
* @param {PopplerExtraOptions} [extras] - Extra options.
|
|
1541
1552
|
* @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
|
|
1542
1553
|
*/
|
|
@@ -1560,7 +1571,7 @@ class Poppler {
|
|
|
1560
1571
|
* @param {string[]} files - Filepaths of the PDF files to merge.
|
|
1561
1572
|
* An entire directory of PDF files can be merged like so: `path/to/directory/*.pdf`.
|
|
1562
1573
|
* @param {string} outputFile - Filepath of the file to output the resulting merged PDF to.
|
|
1563
|
-
* @param {PdfUniteOptions} [options] - Options to pass to pdfunite binary.
|
|
1574
|
+
* @param {PdfUniteOptions} [options] - Options to pass to the pdfunite binary.
|
|
1564
1575
|
* @param {PopplerExtraOptions} [extras] - Extra options.
|
|
1565
1576
|
* @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
|
|
1566
1577
|
*/
|
package/types/index.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export type OptionDetails = {
|
|
|
13
13
|
*/
|
|
14
14
|
minVersion?: string | undefined;
|
|
15
15
|
/**
|
|
16
|
-
* The maximum version of the binary that supports this option
|
|
16
|
+
* The maximum version of the binary that supports this option.
|
|
17
17
|
*/
|
|
18
18
|
maxVersion?: string | undefined;
|
|
19
19
|
};
|
|
@@ -1114,6 +1114,7 @@ export type PdfUniteOptions = {
|
|
|
1114
1114
|
*/
|
|
1115
1115
|
printVersionInfo?: boolean | undefined;
|
|
1116
1116
|
};
|
|
1117
|
+
export type PopplerOptions = (PdfAttachOptions | PdfDetachOptions | PdfFontsOptions | PdfImagesOptions | PdfInfoOptions | PdfSeparateOptions | PdfToCairoOptions | PdfToHtmlOptions | PdfToPpmOptions | PdfToPsOptions | PdfToTextOptions | PdfUniteOptions);
|
|
1117
1118
|
export type PopplerExtraOptions = {
|
|
1118
1119
|
/**
|
|
1119
1120
|
* An `AbortSignal` that can be used to cancel the operation.
|
|
@@ -1122,17 +1123,17 @@ export type PopplerExtraOptions = {
|
|
|
1122
1123
|
};
|
|
1123
1124
|
export class Poppler {
|
|
1124
1125
|
/**
|
|
1125
|
-
* @param {string} [binPath] - Path
|
|
1126
|
+
* @param {string} [binPath] - Path to the directory containing the poppler-utils binaries.
|
|
1126
1127
|
* If not provided, the constructor will attempt to find the Poppler `pdfinfo` binary
|
|
1127
1128
|
* in the PATH environment variable and use that as the path for all binaries.
|
|
1128
1129
|
* For `win32` the binaries are bundled with the package and will be used
|
|
1129
|
-
* if
|
|
1130
|
+
* if local binaries cannot be found.
|
|
1130
1131
|
* @throws {Error} If the Poppler binaries cannot be found.
|
|
1131
1132
|
*/
|
|
1132
1133
|
constructor(binPath?: string);
|
|
1133
1134
|
/**
|
|
1134
1135
|
* @description Returns the path of the Poppler binaries.
|
|
1135
|
-
* @returns {string} Path of Poppler binaries.
|
|
1136
|
+
* @returns {string} Path of the Poppler binaries' directory.
|
|
1136
1137
|
*/
|
|
1137
1138
|
get path(): string;
|
|
1138
1139
|
/**
|
|
@@ -1141,7 +1142,7 @@ export class Poppler {
|
|
|
1141
1142
|
* @param {string} file - Filepath of the PDF file to read.
|
|
1142
1143
|
* @param {string} fileToAttach - Filepath of the attachment to be embedded into the PDF file.
|
|
1143
1144
|
* @param {string} outputFile - Filepath of the file to output the results to.
|
|
1144
|
-
* @param {PdfAttachOptions} [options] - Options to pass to pdfattach binary.
|
|
1145
|
+
* @param {PdfAttachOptions} [options] - Options to pass to the pdfattach binary.
|
|
1145
1146
|
* @param {PopplerExtraOptions} [extras] - Extra options.
|
|
1146
1147
|
* @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
|
|
1147
1148
|
*/
|
|
@@ -1150,7 +1151,7 @@ export class Poppler {
|
|
|
1150
1151
|
* @author Frazer Smith
|
|
1151
1152
|
* @description Lists or extracts embedded files (attachments) from a PDF file.
|
|
1152
1153
|
* @param {string} file - Filepath of the PDF file to read.
|
|
1153
|
-
* @param {PdfDetachOptions} [options] - Options to pass to pdfdetach binary.
|
|
1154
|
+
* @param {PdfDetachOptions} [options] - Options to pass to the pdfdetach binary.
|
|
1154
1155
|
* @param {PopplerExtraOptions} [extras] - Extra options.
|
|
1155
1156
|
* @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
|
|
1156
1157
|
*/
|
|
@@ -1159,7 +1160,7 @@ export class Poppler {
|
|
|
1159
1160
|
* @author Frazer Smith
|
|
1160
1161
|
* @description Lists the fonts used in a PDF file along with various information for each font.
|
|
1161
1162
|
* @param {(Buffer|string)} file - PDF file as Buffer, or filepath of the PDF file to read.
|
|
1162
|
-
* @param {PdfFontsOptions} [options] - Options to pass to pdffonts binary.
|
|
1163
|
+
* @param {PdfFontsOptions} [options] - Options to pass to the pdffonts binary.
|
|
1163
1164
|
* @param {PopplerExtraOptions} [extras] - Extra options.
|
|
1164
1165
|
* @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
|
|
1165
1166
|
*/
|
|
@@ -1169,7 +1170,7 @@ export class Poppler {
|
|
|
1169
1170
|
* @description Saves images from a PDF file as PPM, PBM, PNG, TIFF, JPEG, JPEG2000, or JBIG2 files.
|
|
1170
1171
|
* @param {(Buffer|string)} file - PDF file as Buffer, or filepath of the PDF file to read.
|
|
1171
1172
|
* @param {string} [outputPrefix] - Filename prefix of output files.
|
|
1172
|
-
* @param {PdfImagesOptions} [options] - Options to pass to pdfimages binary.
|
|
1173
|
+
* @param {PdfImagesOptions} [options] - Options to pass to the pdfimages binary.
|
|
1173
1174
|
* @param {PopplerExtraOptions} [extras] - Extra options.
|
|
1174
1175
|
* @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
|
|
1175
1176
|
*/
|
|
@@ -1178,7 +1179,7 @@ export class Poppler {
|
|
|
1178
1179
|
* @author Frazer Smith
|
|
1179
1180
|
* @description Prints the contents of the `Info` dictionary from a PDF file.
|
|
1180
1181
|
* @param {(Buffer|string)} file - PDF file as Buffer, or filepath of the PDF file to read.
|
|
1181
|
-
* @param {PdfInfoOptions} [options] - Options to pass to pdfinfo binary.
|
|
1182
|
+
* @param {PdfInfoOptions} [options] - Options to pass to the pdfinfo binary.
|
|
1182
1183
|
* @param {PopplerExtraOptions} [extras] - Extra options.
|
|
1183
1184
|
* @returns {Promise<Record<string, string>|string>} A promise that resolves with a stdout string or JSON object if
|
|
1184
1185
|
* `options.printAsJson` is `true`, or rejects with an `Error` object.
|
|
@@ -1193,7 +1194,7 @@ export class Poppler {
|
|
|
1193
1194
|
* @param {string} outputPattern - Should contain %d (or any variant respecting printf format),
|
|
1194
1195
|
* since %d is replaced by the page number.
|
|
1195
1196
|
* As an example, `sample-%d.pdf` will produce `sample-1.pdf` for a single page document.
|
|
1196
|
-
* @param {PdfSeparateOptions} [options] - Options to pass to pdfseparate binary.
|
|
1197
|
+
* @param {PdfSeparateOptions} [options] - Options to pass to the pdfseparate binary.
|
|
1197
1198
|
* @param {PopplerExtraOptions} [extras] - Extra options.
|
|
1198
1199
|
* @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
|
|
1199
1200
|
*/
|
|
@@ -1209,7 +1210,7 @@ export class Poppler {
|
|
|
1209
1210
|
* Encoding is set to `binary` if used with `options.singleFile` or `options.pdfFile`.
|
|
1210
1211
|
*
|
|
1211
1212
|
* If not set then the output filename will be derived from the PDF file name.
|
|
1212
|
-
* @param {PdfToCairoOptions} [options] - Options to pass to pdftocairo binary.
|
|
1213
|
+
* @param {PdfToCairoOptions} [options] - Options to pass to the pdftocairo binary.
|
|
1213
1214
|
* @param {PopplerExtraOptions} [extras] - Extra options.
|
|
1214
1215
|
* @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
|
|
1215
1216
|
*/
|
|
@@ -1223,7 +1224,7 @@ export class Poppler {
|
|
|
1223
1224
|
* and create a new file, with `-html` appended to the end of the filename.
|
|
1224
1225
|
*
|
|
1225
1226
|
* Required if `file` is a Buffer.
|
|
1226
|
-
* @param {PdfToHtmlOptions} [options] - Options to pass to pdftohtml binary.
|
|
1227
|
+
* @param {PdfToHtmlOptions} [options] - Options to pass to the pdftohtml binary.
|
|
1227
1228
|
* @param {PopplerExtraOptions} [extras] - Extra options.
|
|
1228
1229
|
* @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
|
|
1229
1230
|
*/
|
|
@@ -1235,7 +1236,7 @@ export class Poppler {
|
|
|
1235
1236
|
* in Portable Bitmap (PBM) format.
|
|
1236
1237
|
* @param {(Buffer|string)} file - PDF file as Buffer, or filepath of the PDF file to read.
|
|
1237
1238
|
* @param {string} outputPath - Filepath to output the results to.
|
|
1238
|
-
* @param {PdfToPpmOptions} [options] - Options to pass to pdftoppm binary.
|
|
1239
|
+
* @param {PdfToPpmOptions} [options] - Options to pass to the pdftoppm binary.
|
|
1239
1240
|
* @param {PopplerExtraOptions} [extras] - Extra options.
|
|
1240
1241
|
* @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
|
|
1241
1242
|
*/
|
|
@@ -1246,7 +1247,7 @@ export class Poppler {
|
|
|
1246
1247
|
* @param {(Buffer|string)} file - PDF file as Buffer, or filepath of the PDF file to read.
|
|
1247
1248
|
* @param {string} [outputFile] - Filepath of the file to output the results to.
|
|
1248
1249
|
* If `undefined` then will write output to stdout.
|
|
1249
|
-
* @param {PdfToPsOptions} [options] - Options to pass to pdftops binary.
|
|
1250
|
+
* @param {PdfToPsOptions} [options] - Options to pass to the pdftops binary.
|
|
1250
1251
|
* @param {PopplerExtraOptions} [extras] - Extra options.
|
|
1251
1252
|
* @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
|
|
1252
1253
|
*/
|
|
@@ -1257,7 +1258,7 @@ export class Poppler {
|
|
|
1257
1258
|
* @param {(Buffer|string)} file - PDF file as Buffer, or filepath of the PDF file to read.
|
|
1258
1259
|
* @param {string} [outputFile] - Filepath of the file to output the results to.
|
|
1259
1260
|
* If `undefined` then will write output to stdout.
|
|
1260
|
-
* @param {PdfToTextOptions} [options] - Options to pass to pdftotext binary.
|
|
1261
|
+
* @param {PdfToTextOptions} [options] - Options to pass to the pdftotext binary.
|
|
1261
1262
|
* @param {PopplerExtraOptions} [extras] - Extra options.
|
|
1262
1263
|
* @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
|
|
1263
1264
|
*/
|
|
@@ -1269,7 +1270,7 @@ export class Poppler {
|
|
|
1269
1270
|
* @param {string[]} files - Filepaths of the PDF files to merge.
|
|
1270
1271
|
* An entire directory of PDF files can be merged like so: `path/to/directory/*.pdf`.
|
|
1271
1272
|
* @param {string} outputFile - Filepath of the file to output the resulting merged PDF to.
|
|
1272
|
-
* @param {PdfUniteOptions} [options] - Options to pass to pdfunite binary.
|
|
1273
|
+
* @param {PdfUniteOptions} [options] - Options to pass to the pdfunite binary.
|
|
1273
1274
|
* @param {PopplerExtraOptions} [extras] - Extra options.
|
|
1274
1275
|
* @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
|
|
1275
1276
|
*/
|