poppler.pdfInfo always reports 0 bytes in fileSize if PDF file is Buffer
nhvu1988 opened this issue · 1 comments
nhvu1988 commented
Prerequisites
-
I have written a descriptive issue title
-
I have searched existing issues to ensure it has not already been reported
-
I agree to follow the Code of Conduct that this project adheres to
API/app/plugin version
5.1.5
Node.js version
16
Operating system
Linux
Operating system version (i.e. 20.04, 11.3, 10)
20.04
Description
The poppler.pdfInfo
always reports 0 bytes in fileSize if the PDF file is Buffer.
Steps to Reproduce
Add the below code to index.test.js and run to see it
test("Should list info of PDF file as Buffer as a JSON object", async () => {
const poppler = new Poppler(testBinaryPath);
const attachmentFile = await fs.promises.readFile(file);
const res = await poppler.pdfInfo(attachmentFile, {
printAsJson: true,
});
expect(res).toMatchObject({
tagged: "yes",
userProperties: "no",
suspects: "no",
form: "AcroForm",
javaScript: "no",
pages: "16",
encrypted: "no",
pageSize: "595.276 x 841.89 pts (A4)",
pageRot: "0",
fileSize: "583094 bytes",
optimized: "no",
pdfVersion: "1.3",
});
});
The test reports is
● Node-Poppler Module › pdfInfo Function › Should list info of PDF file as Buffer as a JSON object
expect(received).toMatchObject(expected)
- Expected - 1
+ Received + 1
@@ -1,8 +1,8 @@
Object {
"encrypted": "no",
- "fileSize": "583094 bytes",
+ "fileSize": "0 bytes",
"form": "AcroForm",
"javaScript": "no",
"optimized": "no",
"pageRot": "0",
"pageSize": "595.276 x 841.89 pts (A4)",
414 | });
415 |
> 416 | expect(res).toMatchObject({
| ^
417 | tagged: "yes",
418 | userProperties: "no",
419 | suspects: "no",
at Object.toMatchObject (src/index.test.js:416:16)
Test Suites: 1 failed, 1 total
Tests: 1 failed, 90 passed, 91 total
Snapshots: 0 total
Time: 32.347 s, estimated 33 s
Ran all test suites.
Expected Behaviour
It should report correct fileSize.