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 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 fs = require("fs");
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 fs.writeFile("new_file.pdf", res, { encoding: "binary" });
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.pdfToHtml(file, undefined, options).then((res) => {
114
- console.log(res);
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 fs = require("fs");
127
+ const { readFileSync } = require("node:fs");
122
128
  const { Poppler } = require("node-poppler");
123
129
 
124
- const file = fs.readFileSync("test_document.pdf");
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.pdfToHtml(file, "tester.html", options).then((res) => {
132
- console.log(res);
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.pdfToText(file, options).then((res) => {
151
- console.log(res);
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": "6.2.7",
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": ">=14.0.0"
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 path = require("upath");
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 that a binary accepts.
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.prototype.hasOwnProperty.call(acceptedOptions, key)) {
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 = path.normalizeTrim(binPath);
87
+ this.popplerPath = normalizeTrim(binPath);
85
88
  } else if (process.platform === "win32") {
86
- this.popplerPath = path.joinSafe(
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
- path.joinSafe(this.popplerPath, "pdfattach"),
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
- path.joinSafe(this.popplerPath, "pdfdetach"),
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
- path.joinSafe(this.popplerPath, "pdffonts"),
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
- path.joinSafe(this.popplerPath, "pdffonts"),
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(new Error(stdErr ? stdErr.trim() : undefined));
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
- path.joinSafe(this.popplerPath, "pdfimages"),
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
- path.joinSafe(this.popplerPath, "pdfimages"),
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
- /* istanbul ignore next */
358
- reject(new Error(errorMessages[code]));
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, or rejects with an `Error` object.
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
- path.joinSafe(this.popplerPath, "pdfinfo"),
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 = execFile(
447
- path.joinSafe(this.popplerPath, "pdfinfo"),
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(new Error(stdErr ? stdErr.trim() : undefined));
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
- path.joinSafe(this.popplerPath, "pdfseparate"),
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
- path.joinSafe(this.popplerPath, "pdfseparate"),
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
- path.joinSafe(this.popplerPath, "pdftocairo"),
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
- path.joinSafe(this.popplerPath, "pdftocairo"),
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
- /* istanbul ignore next */
763
- reject(new Error(errorMessages[code]));
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
- path.joinSafe(this.popplerPath, "pdftohtml"),
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
- path.joinSafe(this.popplerPath, "pdftohtml"),
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
- * See https://gitlab.freedesktop.org/poppler/poppler/-/blob/master/utils/pdftohtml.1
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
- path.joinSafe(this.popplerPath, "pdftoppm"),
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
- path.joinSafe(this.popplerPath, "pdftoppm"),
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
- /* istanbul ignore next */
1089
- reject(new Error(errorMessages[code]));
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
- args: "-rasterize",
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
- path.joinSafe(this.popplerPath, "pdftops"),
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
- path.joinSafe(this.popplerPath, "pdftops"),
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
- /* istanbul ignore next */
1330
- reject(new Error(errorMessages[code]));
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
- path.joinSafe(this.popplerPath, "pdftotext"),
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
- path.joinSafe(this.popplerPath, "pdftotext"),
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
- /* istanbul ignore next */
1479
- reject(new Error(errorMessages[code]));
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
- path.joinSafe(this.popplerPath, "pdfunite"),
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
- path.joinSafe(this.popplerPath, "pdfunite"),
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
- * @param {string} [binPath] - Path of poppler-utils binaries.
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
- printVersionInfo?: boolean | undefined;
26
- replace?: boolean | undefined;
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
- listEmbedded?: boolean | undefined;
61
- ownerPassword?: string | undefined;
62
- outputEncoding?: string | undefined;
63
- outputPath?: string | undefined;
64
- printVersionInfo?: boolean | undefined;
65
- saveAllFiles?: boolean | undefined;
66
- saveFile?: string | undefined;
67
- saveSpecificFile?: number | undefined;
68
- userPassword?: string | undefined;
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
- firstPageToExamine?: number | undefined;
91
- lastPageToExamine?: number | undefined;
92
- listSubstitutes?: boolean | undefined;
93
- ownerPassword?: string | undefined;
94
- printVersionInfo?: boolean | undefined;
95
- userPassword?: string | undefined;
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 | undefined,
126
- options?:
127
- | {
128
- allFiles?: boolean | undefined;
129
- ccittFile?: boolean | undefined;
130
- firstPageToConvert?: number | undefined;
131
- lastPageToConvert?: number | undefined;
132
- list?: boolean | undefined;
133
- jbig2File?: boolean | undefined;
134
- jpeg2000File?: boolean | undefined;
135
- jpegFile?: boolean | undefined;
136
- ownerPassword?: string | undefined;
137
- pngFile?: boolean | undefined;
138
- printVersionInfo?: boolean | undefined;
139
- tiffFile?: boolean | undefined;
140
- userPassword?: string | undefined;
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, or rejects with an `Error` object.
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
- firstPageToConvert?: number | undefined;
183
- lastPageToConvert?: number | undefined;
184
- listEncodingOptions?: boolean | undefined;
185
- outputEncoding?: string | undefined;
186
- ownerPassword?: string | undefined;
187
- printAsJson?: boolean | undefined;
188
- printBoundingBoxes?: boolean | undefined;
189
- printDocStruct?: boolean | undefined;
190
- printDocStructText?: boolean | undefined;
191
- printIsoDates?: boolean | undefined;
192
- printJS?: boolean | undefined;
193
- printMetadata?: boolean | undefined;
194
- printNamedDests?: boolean | undefined;
195
- printRawDates?: boolean | undefined;
196
- printUrls?: boolean | undefined;
197
- printVersionInfo?: boolean | undefined;
198
- userPassword?: string | undefined;
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
- firstPageToExtract?: number | undefined;
225
- lastPageToExtract?: number | undefined;
226
- printVersionInfo?: boolean | undefined;
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 | undefined,
338
- options?:
339
- | {
340
- antialias?:
341
- | "default"
342
- | "none"
343
- | "best"
344
- | "fast"
345
- | "good"
346
- | "gray"
347
- | "subpixel"
348
- | undefined;
349
- cropBox?: boolean | undefined;
350
- cropHeight?: number | undefined;
351
- cropSize?: number | undefined;
352
- cropWidth?: number | undefined;
353
- cropXAxis?: number | undefined;
354
- cropYAxis?: number | undefined;
355
- duplex?: boolean | undefined;
356
- epsFile?: boolean | undefined;
357
- evenPagesOnly?: boolean | undefined;
358
- fillPage?: boolean | undefined;
359
- firstPageToConvert?: number | undefined;
360
- grayscaleFile?: boolean | undefined;
361
- iccFile?: string | undefined;
362
- jpegFile?: boolean | undefined;
363
- jpegOptions?: string | undefined;
364
- lastPageToConvert?: number | undefined;
365
- monochromeFile?: boolean | undefined;
366
- noCenter?: boolean | undefined;
367
- noCrop?: boolean | undefined;
368
- noShrink?: boolean | undefined;
369
- oddPagesOnly?: boolean | undefined;
370
- originalPageSizes?: boolean | undefined;
371
- ownerPassword?: string | undefined;
372
- paperHeight?: number | undefined;
373
- paperSize?:
374
- | "match"
375
- | "A3"
376
- | "A4"
377
- | "legal"
378
- | "letter"
379
- | undefined;
380
- paperWidth?: number | undefined;
381
- pdfFile?: boolean | undefined;
382
- pngFile?: boolean | undefined;
383
- printVersionInfo?: boolean | undefined;
384
- psFile?: boolean | undefined;
385
- psLevel2?: boolean | undefined;
386
- psLevel3?: boolean | undefined;
387
- quiet?: boolean | undefined;
388
- resolutionXAxis?: number | undefined;
389
- resolutionXYAxis?: number | undefined;
390
- resolutionYAxis?: number | undefined;
391
- scalePageTo?: number | undefined;
392
- scalePageToXAxis?: number | undefined;
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 | undefined,
452
- options?:
453
- | {
454
- complexOutput?: boolean | undefined;
455
- dataUrls?: boolean | undefined;
456
- exchangePdfLinks?: boolean | undefined;
457
- extractHidden?: boolean | undefined;
458
- firstPageToConvert?: number | undefined;
459
- fontFullName?: boolean | undefined;
460
- ignoreImages?: boolean | undefined;
461
- imageFormat?: "JPG" | "PNG" | undefined;
462
- lastPageToConvert?: number | undefined;
463
- noDrm?: boolean | undefined;
464
- noFrames?: boolean | undefined;
465
- noMergeParagraph?: boolean | undefined;
466
- noRoundedCoordinates?: boolean | undefined;
467
- outputEncoding?: string | undefined;
468
- ownerPassword?: string | undefined;
469
- printVersionInfo?: boolean | undefined;
470
- quiet?: boolean | undefined;
471
- singlePage?: boolean | undefined;
472
- stdout?: boolean | undefined;
473
- userPassword?: string | undefined;
474
- wordBreakThreshold?: number | undefined;
475
- xmlOutput?: boolean | undefined;
476
- zoom?: number | undefined;
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
- antialiasFonts?: "no" | "yes" | undefined;
560
- antialiasVectors?: "no" | "yes" | undefined;
561
- cropBox?: boolean | undefined;
562
- cropHeight?: number | undefined;
563
- cropSize?: number | undefined;
564
- cropWidth?: number | undefined;
565
- cropXAxis?: number | undefined;
566
- cropYAxis?: number | undefined;
567
- defaultCmykProfile?: string | undefined;
568
- defaultGrayProfile?: string | undefined;
569
- defaultRgbProfile?: string | undefined;
570
- displayProfile?: string | undefined;
571
- evenPagesOnly?: boolean | undefined;
572
- firstPageToConvert?: number | undefined;
573
- freetype?: "no" | "yes" | undefined;
574
- forcePageNumber?: boolean | undefined;
575
- grayscaleFile?: boolean | undefined;
576
- hideAnnotations?: boolean | undefined;
577
- jpegFile?: boolean | undefined;
578
- lastPageToConvert?: number | undefined;
579
- monochromeFile?: boolean | undefined;
580
- oddPagesOnly?: boolean | undefined;
581
- ownerPassword?: string | undefined;
582
- pngFile?: boolean | undefined;
583
- printProgress?: boolean | undefined;
584
- printVersionInfo?: boolean | undefined;
585
- quiet?: boolean | undefined;
586
- resolutionXAxis?: number | undefined;
587
- resolutionXYAxis?: number | undefined;
588
- resolutionYAxis?: number | undefined;
589
- scalePageTo?: number | undefined;
590
- scalePageToXAxis?: number | undefined;
591
- scalePageToYAxis?: number | undefined;
592
- separator?: string | undefined;
593
- singleFile?: boolean | undefined;
594
- thinLineMode?: "none" | "shape" | "solid" | undefined;
595
- tiffCompression?:
596
- | "none"
597
- | "deflate"
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 | undefined,
719
- options?:
720
- | {
721
- antialias?: "no" | "yes" | undefined;
722
- binary?: boolean | undefined;
723
- defaultCmykProfile?: string | undefined;
724
- defaultGrayProfile?: string | undefined;
725
- defaultRgbProfile?: string | undefined;
726
- duplex?: boolean | undefined;
727
- epsFile?: boolean | undefined;
728
- fillPage?: boolean | undefined;
729
- firstPageToConvert?: number | undefined;
730
- form?: number | undefined;
731
- lastPageToConvert?: number | undefined;
732
- level1?: boolean | undefined;
733
- level1Sep?: boolean | undefined;
734
- level2?: boolean | undefined;
735
- level2Sep?: boolean | undefined;
736
- level3?: boolean | undefined;
737
- level3Sep?: boolean | undefined;
738
- noEmbedCIDFonts?: boolean | undefined;
739
- noEmbedCIDTrueTypeFonts?: boolean | undefined;
740
- noEmbedTrueTypeFonts?: boolean | undefined;
741
- noEmbedType1Fonts?: boolean | undefined;
742
- noCenter?: boolean | undefined;
743
- noCrop?: boolean | undefined;
744
- noShrink?: boolean | undefined;
745
- opi?: boolean | undefined;
746
- optimizecolorspace?: boolean | undefined;
747
- originalPageSizes?: boolean | undefined;
748
- overprint?: boolean | undefined;
749
- ownerPassword?: string | undefined;
750
- paperHeight?: number | undefined;
751
- paperSize?:
752
- | "match"
753
- | "A3"
754
- | "A4"
755
- | "legal"
756
- | "letter"
757
- | undefined;
758
- paperWidth?: number | undefined;
759
- passfonts?: boolean | undefined;
760
- preload?: boolean | undefined;
761
- printVersionInfo?: boolean | undefined;
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 | undefined,
822
- options?:
823
- | {
824
- boundingBoxXhtml?: boolean | undefined;
825
- boundingBoxXhtmlLayout?: boolean | undefined;
826
- cropBox?: boolean | undefined;
827
- cropHeight?: number | undefined;
828
- cropWidth?: number | undefined;
829
- cropXAxis?: number | undefined;
830
- cropYAxis?: number | undefined;
831
- eolConvention?: "dos" | "mac" | "unix" | undefined;
832
- firstPageToConvert?: number | undefined;
833
- fixedWidthLayout?: number | undefined;
834
- generateHtmlMetaFile?: boolean | undefined;
835
- generateTsvFile?: boolean | undefined;
836
- lastPageToConvert?: number | undefined;
837
- listEncodingOptions?: boolean | undefined;
838
- maintainLayout?: boolean | undefined;
839
- noDiagonalText?: boolean | undefined;
840
- noPageBreaks?: boolean | undefined;
841
- outputEncoding?: string | undefined;
842
- ownerPassword?: string | undefined;
843
- printVersionInfo?: boolean | undefined;
844
- quiet?: boolean | undefined;
845
- rawLayout?: boolean | undefined;
846
- userPassword?: string | undefined;
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
- printVersionInfo?: boolean | undefined;
867
- }
868
- | undefined
816
+ options?: {
817
+ printVersionInfo?: boolean;
818
+ }
869
819
  ): Promise<string>;
870
820
  }