Is there a PDF parser for PHP?

Viewed 44863

Hi I know about several PDF Generators for php (fpdf, dompdf, etc.) What I want to know is about a parser.

For reasons beyond my control, certain information I need is only in a table inside a pdf and I need to extract that table and convert it to an array.

Any suggestions?

7 Answers

Have you already looked at xPDF ? There is a program in there called pdftotext that will do the conversion. You can call it from PHP and then read in the text version of the PDF. You will need to have the ability to run exec() or system() from php, so this may not work on all hosted solutions though.

Also, there are some examples on the PHP site that will convert PDF to text, although its pretty rough. You may want to try some of those examples as well. On that PHP page, search for luc at phpt dot org.

Zend_Pdf is part of the Zend Framework. Their manual states:

The Zend_Pdf component is a PDF (Portable Document Format) manipulation engine. It can load, create, modify and save documents. Thus it can help any PHP application dynamically create PDF documents by modifying existing documents or generating new ones from scratch.

Have a look at GhostScript or ITextSharp, there are various cross-platform version of both.

It may not actually be a table inside the PDF as the PDF loses that sort of information...

Related