Error: A PDF file must end with an EOF line.
See original GitHub issueI had some problems when reading the pdf file from the buffer, since once called the function .sign (), this throws the following error:
/Users/iopazo/Develop/uno/transmision-api/node_modules/node-signpdf/dist/helpers/removeTrailingNewLine.js:40
throw new _SignPdfError.default (
^
Error: A PDF file must end with an EOF line.
Imagine the problem was with one of my PDF files, but checking these if they have the final line.
Here is my integration:
const signer = require('node-signpdf').default;
let pdfBuffer = fs.readFileSync(file);
const signedPdf = signer.sign(pdfBuffer, fs.readFileSync(signature));
console.log(signedPdf);
From already thank you very much!
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:12 (6 by maintainers)
Top Results From Across the Web
Does the %%EOF in a PDF have to appear within the last ...
Acrobat viewers require only that the %%EOF marker appear somewhere within the last 1024 bytes of the file. In other words, it's saying...
Read more >Re: end-of-file (EOF) marker as required by the PD... - 11937490
I'm trying to upload a PDF to a site but, no matter what I do, I keep getting the following error message: This...
Read more >Bug #168263 (eofpdf) “Any chars after %%EOF break the pdf ...
NO! The message of pdfopt was right. There are no chars allowed after the end of file sign %%EOF. The file corner45.pdf has...
Read more >'Fixing PDF EOF Errors with PyPDF' - MARC
Yet all of those files can be open successfully with Adobe Acrobat Reader. ... line-height: 18px; white-space: \ nowrap; ">def fixPdf(pdfFile):<br ...
Read more >PDF file format: Basic structure [updated 2020]
The last line of the PDF document contains the end of the “%%EOF” file string. ... We must remember that the initial structure...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
So how should I solve this problem ? All my pdf’s have that null byte in the end and I can’t trim a buffer.
This 0x00 is added by some dumb network app. See this for example: https://doc.lagout.org/science/0_Computer Science/3_Theory/Mathematics/Exploring Abstract Algebra with Mathematica [Hibbard %26 Levasseur 1999-02-19].pdf
the file has 0x00 in the end and yet otherwise bitperfect file from libgen does not have it! WTF. https://libgen.li/edition.php?id=139704336
As for 0D 0A I suppose the standard is vague enough.
That is wrong. Last line ends with nothing. If it ends with those, there is now a new line. But here the pdfs created by Acrobat are the reference, both docx printed to pdf and .ps files to pdf by Distiller end in 0D 0A.
**Back in the Adobe 1.3 specification, in Appendix H (Implementation notes), you’ll find this little snippet about the properties of the Acrobat viewer (not the file format):
3.4.4, “File Trailer”
Acrobat viewers require only that the %%EOF marker appear somewhere within the last 1024 bytes of the file.**
Source: https://stackoverflow.com/questions/11896858/does-the-eof-in-a-pdf-have-to-appear-within-the-last-1024-bytes-of-the-file