node-poppler 6.1.2 → 6.2.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/package.json +3 -1
- package/src/index.js +36 -36
- package/{src → types}/index.d.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-poppler",
|
|
3
|
-
"version": "6.1
|
|
3
|
+
"version": "6.2.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
|
+
"types": "types/index.d.ts",
|
|
36
37
|
"repository": "git+https://github.com/Fdawgs/node-poppler.git",
|
|
37
38
|
"homepage": "https://github.com/Fdawgs/node-poppler",
|
|
38
39
|
"bugs": {
|
|
@@ -40,6 +41,7 @@
|
|
|
40
41
|
},
|
|
41
42
|
"license": "MIT",
|
|
42
43
|
"author": "Frazer Smith <frazer.dev@outlook.com>",
|
|
44
|
+
"funding": "https://github.com/sponsors/Fdawgs",
|
|
43
45
|
"engines": {
|
|
44
46
|
"node": ">=14.0.0"
|
|
45
47
|
},
|
package/src/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable security/detect-child-process */
|
|
2
1
|
const camelCase = require("camelcase");
|
|
3
2
|
const path = require("upath");
|
|
4
3
|
const { execFile, spawn } = require("child_process");
|
|
@@ -11,6 +10,7 @@ const errorMessages = {
|
|
|
11
10
|
1: "Error opening a PDF file",
|
|
12
11
|
2: "Error opening an output file",
|
|
13
12
|
3: "Error related to PDF permissions",
|
|
13
|
+
4: "Error related to ICC profile",
|
|
14
14
|
99: "Other error",
|
|
15
15
|
3221226505: "Internal process error",
|
|
16
16
|
};
|
|
@@ -19,10 +19,12 @@ const errorMessages = {
|
|
|
19
19
|
* @author Frazer Smith
|
|
20
20
|
* @description Check each option provided is valid, of the correct type, and can be used by specified
|
|
21
21
|
* version of binary.
|
|
22
|
+
* @ignore
|
|
22
23
|
* @param {object} acceptedOptions - Object containing options that a binary accepts.
|
|
23
24
|
* @param {object} options - Object containing options to pass to binary.
|
|
24
25
|
* @param {string=} version - Version of binary.
|
|
25
|
-
* @returns {Array
|
|
26
|
+
* @returns {Array<string>} Array of CLI arguments.
|
|
27
|
+
* @throws If invalid arguments provided.
|
|
26
28
|
*/
|
|
27
29
|
function parseOptions(acceptedOptions, options, version) {
|
|
28
30
|
const args = [];
|
|
@@ -233,19 +235,19 @@ class Poppler {
|
|
|
233
235
|
let stdOut = "";
|
|
234
236
|
let stdErr = "";
|
|
235
237
|
|
|
236
|
-
child.stdout.on("data",
|
|
238
|
+
child.stdout.on("data", (data) => {
|
|
237
239
|
stdOut += data;
|
|
238
240
|
});
|
|
239
241
|
|
|
240
|
-
child.stderr.on("data",
|
|
242
|
+
child.stderr.on("data", (data) => {
|
|
241
243
|
stdErr += data;
|
|
242
244
|
});
|
|
243
245
|
|
|
244
|
-
child.on("close",
|
|
246
|
+
child.on("close", () => {
|
|
245
247
|
if (stdOut !== "") {
|
|
246
248
|
resolve(stdOut.trim());
|
|
247
249
|
} else {
|
|
248
|
-
reject(new Error(stdErr.trim()));
|
|
250
|
+
reject(new Error(stdErr ? stdErr.trim() : undefined));
|
|
249
251
|
}
|
|
250
252
|
});
|
|
251
253
|
});
|
|
@@ -329,15 +331,15 @@ class Poppler {
|
|
|
329
331
|
let stdOut = "";
|
|
330
332
|
let stdErr = "";
|
|
331
333
|
|
|
332
|
-
child.stdout.on("data",
|
|
334
|
+
child.stdout.on("data", (data) => {
|
|
333
335
|
stdOut += data;
|
|
334
336
|
});
|
|
335
337
|
|
|
336
|
-
child.stderr.on("data",
|
|
338
|
+
child.stderr.on("data", (data) => {
|
|
337
339
|
stdErr += data;
|
|
338
340
|
});
|
|
339
341
|
|
|
340
|
-
child.on("close",
|
|
342
|
+
child.on("close", (code) => {
|
|
341
343
|
if (stdOut !== "") {
|
|
342
344
|
resolve(stdOut.trim());
|
|
343
345
|
} else if (code === 0) {
|
|
@@ -447,15 +449,15 @@ class Poppler {
|
|
|
447
449
|
let stdOut = "";
|
|
448
450
|
let stdErr = "";
|
|
449
451
|
|
|
450
|
-
child.stdout.on("data",
|
|
452
|
+
child.stdout.on("data", (data) => {
|
|
451
453
|
stdOut += data;
|
|
452
454
|
});
|
|
453
455
|
|
|
454
|
-
child.stderr.on("data",
|
|
456
|
+
child.stderr.on("data", (data) => {
|
|
455
457
|
stdErr += data;
|
|
456
458
|
});
|
|
457
459
|
|
|
458
|
-
child.on("close",
|
|
460
|
+
child.on("close", () => {
|
|
459
461
|
if (stdOut !== "") {
|
|
460
462
|
if (fileSize) {
|
|
461
463
|
stdOut = stdOut.replace(
|
|
@@ -481,7 +483,7 @@ class Poppler {
|
|
|
481
483
|
resolve(stdOut.trim());
|
|
482
484
|
}
|
|
483
485
|
} else {
|
|
484
|
-
reject(new Error(stdErr.trim()));
|
|
486
|
+
reject(new Error(stdErr ? stdErr.trim() : undefined));
|
|
485
487
|
}
|
|
486
488
|
});
|
|
487
489
|
});
|
|
@@ -734,15 +736,15 @@ class Poppler {
|
|
|
734
736
|
let stdOut = "";
|
|
735
737
|
let stdErr = "";
|
|
736
738
|
|
|
737
|
-
child.stdout.on("data",
|
|
739
|
+
child.stdout.on("data", (data) => {
|
|
738
740
|
stdOut += data;
|
|
739
741
|
});
|
|
740
742
|
|
|
741
|
-
child.stderr.on("data",
|
|
743
|
+
child.stderr.on("data", (data) => {
|
|
742
744
|
stdErr += data;
|
|
743
745
|
});
|
|
744
746
|
|
|
745
|
-
child.on("close",
|
|
747
|
+
child.on("close", (code) => {
|
|
746
748
|
if (stdOut !== "") {
|
|
747
749
|
resolve(stdOut.trim());
|
|
748
750
|
} else if (code === 0) {
|
|
@@ -865,24 +867,23 @@ class Poppler {
|
|
|
865
867
|
let stdOut = "";
|
|
866
868
|
let stdErr = "";
|
|
867
869
|
|
|
868
|
-
child.stdout.on("data",
|
|
870
|
+
child.stdout.on("data", (data) => {
|
|
869
871
|
stdOut += data;
|
|
870
872
|
});
|
|
871
873
|
|
|
872
|
-
child.stderr.on("data",
|
|
874
|
+
child.stderr.on("data", (data) => {
|
|
873
875
|
stdErr += data;
|
|
874
876
|
});
|
|
875
877
|
|
|
876
|
-
|
|
878
|
+
/**
|
|
879
|
+
* pdfToHtml does not return an exit code so check output to see if it was successful.
|
|
880
|
+
* See https://gitlab.freedesktop.org/poppler/poppler/-/blob/master/utils/pdftohtml.1
|
|
881
|
+
*/
|
|
882
|
+
child.on("close", () => {
|
|
877
883
|
if (stdOut !== "") {
|
|
878
884
|
resolve(stdOut.trim());
|
|
879
|
-
} else if (code === 0) {
|
|
880
|
-
resolve(errorMessages[code]);
|
|
881
|
-
} else if (stdErr !== "") {
|
|
882
|
-
reject(new Error(stdErr.trim()));
|
|
883
885
|
} else {
|
|
884
|
-
|
|
885
|
-
reject(new Error(errorMessages[code]));
|
|
886
|
+
reject(new Error(stdErr ? stdErr.trim() : undefined));
|
|
886
887
|
}
|
|
887
888
|
});
|
|
888
889
|
});
|
|
@@ -1067,11 +1068,11 @@ class Poppler {
|
|
|
1067
1068
|
|
|
1068
1069
|
let stdErr = "";
|
|
1069
1070
|
|
|
1070
|
-
child.stderr.on("data",
|
|
1071
|
+
child.stderr.on("data", (data) => {
|
|
1071
1072
|
stdErr += data;
|
|
1072
1073
|
});
|
|
1073
1074
|
|
|
1074
|
-
child.on("close",
|
|
1075
|
+
child.on("close", (code) => {
|
|
1075
1076
|
if (stdErr !== "") {
|
|
1076
1077
|
reject(new Error(stdErr.trim()));
|
|
1077
1078
|
} else if (code === 0) {
|
|
@@ -1302,15 +1303,15 @@ class Poppler {
|
|
|
1302
1303
|
let stdOut = "";
|
|
1303
1304
|
let stdErr = "";
|
|
1304
1305
|
|
|
1305
|
-
child.stdout.on("data",
|
|
1306
|
+
child.stdout.on("data", (data) => {
|
|
1306
1307
|
stdOut += data;
|
|
1307
1308
|
});
|
|
1308
1309
|
|
|
1309
|
-
child.stderr.on("data",
|
|
1310
|
+
child.stderr.on("data", (data) => {
|
|
1310
1311
|
stdErr += data;
|
|
1311
1312
|
});
|
|
1312
1313
|
|
|
1313
|
-
child.on("close",
|
|
1314
|
+
child.on("close", (code) => {
|
|
1314
1315
|
if (stdOut !== "") {
|
|
1315
1316
|
resolve(stdOut.trim());
|
|
1316
1317
|
} else if (code === 0) {
|
|
@@ -1451,15 +1452,15 @@ class Poppler {
|
|
|
1451
1452
|
let stdOut = "";
|
|
1452
1453
|
let stdErr = "";
|
|
1453
1454
|
|
|
1454
|
-
child.stdout.on("data",
|
|
1455
|
+
child.stdout.on("data", (data) => {
|
|
1455
1456
|
stdOut += data;
|
|
1456
1457
|
});
|
|
1457
1458
|
|
|
1458
|
-
child.stderr.on("data",
|
|
1459
|
+
child.stderr.on("data", (data) => {
|
|
1459
1460
|
stdErr += data;
|
|
1460
1461
|
});
|
|
1461
1462
|
|
|
1462
|
-
child.on("close",
|
|
1463
|
+
child.on("close", (code) => {
|
|
1463
1464
|
if (stdOut !== "") {
|
|
1464
1465
|
resolve(stdOut.trim());
|
|
1465
1466
|
} else if (code === 0) {
|
|
@@ -1518,6 +1519,5 @@ class Poppler {
|
|
|
1518
1519
|
}
|
|
1519
1520
|
}
|
|
1520
1521
|
|
|
1521
|
-
module.exports =
|
|
1522
|
-
|
|
1523
|
-
};
|
|
1522
|
+
module.exports.Poppler = Poppler;
|
|
1523
|
+
module.exports.default = Poppler;
|
package/{src → types}/index.d.ts
RENAMED