PDF created with FPDF cannot be opened by Adobe Reader

偶尔善良 提交于 2019-12-14 03:11:18

问题


My PDF file cannot be opened with Adobe Reader. What's weird is that the PDF used to work in Adobe Reader just a few days ago and now it does not work, and of course I didn't modify the code otherwise it would be easy to fix.

I validated my PDF and learned it was a PDF/A-3, could be that it is not a PDF/A-1? If so why did it work for a time and suddenly stopped working?

EDIT

The problem was that somehow, some HTML code was output inside the PDF file, thus making the PDF file invalid for Adobe Reader, but not for Firefox, making all this much more confusing than it should be.

So a tip to anyway having trouble with PDF, open it with a text editor such as Notepad++ for Windows or GEdit for Linux, and compare with another PDF file which works fine. You should find the problem pretty quickly.


回答1:


I read a lot of questions about this and I understood that the problem is happening with:

ob_start();

Without this line, my FPDF was not working with the message explained that there was another buffer first. With this line, the PDF was readable only with Browser.

I changed this line to:

ob_clean();

and now I can open PDF with any reader.



来源:https://stackoverflow.com/questions/22817210/pdf-created-with-fpdf-cannot-be-opened-by-adobe-reader

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!