How to read a PDF file with PHP?

PHP Developers: Why do I get an error attaching a larger than 2KB JPEG file in a pdf using ezPDF?

  • I am using ezPDF class to generate PDF in PHP. If I try to add a JPEG file with a size below 2KB, it works fine; however, with a JPEG file larger than 2KB, the whole PDF file gets corrupted. After opening the PDF file, I get "alert('file is corrupted or not repaired')".

  • Answer:

    Hmmm is there an exit call in the php script after generating the pdf output? HTML could get appended to the PDF and mess it up.

Johnny Walls at Quora Visit the source

Was this solution helpful to you?

Other answers

Try it with 2 PNG files, one under 2KB, one over 2KB.  If that works, the problem is in addJpegFromFile(). If not, let us know.  (It's a huge file for a Quora question.  That was the first point I found that could cause the problem.  If that fixes it, it doesn't pay for me to analyze the rest of the class.)

Al Klein

Are you hitting the memory limit in PHP?

Bastien Koert

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.