node-poppler 6.2.7 → 7.0.1
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 +31 -13
- package/package.json +3 -2
- package/src/index.js +129 -54
- package/types/index.d.ts +264 -314
package/README.md
CHANGED
|
@@ -81,7 +81,7 @@ Example of an `async` `await` call to `poppler.pdfToCairo()`, to convert only th
|
|
|
81
81
|
PDF file using stdout:
|
|
82
82
|
|
|
83
83
|
```js
|
|
84
|
-
const
|
|
84
|
+
const { writeFile } = require("node:fs/promises");
|
|
85
85
|
const { Poppler } = require("node-poppler");
|
|
86
86
|
|
|
87
87
|
const file = "test_document.pdf";
|
|
@@ -93,7 +93,7 @@ const options = {
|
|
|
93
93
|
|
|
94
94
|
const res = await poppler.pdfToCairo(file, undefined, options);
|
|
95
95
|
// pdfToCairo writes to stdout using binary encoding if pdfFile or singleFile options are used
|
|
96
|
-
await
|
|
96
|
+
await writeFile("new_file.pdf", res, { encoding: "binary" });
|
|
97
97
|
```
|
|
98
98
|
|
|
99
99
|
### poppler.pdfToHtml
|
|
@@ -110,27 +110,39 @@ const options = {
|
|
|
110
110
|
lastPageToConvert: 2,
|
|
111
111
|
};
|
|
112
112
|
|
|
113
|
-
poppler
|
|
114
|
-
|
|
115
|
-
|
|
113
|
+
poppler
|
|
114
|
+
.pdfToHtml(file, undefined, options)
|
|
115
|
+
.then((res) => {
|
|
116
|
+
console.log(res);
|
|
117
|
+
})
|
|
118
|
+
.catch((err) => {
|
|
119
|
+
console.error(err);
|
|
120
|
+
throw err;
|
|
121
|
+
});
|
|
116
122
|
```
|
|
117
123
|
|
|
118
124
|
Example of calling `poppler.pdfToHtml()` with a promise chain, providing a Buffer as an input:
|
|
119
125
|
|
|
120
126
|
```js
|
|
121
|
-
const
|
|
127
|
+
const { readFileSync } = require("node:fs");
|
|
122
128
|
const { Poppler } = require("node-poppler");
|
|
123
129
|
|
|
124
|
-
const file =
|
|
130
|
+
const file = readFileSync("test_document.pdf");
|
|
125
131
|
const poppler = new Poppler();
|
|
126
132
|
const options = {
|
|
127
133
|
firstPageToConvert: 1,
|
|
128
134
|
lastPageToConvert: 2,
|
|
129
135
|
};
|
|
130
136
|
|
|
131
|
-
poppler
|
|
132
|
-
|
|
133
|
-
|
|
137
|
+
poppler
|
|
138
|
+
.pdfToHtml(file, "tester.html", options)
|
|
139
|
+
.then((res) => {
|
|
140
|
+
console.log(res);
|
|
141
|
+
})
|
|
142
|
+
.catch((err) => {
|
|
143
|
+
console.error(err);
|
|
144
|
+
throw err;
|
|
145
|
+
});
|
|
134
146
|
```
|
|
135
147
|
|
|
136
148
|
### poppler.pdfToText
|
|
@@ -147,9 +159,15 @@ const options = {
|
|
|
147
159
|
lastPageToConvert: 2,
|
|
148
160
|
};
|
|
149
161
|
|
|
150
|
-
poppler
|
|
151
|
-
|
|
152
|
-
|
|
162
|
+
poppler
|
|
163
|
+
.pdfToText(file, options)
|
|
164
|
+
.then((res) => {
|
|
165
|
+
console.log(res);
|
|
166
|
+
})
|
|
167
|
+
.catch((err) => {
|
|
168
|
+
console.error(err);
|
|
169
|
+
throw err;
|
|
170
|
+
});
|
|
153
171
|
```
|
|
154
172
|
|
|
155
173
|
## Contributing
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-poppler",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.1",
|
|
4
4
|
"description": "Asynchronous node.js wrapper for the Poppler PDF rendering library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"async",
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
"unite"
|
|
34
34
|
],
|
|
35
35
|
"main": "src/index.js",
|
|
36
|
+
"type": "commonjs",
|
|
36
37
|
"types": "types/index.d.ts",
|
|
37
38
|
"repository": "git+https://github.com/Fdawgs/node-poppler.git",
|
|
38
39
|
"homepage": "https://github.com/Fdawgs/node-poppler",
|
|
@@ -43,7 +44,7 @@
|
|
|
43
44
|
"author": "Frazer Smith <frazer.dev@outlook.com>",
|
|
44
45
|
"funding": "https://github.com/sponsors/Fdawgs",
|
|
45
46
|
"engines": {
|
|
46
|
-
"node": ">=
|
|
47
|
+
"node": ">=18.0.0"
|
|
47
48
|
},
|
|
48
49
|
"dependencies": {
|
|
49
50
|
"camelcase": "^6.3.0",
|
package/src/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
const { execFile, spawn } = require("child_process");
|
|
4
|
-
const { promisify } = require("util");
|
|
3
|
+
const { execFile, spawn } = require("node:child_process");
|
|
4
|
+
const { promisify } = require("node:util");
|
|
5
5
|
const camelCase = require("camelcase");
|
|
6
6
|
const { lt } = require("semver");
|
|
7
|
-
const
|
|
7
|
+
const { joinSafe, normalizeTrim } = require("upath");
|
|
8
8
|
|
|
9
9
|
const execFileAsync = promisify(execFile);
|
|
10
10
|
|
|
@@ -23,24 +23,28 @@ const errorMessages = {
|
|
|
23
23
|
* @description Checks each option provided is valid, of the correct type, and can be used by specified
|
|
24
24
|
* version of binary.
|
|
25
25
|
* @ignore
|
|
26
|
-
* @param {object} acceptedOptions - Object containing options
|
|
26
|
+
* @param {object} acceptedOptions - Object containing accepted options.
|
|
27
27
|
* @param {object} options - Object containing options to pass to binary.
|
|
28
28
|
* @param {string} [version] - Version of binary.
|
|
29
29
|
* @returns {string[]} Array of CLI arguments.
|
|
30
30
|
* @throws If invalid arguments provided.
|
|
31
31
|
*/
|
|
32
32
|
function parseOptions(acceptedOptions, options, version) {
|
|
33
|
+
/** @type {string[]} */
|
|
33
34
|
const args = [];
|
|
35
|
+
/** @type {string[]} */
|
|
34
36
|
const invalidArgs = [];
|
|
35
37
|
Object.keys(options).forEach((key) => {
|
|
36
|
-
if (Object.
|
|
38
|
+
if (Object.hasOwn(acceptedOptions, key)) {
|
|
37
39
|
// eslint-disable-next-line valid-typeof
|
|
38
40
|
if (typeof options[key] === acceptedOptions[key].type) {
|
|
39
41
|
// Skip boolean options if false
|
|
42
|
+
|
|
40
43
|
if (acceptedOptions[key].type === "boolean" && !options[key]) {
|
|
41
44
|
return;
|
|
42
45
|
}
|
|
43
46
|
// Arg will be empty for some non-standard options
|
|
47
|
+
|
|
44
48
|
if (acceptedOptions[key].arg !== "") {
|
|
45
49
|
args.push(acceptedOptions[key].arg);
|
|
46
50
|
}
|
|
@@ -59,6 +63,7 @@ function parseOptions(acceptedOptions, options, version) {
|
|
|
59
63
|
if (
|
|
60
64
|
acceptedOptions[key].minVersion &&
|
|
61
65
|
version &&
|
|
66
|
+
// @ts-ignore: type checking is done above
|
|
62
67
|
lt(version, acceptedOptions[key].minVersion, { loose: true })
|
|
63
68
|
) {
|
|
64
69
|
invalidArgs.push(
|
|
@@ -76,14 +81,12 @@ function parseOptions(acceptedOptions, options, version) {
|
|
|
76
81
|
}
|
|
77
82
|
|
|
78
83
|
class Poppler {
|
|
79
|
-
/**
|
|
80
|
-
* @param {string} [binPath] - Path of poppler-utils binaries.
|
|
81
|
-
*/
|
|
84
|
+
/** @param {string} [binPath] - Path of poppler-utils binaries. */
|
|
82
85
|
constructor(binPath) {
|
|
83
86
|
if (binPath) {
|
|
84
|
-
this.popplerPath =
|
|
87
|
+
this.popplerPath = normalizeTrim(binPath);
|
|
85
88
|
} else if (process.platform === "win32") {
|
|
86
|
-
this.popplerPath =
|
|
89
|
+
this.popplerPath = joinSafe(
|
|
87
90
|
__dirname,
|
|
88
91
|
"lib",
|
|
89
92
|
"win32",
|
|
@@ -122,7 +125,7 @@ class Poppler {
|
|
|
122
125
|
args.push(outputFile);
|
|
123
126
|
|
|
124
127
|
const { stdout } = await execFileAsync(
|
|
125
|
-
|
|
128
|
+
joinSafe(this.popplerPath, "pdfattach"),
|
|
126
129
|
args
|
|
127
130
|
);
|
|
128
131
|
return Promise.resolve(stdout);
|
|
@@ -179,7 +182,7 @@ class Poppler {
|
|
|
179
182
|
args.push(file);
|
|
180
183
|
|
|
181
184
|
const { stdout } = await execFileAsync(
|
|
182
|
-
|
|
185
|
+
joinSafe(this.popplerPath, "pdfdetach"),
|
|
183
186
|
args
|
|
184
187
|
);
|
|
185
188
|
return Promise.resolve(stdout);
|
|
@@ -214,10 +217,11 @@ class Poppler {
|
|
|
214
217
|
|
|
215
218
|
try {
|
|
216
219
|
const { stderr } = await execFileAsync(
|
|
217
|
-
|
|
220
|
+
joinSafe(this.popplerPath, "pdffonts"),
|
|
218
221
|
["-v"]
|
|
219
222
|
);
|
|
220
223
|
|
|
224
|
+
// @ts-ignore: parseOptions checks if falsy
|
|
221
225
|
const versionInfo = /(\d{1,2}\.\d{1,2}\.\d{1,2})/u.exec(stderr)[1];
|
|
222
226
|
|
|
223
227
|
const args = parseOptions(acceptedOptions, options, versionInfo);
|
|
@@ -230,7 +234,7 @@ class Poppler {
|
|
|
230
234
|
}
|
|
231
235
|
|
|
232
236
|
const child = spawn(
|
|
233
|
-
|
|
237
|
+
joinSafe(this.popplerPath, "pdffonts"),
|
|
234
238
|
args
|
|
235
239
|
);
|
|
236
240
|
|
|
@@ -250,11 +254,23 @@ class Poppler {
|
|
|
250
254
|
stdErr += data;
|
|
251
255
|
});
|
|
252
256
|
|
|
253
|
-
child.on("close", () => {
|
|
257
|
+
child.on("close", (code) => {
|
|
258
|
+
/* istanbul ignore else */
|
|
254
259
|
if (stdOut !== "") {
|
|
255
260
|
resolve(stdOut.trim());
|
|
261
|
+
} else if (code === 0) {
|
|
262
|
+
resolve(errorMessages[code]);
|
|
263
|
+
} else if (stdErr !== "") {
|
|
264
|
+
reject(new Error(stdErr.trim()));
|
|
256
265
|
} else {
|
|
257
|
-
reject(
|
|
266
|
+
reject(
|
|
267
|
+
new Error(
|
|
268
|
+
errorMessages[code] ||
|
|
269
|
+
`pdffonts ${args.join(
|
|
270
|
+
" "
|
|
271
|
+
)} exited with code ${code}`
|
|
272
|
+
)
|
|
273
|
+
);
|
|
258
274
|
}
|
|
259
275
|
});
|
|
260
276
|
});
|
|
@@ -306,10 +322,11 @@ class Poppler {
|
|
|
306
322
|
|
|
307
323
|
try {
|
|
308
324
|
const { stderr } = await execFileAsync(
|
|
309
|
-
|
|
325
|
+
joinSafe(this.popplerPath, "pdfimages"),
|
|
310
326
|
["-v"]
|
|
311
327
|
);
|
|
312
328
|
|
|
329
|
+
// @ts-ignore: parseOptions checks if falsy
|
|
313
330
|
const versionInfo = /(\d{1,2}\.\d{1,2}\.\d{1,2})/u.exec(stderr)[1];
|
|
314
331
|
|
|
315
332
|
const args = parseOptions(acceptedOptions, options, versionInfo);
|
|
@@ -326,7 +343,7 @@ class Poppler {
|
|
|
326
343
|
}
|
|
327
344
|
|
|
328
345
|
const child = spawn(
|
|
329
|
-
|
|
346
|
+
joinSafe(this.popplerPath, "pdfimages"),
|
|
330
347
|
args
|
|
331
348
|
);
|
|
332
349
|
|
|
@@ -347,6 +364,7 @@ class Poppler {
|
|
|
347
364
|
});
|
|
348
365
|
|
|
349
366
|
child.on("close", (code) => {
|
|
367
|
+
/* istanbul ignore else */
|
|
350
368
|
if (stdOut !== "") {
|
|
351
369
|
resolve(stdOut.trim());
|
|
352
370
|
} else if (code === 0) {
|
|
@@ -354,8 +372,14 @@ class Poppler {
|
|
|
354
372
|
} else if (stdErr !== "") {
|
|
355
373
|
reject(new Error(stdErr.trim()));
|
|
356
374
|
} else {
|
|
357
|
-
|
|
358
|
-
|
|
375
|
+
reject(
|
|
376
|
+
new Error(
|
|
377
|
+
errorMessages[code] ||
|
|
378
|
+
`pdfimages ${args.join(
|
|
379
|
+
" "
|
|
380
|
+
)} exited with code ${code}`
|
|
381
|
+
)
|
|
382
|
+
);
|
|
359
383
|
}
|
|
360
384
|
});
|
|
361
385
|
});
|
|
@@ -396,7 +420,8 @@ class Poppler {
|
|
|
396
420
|
* such as Link Annotations are listed, not URL strings in the text content.
|
|
397
421
|
* @param {boolean} [options.printVersionInfo] - Print copyright and version info.
|
|
398
422
|
* @param {string} [options.userPassword] - User password (for encrypted files).
|
|
399
|
-
* @returns {Promise<string>} A promise that resolves with a stdout string
|
|
423
|
+
* @returns {Promise<object|string>} A promise that resolves with a stdout string or JSON object if
|
|
424
|
+
* `options.printAsJson` is `true`, or rejects with an `Error` object.
|
|
400
425
|
*/
|
|
401
426
|
async pdfInfo(file, options = {}) {
|
|
402
427
|
const acceptedOptions = {
|
|
@@ -421,10 +446,11 @@ class Poppler {
|
|
|
421
446
|
|
|
422
447
|
try {
|
|
423
448
|
const { stderr } = await execFileAsync(
|
|
424
|
-
|
|
449
|
+
joinSafe(this.popplerPath, "pdfinfo"),
|
|
425
450
|
["-v"]
|
|
426
451
|
);
|
|
427
452
|
|
|
453
|
+
// @ts-ignore: parseOptions checks if falsy
|
|
428
454
|
const versionInfo = /(\d{1,2}\.\d{1,2}\.\d{1,2})/u.exec(stderr)[1];
|
|
429
455
|
|
|
430
456
|
const args = parseOptions(acceptedOptions, options, versionInfo);
|
|
@@ -433,6 +459,7 @@ class Poppler {
|
|
|
433
459
|
* Poppler does not set the "File size" metadata value if passed
|
|
434
460
|
* a Buffer via stdin, so need to retrieve it from the Buffer
|
|
435
461
|
*/
|
|
462
|
+
/** @type {number} */
|
|
436
463
|
let fileSize;
|
|
437
464
|
|
|
438
465
|
return new Promise((resolve, reject) => {
|
|
@@ -443,8 +470,8 @@ class Poppler {
|
|
|
443
470
|
args.push(file);
|
|
444
471
|
}
|
|
445
472
|
|
|
446
|
-
const child =
|
|
447
|
-
|
|
473
|
+
const child = spawn(
|
|
474
|
+
joinSafe(this.popplerPath, "pdfinfo"),
|
|
448
475
|
args
|
|
449
476
|
);
|
|
450
477
|
|
|
@@ -464,7 +491,8 @@ class Poppler {
|
|
|
464
491
|
stdErr += data;
|
|
465
492
|
});
|
|
466
493
|
|
|
467
|
-
child.on("close", () => {
|
|
494
|
+
child.on("close", (code) => {
|
|
495
|
+
/* istanbul ignore else */
|
|
468
496
|
if (stdOut !== "") {
|
|
469
497
|
if (fileSize) {
|
|
470
498
|
stdOut = stdOut.replace(
|
|
@@ -473,15 +501,16 @@ class Poppler {
|
|
|
473
501
|
);
|
|
474
502
|
}
|
|
475
503
|
|
|
504
|
+
/**
|
|
505
|
+
* Convert output to JSON.
|
|
506
|
+
* @see {@link https://github.com/Fdawgs/node-poppler/issues/248#issuecomment-845948080 | Node-Poppler Issue #248}
|
|
507
|
+
*/
|
|
476
508
|
if (options.printAsJson === true) {
|
|
477
|
-
/**
|
|
478
|
-
* Thanks to @sainf for this solution
|
|
479
|
-
* https://github.com/Fdawgs/node-poppler/issues/248#issuecomment-845948080
|
|
480
|
-
*/
|
|
481
509
|
const info = {};
|
|
482
510
|
stdOut.split("\n").forEach((line) => {
|
|
483
511
|
const lines = line.split(": ");
|
|
484
512
|
if (lines.length > 1) {
|
|
513
|
+
// @ts-ignore: creating dynamic object keys
|
|
485
514
|
info[camelCase(lines[0])] = lines[1].trim();
|
|
486
515
|
}
|
|
487
516
|
});
|
|
@@ -489,8 +518,19 @@ class Poppler {
|
|
|
489
518
|
} else {
|
|
490
519
|
resolve(stdOut.trim());
|
|
491
520
|
}
|
|
521
|
+
} else if (code === 0) {
|
|
522
|
+
resolve(errorMessages[code]);
|
|
523
|
+
} else if (stdErr !== "") {
|
|
524
|
+
reject(new Error(stdErr.trim()));
|
|
492
525
|
} else {
|
|
493
|
-
reject(
|
|
526
|
+
reject(
|
|
527
|
+
new Error(
|
|
528
|
+
errorMessages[code] ||
|
|
529
|
+
`pdfinfo ${args.join(
|
|
530
|
+
" "
|
|
531
|
+
)} exited with code ${code}`
|
|
532
|
+
)
|
|
533
|
+
);
|
|
494
534
|
}
|
|
495
535
|
});
|
|
496
536
|
});
|
|
@@ -525,10 +565,11 @@ class Poppler {
|
|
|
525
565
|
|
|
526
566
|
try {
|
|
527
567
|
const { stderr } = await execFileAsync(
|
|
528
|
-
|
|
568
|
+
joinSafe(this.popplerPath, "pdfseparate"),
|
|
529
569
|
["-v"]
|
|
530
570
|
);
|
|
531
571
|
|
|
572
|
+
// @ts-ignore: parseOptions checks if falsy
|
|
532
573
|
const versionInfo = /(\d{1,2}\.\d{1,2}\.\d{1,2})/u.exec(stderr)[1];
|
|
533
574
|
|
|
534
575
|
const args = parseOptions(acceptedOptions, options, versionInfo);
|
|
@@ -536,7 +577,7 @@ class Poppler {
|
|
|
536
577
|
args.push(outputPattern);
|
|
537
578
|
|
|
538
579
|
const { stdout } = await execFileAsync(
|
|
539
|
-
|
|
580
|
+
joinSafe(this.popplerPath, "pdfseparate"),
|
|
540
581
|
args
|
|
541
582
|
);
|
|
542
583
|
return Promise.resolve(stdout);
|
|
@@ -702,10 +743,11 @@ class Poppler {
|
|
|
702
743
|
|
|
703
744
|
try {
|
|
704
745
|
const { stderr } = await execFileAsync(
|
|
705
|
-
|
|
746
|
+
joinSafe(this.popplerPath, "pdftocairo"),
|
|
706
747
|
["-v"]
|
|
707
748
|
);
|
|
708
749
|
|
|
750
|
+
// @ts-ignore: parseOptions checks if falsy
|
|
709
751
|
const versionInfo = /(\d{1,2}\.\d{1,2}\.\d{1,2})/u.exec(stderr)[1];
|
|
710
752
|
|
|
711
753
|
const args = parseOptions(acceptedOptions, options, versionInfo);
|
|
@@ -724,7 +766,7 @@ class Poppler {
|
|
|
724
766
|
}
|
|
725
767
|
|
|
726
768
|
const child = spawn(
|
|
727
|
-
|
|
769
|
+
joinSafe(this.popplerPath, "pdftocairo"),
|
|
728
770
|
args
|
|
729
771
|
);
|
|
730
772
|
|
|
@@ -752,6 +794,7 @@ class Poppler {
|
|
|
752
794
|
});
|
|
753
795
|
|
|
754
796
|
child.on("close", (code) => {
|
|
797
|
+
/* istanbul ignore else */
|
|
755
798
|
if (stdOut !== "") {
|
|
756
799
|
resolve(stdOut.trim());
|
|
757
800
|
} else if (code === 0) {
|
|
@@ -759,8 +802,14 @@ class Poppler {
|
|
|
759
802
|
} else if (stdErr !== "") {
|
|
760
803
|
reject(new Error(stdErr.trim()));
|
|
761
804
|
} else {
|
|
762
|
-
|
|
763
|
-
|
|
805
|
+
reject(
|
|
806
|
+
new Error(
|
|
807
|
+
errorMessages[code] ||
|
|
808
|
+
`pdftocairo ${args.join(
|
|
809
|
+
" "
|
|
810
|
+
)} exited with code ${code}`
|
|
811
|
+
)
|
|
812
|
+
);
|
|
764
813
|
}
|
|
765
814
|
});
|
|
766
815
|
});
|
|
@@ -842,10 +891,11 @@ class Poppler {
|
|
|
842
891
|
|
|
843
892
|
try {
|
|
844
893
|
const { stderr } = await execFileAsync(
|
|
845
|
-
|
|
894
|
+
joinSafe(this.popplerPath, "pdftohtml"),
|
|
846
895
|
["-v"]
|
|
847
896
|
);
|
|
848
897
|
|
|
898
|
+
// @ts-ignore: parseOptions checks if falsy
|
|
849
899
|
const versionInfo = /(\d{1,2}\.\d{1,2}\.\d{1,2})/u.exec(stderr)[1];
|
|
850
900
|
|
|
851
901
|
const args = parseOptions(acceptedOptions, options, versionInfo);
|
|
@@ -862,7 +912,7 @@ class Poppler {
|
|
|
862
912
|
}
|
|
863
913
|
|
|
864
914
|
const child = spawn(
|
|
865
|
-
|
|
915
|
+
joinSafe(this.popplerPath, "pdftohtml"),
|
|
866
916
|
args
|
|
867
917
|
);
|
|
868
918
|
|
|
@@ -884,7 +934,7 @@ class Poppler {
|
|
|
884
934
|
|
|
885
935
|
/**
|
|
886
936
|
* pdfToHtml does not return an exit code so check output to see if it was successful.
|
|
887
|
-
*
|
|
937
|
+
* @see {@link https://gitlab.freedesktop.org/poppler/poppler/-/blob/master/utils/pdftohtml.1 | Poppler pdftohtml man}
|
|
888
938
|
*/
|
|
889
939
|
child.on("close", () => {
|
|
890
940
|
if (stdOut !== "") {
|
|
@@ -1046,10 +1096,11 @@ class Poppler {
|
|
|
1046
1096
|
|
|
1047
1097
|
try {
|
|
1048
1098
|
const { stderr } = await execFileAsync(
|
|
1049
|
-
|
|
1099
|
+
joinSafe(this.popplerPath, "pdftoppm"),
|
|
1050
1100
|
["-v"]
|
|
1051
1101
|
);
|
|
1052
1102
|
|
|
1103
|
+
// @ts-ignore: parseOptions checks if falsy
|
|
1053
1104
|
const versionInfo = /(\d{1,2}\.\d{1,2}\.\d{1,2})/u.exec(stderr)[1];
|
|
1054
1105
|
|
|
1055
1106
|
const args = parseOptions(acceptedOptions, options, versionInfo);
|
|
@@ -1064,7 +1115,7 @@ class Poppler {
|
|
|
1064
1115
|
args.push(outputPath);
|
|
1065
1116
|
|
|
1066
1117
|
const child = spawn(
|
|
1067
|
-
|
|
1118
|
+
joinSafe(this.popplerPath, "pdftoppm"),
|
|
1068
1119
|
args
|
|
1069
1120
|
);
|
|
1070
1121
|
|
|
@@ -1080,13 +1131,20 @@ class Poppler {
|
|
|
1080
1131
|
});
|
|
1081
1132
|
|
|
1082
1133
|
child.on("close", (code) => {
|
|
1134
|
+
/* istanbul ignore else */
|
|
1083
1135
|
if (stdErr !== "") {
|
|
1084
1136
|
reject(new Error(stdErr.trim()));
|
|
1085
1137
|
} else if (code === 0) {
|
|
1086
1138
|
resolve(errorMessages[code]);
|
|
1087
1139
|
} else {
|
|
1088
|
-
|
|
1089
|
-
|
|
1140
|
+
reject(
|
|
1141
|
+
new Error(
|
|
1142
|
+
errorMessages[code] ||
|
|
1143
|
+
`pdftoppm ${args.join(
|
|
1144
|
+
" "
|
|
1145
|
+
)} exited with code ${code}`
|
|
1146
|
+
)
|
|
1147
|
+
);
|
|
1090
1148
|
}
|
|
1091
1149
|
});
|
|
1092
1150
|
});
|
|
@@ -1266,7 +1324,7 @@ class Poppler {
|
|
|
1266
1324
|
processColorFormat: { arg: "-processcolorformat", type: "string" },
|
|
1267
1325
|
quiet: { arg: "-q", type: "boolean" },
|
|
1268
1326
|
rasterize: {
|
|
1269
|
-
|
|
1327
|
+
arg: "-rasterize",
|
|
1270
1328
|
type: "string",
|
|
1271
1329
|
minVersion: "0.90.0",
|
|
1272
1330
|
},
|
|
@@ -1276,10 +1334,11 @@ class Poppler {
|
|
|
1276
1334
|
|
|
1277
1335
|
try {
|
|
1278
1336
|
const { stderr } = await execFileAsync(
|
|
1279
|
-
|
|
1337
|
+
joinSafe(this.popplerPath, "pdftops"),
|
|
1280
1338
|
["-v"]
|
|
1281
1339
|
);
|
|
1282
1340
|
|
|
1341
|
+
// @ts-ignore: parseOptions checks if falsy
|
|
1283
1342
|
const versionInfo = /(\d{1,2}\.\d{1,2}\.\d{1,2})/u.exec(stderr)[1];
|
|
1284
1343
|
|
|
1285
1344
|
const args = parseOptions(acceptedOptions, options, versionInfo);
|
|
@@ -1298,7 +1357,7 @@ class Poppler {
|
|
|
1298
1357
|
}
|
|
1299
1358
|
|
|
1300
1359
|
const child = spawn(
|
|
1301
|
-
|
|
1360
|
+
joinSafe(this.popplerPath, "pdftops"),
|
|
1302
1361
|
args
|
|
1303
1362
|
);
|
|
1304
1363
|
|
|
@@ -1319,6 +1378,7 @@ class Poppler {
|
|
|
1319
1378
|
});
|
|
1320
1379
|
|
|
1321
1380
|
child.on("close", (code) => {
|
|
1381
|
+
/* istanbul ignore else */
|
|
1322
1382
|
if (stdOut !== "") {
|
|
1323
1383
|
resolve(stdOut.trim());
|
|
1324
1384
|
} else if (code === 0) {
|
|
@@ -1326,8 +1386,14 @@ class Poppler {
|
|
|
1326
1386
|
} else if (stdErr !== "") {
|
|
1327
1387
|
reject(new Error(stdErr.trim()));
|
|
1328
1388
|
} else {
|
|
1329
|
-
|
|
1330
|
-
|
|
1389
|
+
reject(
|
|
1390
|
+
new Error(
|
|
1391
|
+
errorMessages[code] ||
|
|
1392
|
+
`pdftops ${args.join(
|
|
1393
|
+
" "
|
|
1394
|
+
)} exited with code ${code}`
|
|
1395
|
+
)
|
|
1396
|
+
);
|
|
1331
1397
|
}
|
|
1332
1398
|
});
|
|
1333
1399
|
});
|
|
@@ -1425,10 +1491,11 @@ class Poppler {
|
|
|
1425
1491
|
|
|
1426
1492
|
try {
|
|
1427
1493
|
const { stderr } = await execFileAsync(
|
|
1428
|
-
|
|
1494
|
+
joinSafe(this.popplerPath, "pdftotext"),
|
|
1429
1495
|
["-v"]
|
|
1430
1496
|
);
|
|
1431
1497
|
|
|
1498
|
+
// @ts-ignore: parseOptions checks if falsy
|
|
1432
1499
|
const versionInfo = /(\d{1,2}\.\d{1,2}\.\d{1,2})/u.exec(stderr)[1];
|
|
1433
1500
|
|
|
1434
1501
|
const args = parseOptions(acceptedOptions, options, versionInfo);
|
|
@@ -1447,7 +1514,7 @@ class Poppler {
|
|
|
1447
1514
|
}
|
|
1448
1515
|
|
|
1449
1516
|
const child = spawn(
|
|
1450
|
-
|
|
1517
|
+
joinSafe(this.popplerPath, "pdftotext"),
|
|
1451
1518
|
args
|
|
1452
1519
|
);
|
|
1453
1520
|
|
|
@@ -1468,6 +1535,7 @@ class Poppler {
|
|
|
1468
1535
|
});
|
|
1469
1536
|
|
|
1470
1537
|
child.on("close", (code) => {
|
|
1538
|
+
/* istanbul ignore else */
|
|
1471
1539
|
if (stdOut !== "") {
|
|
1472
1540
|
resolve(stdOut.trim());
|
|
1473
1541
|
} else if (code === 0) {
|
|
@@ -1475,8 +1543,14 @@ class Poppler {
|
|
|
1475
1543
|
} else if (stdErr !== "") {
|
|
1476
1544
|
reject(new Error(stdErr.trim()));
|
|
1477
1545
|
} else {
|
|
1478
|
-
|
|
1479
|
-
|
|
1546
|
+
reject(
|
|
1547
|
+
new Error(
|
|
1548
|
+
errorMessages[code] ||
|
|
1549
|
+
`pdftotext ${args.join(
|
|
1550
|
+
" "
|
|
1551
|
+
)} exited with code ${code}`
|
|
1552
|
+
)
|
|
1553
|
+
);
|
|
1480
1554
|
}
|
|
1481
1555
|
});
|
|
1482
1556
|
});
|
|
@@ -1503,10 +1577,11 @@ class Poppler {
|
|
|
1503
1577
|
|
|
1504
1578
|
try {
|
|
1505
1579
|
const { stderr } = await execFileAsync(
|
|
1506
|
-
|
|
1580
|
+
joinSafe(this.popplerPath, "pdfunite"),
|
|
1507
1581
|
["-v"]
|
|
1508
1582
|
);
|
|
1509
1583
|
|
|
1584
|
+
// @ts-ignore: parseOptions checks if falsy
|
|
1510
1585
|
const versionInfo = /(\d{1,2}\.\d{1,2}\.\d{1,2})/u.exec(stderr)[1];
|
|
1511
1586
|
|
|
1512
1587
|
const args = parseOptions(acceptedOptions, options, versionInfo);
|
|
@@ -1516,7 +1591,7 @@ class Poppler {
|
|
|
1516
1591
|
args.push(outputFile);
|
|
1517
1592
|
|
|
1518
1593
|
const { stdout } = await execFileAsync(
|
|
1519
|
-
|
|
1594
|
+
joinSafe(this.popplerPath, "pdfunite"),
|
|
1520
1595
|
args
|
|
1521
1596
|
);
|
|
1522
1597
|
return Promise.resolve(stdout);
|
package/types/index.d.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
export default Poppler;
|
|
2
2
|
export class Poppler {
|
|
3
|
-
/**
|
|
4
|
-
|
|
5
|
-
*/
|
|
6
|
-
constructor(binPath?: string | undefined);
|
|
3
|
+
/** @param {string} [binPath] - Path of poppler-utils binaries. */
|
|
4
|
+
constructor(binPath?: string);
|
|
7
5
|
popplerPath: string;
|
|
8
6
|
/**
|
|
9
7
|
* @author Frazer Smith
|
|
@@ -20,12 +18,10 @@ export class Poppler {
|
|
|
20
18
|
file: string,
|
|
21
19
|
fileToAttach: string,
|
|
22
20
|
outputFile: string,
|
|
23
|
-
options?:
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
| undefined
|
|
21
|
+
options?: {
|
|
22
|
+
printVersionInfo?: boolean;
|
|
23
|
+
replace?: boolean;
|
|
24
|
+
}
|
|
29
25
|
): Promise<string>;
|
|
30
26
|
/**
|
|
31
27
|
* @author Frazer Smith
|
|
@@ -55,19 +51,17 @@ export class Poppler {
|
|
|
55
51
|
*/
|
|
56
52
|
pdfDetach(
|
|
57
53
|
file: string,
|
|
58
|
-
options?:
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
| undefined
|
|
54
|
+
options?: {
|
|
55
|
+
listEmbedded?: boolean;
|
|
56
|
+
ownerPassword?: string;
|
|
57
|
+
outputEncoding?: string;
|
|
58
|
+
outputPath?: string;
|
|
59
|
+
printVersionInfo?: boolean;
|
|
60
|
+
saveAllFiles?: boolean;
|
|
61
|
+
saveFile?: string;
|
|
62
|
+
saveSpecificFile?: number;
|
|
63
|
+
userPassword?: string;
|
|
64
|
+
}
|
|
71
65
|
): Promise<string>;
|
|
72
66
|
/**
|
|
73
67
|
* @author Frazer Smith
|
|
@@ -85,16 +79,14 @@ export class Poppler {
|
|
|
85
79
|
*/
|
|
86
80
|
pdfFonts(
|
|
87
81
|
file: Buffer | string,
|
|
88
|
-
options?:
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
| undefined
|
|
82
|
+
options?: {
|
|
83
|
+
firstPageToExamine?: number;
|
|
84
|
+
lastPageToExamine?: number;
|
|
85
|
+
listSubstitutes?: boolean;
|
|
86
|
+
ownerPassword?: string;
|
|
87
|
+
printVersionInfo?: boolean;
|
|
88
|
+
userPassword?: string;
|
|
89
|
+
}
|
|
98
90
|
): Promise<string>;
|
|
99
91
|
/**
|
|
100
92
|
* @author Frazer Smith
|
|
@@ -122,24 +114,22 @@ export class Poppler {
|
|
|
122
114
|
*/
|
|
123
115
|
pdfImages(
|
|
124
116
|
file: Buffer | string,
|
|
125
|
-
outputPrefix?: string
|
|
126
|
-
options?:
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
}
|
|
142
|
-
| undefined
|
|
117
|
+
outputPrefix?: string,
|
|
118
|
+
options?: {
|
|
119
|
+
allFiles?: boolean;
|
|
120
|
+
ccittFile?: boolean;
|
|
121
|
+
firstPageToConvert?: number;
|
|
122
|
+
lastPageToConvert?: number;
|
|
123
|
+
list?: boolean;
|
|
124
|
+
jbig2File?: boolean;
|
|
125
|
+
jpeg2000File?: boolean;
|
|
126
|
+
jpegFile?: boolean;
|
|
127
|
+
ownerPassword?: string;
|
|
128
|
+
pngFile?: boolean;
|
|
129
|
+
printVersionInfo?: boolean;
|
|
130
|
+
tiffFile?: boolean;
|
|
131
|
+
userPassword?: string;
|
|
132
|
+
}
|
|
143
133
|
): Promise<string>;
|
|
144
134
|
/**
|
|
145
135
|
* @author Frazer Smith
|
|
@@ -173,32 +163,31 @@ export class Poppler {
|
|
|
173
163
|
* such as Link Annotations are listed, not URL strings in the text content.
|
|
174
164
|
* @param {boolean} [options.printVersionInfo] - Print copyright and version info.
|
|
175
165
|
* @param {string} [options.userPassword] - User password (for encrypted files).
|
|
176
|
-
* @returns {Promise<string>} A promise that resolves with a stdout string
|
|
166
|
+
* @returns {Promise<object|string>} A promise that resolves with a stdout string or JSON object if
|
|
167
|
+
* `options.printAsJson` is `true`, or rejects with an `Error` object.
|
|
177
168
|
*/
|
|
178
169
|
pdfInfo(
|
|
179
170
|
file: Buffer | string,
|
|
180
|
-
options?:
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
| undefined
|
|
201
|
-
): Promise<string>;
|
|
171
|
+
options?: {
|
|
172
|
+
firstPageToConvert?: number;
|
|
173
|
+
lastPageToConvert?: number;
|
|
174
|
+
listEncodingOptions?: boolean;
|
|
175
|
+
outputEncoding?: string;
|
|
176
|
+
ownerPassword?: string;
|
|
177
|
+
printAsJson?: boolean;
|
|
178
|
+
printBoundingBoxes?: boolean;
|
|
179
|
+
printDocStruct?: boolean;
|
|
180
|
+
printDocStructText?: boolean;
|
|
181
|
+
printIsoDates?: boolean;
|
|
182
|
+
printJS?: boolean;
|
|
183
|
+
printMetadata?: boolean;
|
|
184
|
+
printNamedDests?: boolean;
|
|
185
|
+
printRawDates?: boolean;
|
|
186
|
+
printUrls?: boolean;
|
|
187
|
+
printVersionInfo?: boolean;
|
|
188
|
+
userPassword?: string;
|
|
189
|
+
}
|
|
190
|
+
): Promise<object | string>;
|
|
202
191
|
/**
|
|
203
192
|
* @author Frazer Smith
|
|
204
193
|
* @description Extracts single pages from a PDF file,
|
|
@@ -219,13 +208,11 @@ export class Poppler {
|
|
|
219
208
|
pdfSeparate(
|
|
220
209
|
file: string,
|
|
221
210
|
outputPattern: string,
|
|
222
|
-
options?:
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
}
|
|
228
|
-
| undefined
|
|
211
|
+
options?: {
|
|
212
|
+
firstPageToExtract?: number;
|
|
213
|
+
lastPageToExtract?: number;
|
|
214
|
+
printVersionInfo?: boolean;
|
|
215
|
+
}
|
|
229
216
|
): Promise<string>;
|
|
230
217
|
/**
|
|
231
218
|
* @author Frazer Smith
|
|
@@ -334,77 +321,62 @@ export class Poppler {
|
|
|
334
321
|
*/
|
|
335
322
|
pdfToCairo(
|
|
336
323
|
file: Buffer | string,
|
|
337
|
-
outputFile?: string
|
|
338
|
-
options?:
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
scalePageToYAxis?: number | undefined;
|
|
394
|
-
singleFile?: boolean | undefined;
|
|
395
|
-
svgFile?: boolean | undefined;
|
|
396
|
-
tiffCompression?:
|
|
397
|
-
| "none"
|
|
398
|
-
| "deflate"
|
|
399
|
-
| "jpeg"
|
|
400
|
-
| "lzw"
|
|
401
|
-
| "packbits"
|
|
402
|
-
| undefined;
|
|
403
|
-
tiffFile?: boolean | undefined;
|
|
404
|
-
transparentPageColor?: boolean | undefined;
|
|
405
|
-
userPassword?: string | undefined;
|
|
406
|
-
}
|
|
407
|
-
| undefined
|
|
324
|
+
outputFile?: string,
|
|
325
|
+
options?: {
|
|
326
|
+
antialias?:
|
|
327
|
+
| "best"
|
|
328
|
+
| "default"
|
|
329
|
+
| "fast"
|
|
330
|
+
| "good"
|
|
331
|
+
| "gray"
|
|
332
|
+
| "none"
|
|
333
|
+
| "subpixel";
|
|
334
|
+
cropBox?: boolean;
|
|
335
|
+
cropHeight?: number;
|
|
336
|
+
cropSize?: number;
|
|
337
|
+
cropWidth?: number;
|
|
338
|
+
cropXAxis?: number;
|
|
339
|
+
cropYAxis?: number;
|
|
340
|
+
duplex?: boolean;
|
|
341
|
+
epsFile?: boolean;
|
|
342
|
+
evenPagesOnly?: boolean;
|
|
343
|
+
fillPage?: boolean;
|
|
344
|
+
firstPageToConvert?: number;
|
|
345
|
+
grayscaleFile?: boolean;
|
|
346
|
+
iccFile?: string;
|
|
347
|
+
jpegFile?: boolean;
|
|
348
|
+
jpegOptions?: string;
|
|
349
|
+
lastPageToConvert?: number;
|
|
350
|
+
monochromeFile?: boolean;
|
|
351
|
+
noCenter?: boolean;
|
|
352
|
+
noCrop?: boolean;
|
|
353
|
+
noShrink?: boolean;
|
|
354
|
+
oddPagesOnly?: boolean;
|
|
355
|
+
originalPageSizes?: boolean;
|
|
356
|
+
ownerPassword?: string;
|
|
357
|
+
paperHeight?: number;
|
|
358
|
+
paperSize?: "A3" | "A4" | "legal" | "letter" | "match";
|
|
359
|
+
paperWidth?: number;
|
|
360
|
+
pdfFile?: boolean;
|
|
361
|
+
pngFile?: boolean;
|
|
362
|
+
printVersionInfo?: boolean;
|
|
363
|
+
psFile?: boolean;
|
|
364
|
+
psLevel2?: boolean;
|
|
365
|
+
psLevel3?: boolean;
|
|
366
|
+
quiet?: boolean;
|
|
367
|
+
resolutionXAxis?: number;
|
|
368
|
+
resolutionXYAxis?: number;
|
|
369
|
+
resolutionYAxis?: number;
|
|
370
|
+
scalePageTo?: number;
|
|
371
|
+
scalePageToXAxis?: number;
|
|
372
|
+
scalePageToYAxis?: number;
|
|
373
|
+
singleFile?: boolean;
|
|
374
|
+
svgFile?: boolean;
|
|
375
|
+
tiffCompression?: "deflate" | "jpeg" | "lzw" | "none" | "packbits";
|
|
376
|
+
tiffFile?: boolean;
|
|
377
|
+
transparentPageColor?: boolean;
|
|
378
|
+
userPassword?: string;
|
|
379
|
+
}
|
|
408
380
|
): Promise<string>;
|
|
409
381
|
/**
|
|
410
382
|
* @author Frazer Smith
|
|
@@ -448,34 +420,32 @@ export class Poppler {
|
|
|
448
420
|
*/
|
|
449
421
|
pdfToHtml(
|
|
450
422
|
file: Buffer | string,
|
|
451
|
-
outputFile?: string
|
|
452
|
-
options?:
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
}
|
|
478
|
-
| undefined
|
|
423
|
+
outputFile?: string,
|
|
424
|
+
options?: {
|
|
425
|
+
complexOutput?: boolean;
|
|
426
|
+
dataUrls?: boolean;
|
|
427
|
+
exchangePdfLinks?: boolean;
|
|
428
|
+
extractHidden?: boolean;
|
|
429
|
+
firstPageToConvert?: number;
|
|
430
|
+
fontFullName?: boolean;
|
|
431
|
+
ignoreImages?: boolean;
|
|
432
|
+
imageFormat?: "JPG" | "PNG";
|
|
433
|
+
lastPageToConvert?: number;
|
|
434
|
+
noDrm?: boolean;
|
|
435
|
+
noFrames?: boolean;
|
|
436
|
+
noMergeParagraph?: boolean;
|
|
437
|
+
noRoundedCoordinates?: boolean;
|
|
438
|
+
outputEncoding?: string;
|
|
439
|
+
ownerPassword?: string;
|
|
440
|
+
printVersionInfo?: boolean;
|
|
441
|
+
quiet?: boolean;
|
|
442
|
+
singlePage?: boolean;
|
|
443
|
+
stdout?: boolean;
|
|
444
|
+
userPassword?: string;
|
|
445
|
+
wordBreakThreshold?: number;
|
|
446
|
+
xmlOutput?: boolean;
|
|
447
|
+
zoom?: number;
|
|
448
|
+
}
|
|
479
449
|
): Promise<string>;
|
|
480
450
|
/**
|
|
481
451
|
* @author Frazer Smith
|
|
@@ -554,55 +524,47 @@ export class Poppler {
|
|
|
554
524
|
pdfToPpm(
|
|
555
525
|
file: Buffer | string,
|
|
556
526
|
outputPath: string,
|
|
557
|
-
options?:
|
|
558
|
-
|
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
| "jpeg"
|
|
599
|
-
| "lzw"
|
|
600
|
-
| "packbits"
|
|
601
|
-
| undefined;
|
|
602
|
-
tiffFile?: boolean | undefined;
|
|
603
|
-
userPassword?: string | undefined;
|
|
604
|
-
}
|
|
605
|
-
| undefined
|
|
527
|
+
options?: {
|
|
528
|
+
antialiasFonts?: "no" | "yes";
|
|
529
|
+
antialiasVectors?: "no" | "yes";
|
|
530
|
+
cropBox?: boolean;
|
|
531
|
+
cropHeight?: number;
|
|
532
|
+
cropSize?: number;
|
|
533
|
+
cropWidth?: number;
|
|
534
|
+
cropXAxis?: number;
|
|
535
|
+
cropYAxis?: number;
|
|
536
|
+
defaultCmykProfile?: string;
|
|
537
|
+
defaultGrayProfile?: string;
|
|
538
|
+
defaultRgbProfile?: string;
|
|
539
|
+
displayProfile?: string;
|
|
540
|
+
evenPagesOnly?: boolean;
|
|
541
|
+
firstPageToConvert?: number;
|
|
542
|
+
freetype?: "no" | "yes";
|
|
543
|
+
forcePageNumber?: boolean;
|
|
544
|
+
grayscaleFile?: boolean;
|
|
545
|
+
hideAnnotations?: boolean;
|
|
546
|
+
jpegFile?: boolean;
|
|
547
|
+
lastPageToConvert?: number;
|
|
548
|
+
monochromeFile?: boolean;
|
|
549
|
+
oddPagesOnly?: boolean;
|
|
550
|
+
ownerPassword?: string;
|
|
551
|
+
pngFile?: boolean;
|
|
552
|
+
printProgress?: boolean;
|
|
553
|
+
printVersionInfo?: boolean;
|
|
554
|
+
quiet?: boolean;
|
|
555
|
+
resolutionXAxis?: number;
|
|
556
|
+
resolutionXYAxis?: number;
|
|
557
|
+
resolutionYAxis?: number;
|
|
558
|
+
scalePageTo?: number;
|
|
559
|
+
scalePageToXAxis?: number;
|
|
560
|
+
scalePageToYAxis?: number;
|
|
561
|
+
separator?: string;
|
|
562
|
+
singleFile?: boolean;
|
|
563
|
+
thinLineMode?: "none" | "shape" | "solid";
|
|
564
|
+
tiffCompression?: "deflate" | "jpeg" | "lzw" | "none" | "packbits";
|
|
565
|
+
tiffFile?: boolean;
|
|
566
|
+
userPassword?: string;
|
|
567
|
+
}
|
|
606
568
|
): Promise<string>;
|
|
607
569
|
/**
|
|
608
570
|
* @author Frazer Smith
|
|
@@ -715,58 +677,50 @@ export class Poppler {
|
|
|
715
677
|
*/
|
|
716
678
|
pdfToPs(
|
|
717
679
|
file: Buffer | string,
|
|
718
|
-
outputFile?: string
|
|
719
|
-
options?:
|
|
720
|
-
|
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
processColorFormat?: "CMYK8" | "MONO8" | "RGB8" | undefined;
|
|
763
|
-
processColorProfile?: string | undefined;
|
|
764
|
-
quiet?: boolean | undefined;
|
|
765
|
-
rasterize?: "always" | "never" | "whenneeded" | undefined;
|
|
766
|
-
resolutionXYAxis?: number | undefined;
|
|
767
|
-
userPassword?: string | undefined;
|
|
768
|
-
}
|
|
769
|
-
| undefined
|
|
680
|
+
outputFile?: string,
|
|
681
|
+
options?: {
|
|
682
|
+
antialias?: "no" | "yes";
|
|
683
|
+
binary?: boolean;
|
|
684
|
+
defaultCmykProfile?: string;
|
|
685
|
+
defaultGrayProfile?: string;
|
|
686
|
+
defaultRgbProfile?: string;
|
|
687
|
+
duplex?: boolean;
|
|
688
|
+
epsFile?: boolean;
|
|
689
|
+
fillPage?: boolean;
|
|
690
|
+
firstPageToConvert?: number;
|
|
691
|
+
form?: number;
|
|
692
|
+
lastPageToConvert?: number;
|
|
693
|
+
level1?: boolean;
|
|
694
|
+
level1Sep?: boolean;
|
|
695
|
+
level2?: boolean;
|
|
696
|
+
level2Sep?: boolean;
|
|
697
|
+
level3?: boolean;
|
|
698
|
+
level3Sep?: boolean;
|
|
699
|
+
noEmbedCIDFonts?: boolean;
|
|
700
|
+
noEmbedCIDTrueTypeFonts?: boolean;
|
|
701
|
+
noEmbedTrueTypeFonts?: boolean;
|
|
702
|
+
noEmbedType1Fonts?: boolean;
|
|
703
|
+
noCenter?: boolean;
|
|
704
|
+
noCrop?: boolean;
|
|
705
|
+
noShrink?: boolean;
|
|
706
|
+
opi?: boolean;
|
|
707
|
+
optimizecolorspace?: boolean;
|
|
708
|
+
originalPageSizes?: boolean;
|
|
709
|
+
overprint?: boolean;
|
|
710
|
+
ownerPassword?: string;
|
|
711
|
+
paperHeight?: number;
|
|
712
|
+
paperSize?: "A3" | "A4" | "legal" | "letter" | "match";
|
|
713
|
+
paperWidth?: number;
|
|
714
|
+
passfonts?: boolean;
|
|
715
|
+
preload?: boolean;
|
|
716
|
+
printVersionInfo?: boolean;
|
|
717
|
+
processColorFormat?: "CMYK8" | "MONO8" | "RGB8";
|
|
718
|
+
processColorProfile?: string;
|
|
719
|
+
quiet?: boolean;
|
|
720
|
+
rasterize?: "always" | "never" | "whenneeded";
|
|
721
|
+
resolutionXYAxis?: number;
|
|
722
|
+
userPassword?: string;
|
|
723
|
+
}
|
|
770
724
|
): Promise<string>;
|
|
771
725
|
/**
|
|
772
726
|
* @author Frazer Smith
|
|
@@ -818,34 +772,32 @@ export class Poppler {
|
|
|
818
772
|
*/
|
|
819
773
|
pdfToText(
|
|
820
774
|
file: Buffer | string,
|
|
821
|
-
outputFile?: string
|
|
822
|
-
options?:
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
}
|
|
848
|
-
| undefined
|
|
775
|
+
outputFile?: string,
|
|
776
|
+
options?: {
|
|
777
|
+
boundingBoxXhtml?: boolean;
|
|
778
|
+
boundingBoxXhtmlLayout?: boolean;
|
|
779
|
+
cropBox?: boolean;
|
|
780
|
+
cropHeight?: number;
|
|
781
|
+
cropWidth?: number;
|
|
782
|
+
cropXAxis?: number;
|
|
783
|
+
cropYAxis?: number;
|
|
784
|
+
eolConvention?: "dos" | "mac" | "unix";
|
|
785
|
+
firstPageToConvert?: number;
|
|
786
|
+
fixedWidthLayout?: number;
|
|
787
|
+
generateHtmlMetaFile?: boolean;
|
|
788
|
+
generateTsvFile?: boolean;
|
|
789
|
+
lastPageToConvert?: number;
|
|
790
|
+
listEncodingOptions?: boolean;
|
|
791
|
+
maintainLayout?: boolean;
|
|
792
|
+
noDiagonalText?: boolean;
|
|
793
|
+
noPageBreaks?: boolean;
|
|
794
|
+
outputEncoding?: string;
|
|
795
|
+
ownerPassword?: string;
|
|
796
|
+
printVersionInfo?: boolean;
|
|
797
|
+
quiet?: boolean;
|
|
798
|
+
rawLayout?: boolean;
|
|
799
|
+
userPassword?: string;
|
|
800
|
+
}
|
|
849
801
|
): Promise<string>;
|
|
850
802
|
/**
|
|
851
803
|
* @author Frazer Smith
|
|
@@ -861,10 +813,8 @@ export class Poppler {
|
|
|
861
813
|
pdfUnite(
|
|
862
814
|
files: string[],
|
|
863
815
|
outputFile: string,
|
|
864
|
-
options?:
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
}
|
|
868
|
-
| undefined
|
|
816
|
+
options?: {
|
|
817
|
+
printVersionInfo?: boolean;
|
|
818
|
+
}
|
|
869
819
|
): Promise<string>;
|
|
870
820
|
}
|