node-poppler 5.1.5 → 5.1.6
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/CHANGELOG.md +23 -0
- package/package.json +1 -1
- package/src/index.js +20 -8
- package/tsconfig.json +0 -9
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,29 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## [5.1.6](https://github.com/Fdawgs/node-poppler/compare/v5.1.5...v5.1.6) (2022-06-04)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* **index:** set correct "file size" if `pdfInfo()` passed a buffer ([#427](https://github.com/Fdawgs/node-poppler/issues/427)) ([8d30764](https://github.com/Fdawgs/node-poppler/commit/8d3076482d13e1d31a54a5d7147cb1a3390b59bc))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Improvements
|
|
14
|
+
|
|
15
|
+
* **index:** use `forEach` over `map` as returned array not used ([#426](https://github.com/Fdawgs/node-poppler/issues/426)) ([ef89aa6](https://github.com/Fdawgs/node-poppler/commit/ef89aa6333edcd875596ee133775ad887e43dcb5))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Dependencies
|
|
19
|
+
|
|
20
|
+
* **.npmignore:** ignore `tsconfig.json` ([a35757d](https://github.com/Fdawgs/node-poppler/commit/a35757d6c51f6ef0386c59b6e5657530c25f6726))
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
### Miscellaneous
|
|
24
|
+
|
|
25
|
+
* **.github/funding:** remove unused keys ([66a8f36](https://github.com/Fdawgs/node-poppler/commit/66a8f366c9150730718bfa37ed0a056f09b925ce))
|
|
26
|
+
* **.github:** add `FUNDING.yml` ([f73407d](https://github.com/Fdawgs/node-poppler/commit/f73407df0c9561eb69c17732dc40dfd8d6a3517c))
|
|
27
|
+
|
|
5
28
|
### [5.1.5](https://github.com/Fdawgs/node-poppler/compare/v5.1.4...v5.1.5) (2022-06-01)
|
|
6
29
|
|
|
7
30
|
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -439,9 +439,16 @@ class Poppler {
|
|
|
439
439
|
versionInfo
|
|
440
440
|
);
|
|
441
441
|
|
|
442
|
+
/**
|
|
443
|
+
* Poppler does not set the "File size" metadata value if passed
|
|
444
|
+
* a Buffer via stdin, so need to retrieve it from the Buffer
|
|
445
|
+
*/
|
|
446
|
+
let fileSize;
|
|
447
|
+
|
|
442
448
|
return new Promise((resolve, reject) => {
|
|
443
449
|
if (Buffer.isBuffer(file)) {
|
|
444
450
|
args.push("-");
|
|
451
|
+
fileSize = file.length;
|
|
445
452
|
} else {
|
|
446
453
|
args.push(file);
|
|
447
454
|
}
|
|
@@ -469,20 +476,25 @@ class Poppler {
|
|
|
469
476
|
|
|
470
477
|
child.on("close", async () => {
|
|
471
478
|
if (stdOut !== "") {
|
|
479
|
+
if (fileSize) {
|
|
480
|
+
stdOut = stdOut.replace(
|
|
481
|
+
/(File\s+size:\s+)0(\s+)bytes/,
|
|
482
|
+
`$1${fileSize}$2bytes`
|
|
483
|
+
);
|
|
484
|
+
}
|
|
485
|
+
|
|
472
486
|
if (options.printAsJson === true) {
|
|
473
487
|
/**
|
|
474
488
|
* Thanks to @sainf for this solution
|
|
475
489
|
* https://github.com/Fdawgs/node-poppler/issues/248#issuecomment-845948080
|
|
476
490
|
*/
|
|
477
491
|
const info = {};
|
|
478
|
-
stdOut
|
|
479
|
-
.split("
|
|
480
|
-
.
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
line[1].trim();
|
|
485
|
-
});
|
|
492
|
+
stdOut.split("\n").forEach((line) => {
|
|
493
|
+
const lines = line.split(": ");
|
|
494
|
+
if (lines.length > 1) {
|
|
495
|
+
info[camelCase(lines[0])] = lines[1].trim();
|
|
496
|
+
}
|
|
497
|
+
});
|
|
486
498
|
resolve(info);
|
|
487
499
|
} else {
|
|
488
500
|
resolve(stdOut.trim());
|