Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

appending %%EOF to a PDF file in python

I'm trying to open a PDF with pyPdf. I get the following error:

pyPdf.utils.PdfReadError: EOF marker not found

I thought that I should add the EOF myself. However, I don't want to write bytes. Isn't it OS specific? I want to call something like os.eof(). What do I write? This thread is not helpful.

like image 499
anonymous Avatar asked Mar 18 '26 07:03

anonymous


1 Answers

PDF's EOF marker is a special string (%%EOF) that needs to appear in your PDF file. If it doesn't, you have a malformed PDF. This string separates the actual PDF contents from any additional data (embedded files etc.).

It has nothing to do with the EOF event you run into when reading any file up to its end.

like image 77
Tim Pietzcker Avatar answered Mar 20 '26 22:03

Tim Pietzcker