nicksagona / popphp-v1-legacy

Pop PHP Framework v1.7.0 : A Lightweight PHP Framework
http://www.popphp.org/
Other
42 stars 7 forks source link

PDF import works only with PDFs generated by PopPHP's PDF component #3

Closed nlessmann closed 11 years ago

nlessmann commented 11 years ago

I've been trying to load a PDF via

$pdf = new \Pop\Pdf\Pdf('foo.pdf');
$pdf->output();

This only works with PDFs also generated by the PDF component. With other PDFs, I always end up with the correct amount of pages, also in the correct size, but with no content.

nicksagona commented 11 years ago

I think this issue may have to do with the version of the PDF being imported. I believe at the time a large chunk of the parsing functionality was written for the PDF component, it was only built to support PDF v1.4 or v1.5, I think. So that being said, can you share with me some info about the PDF you're trying to import, namely the PDF version? Thanks.

nlessmann commented 11 years ago

I've tried it with PDFs in Versions 1.4, 1.5. and 1.7, none did work. Two of them were simple documents with only the word "Test" written on a single page (A and B), and the third was a more complex document.

nicksagona commented 11 years ago

Ok, thanks for sharing the PDF samples. I've downloaded them and will poke around and see if I can find the issue. I'll let you know what I find. Also, what program did you originally create these PDFs in? Something like Illustrator or InDesign? Or another program?

nlessmann commented 11 years ago

Thanks for taking the time to look into this! The PDFs A and B were created using html2pdf, which is based on TCPDF, which are both tools to create PDFs in PHP. The Magento document was probably created using OpenOffice.

nicksagona commented 11 years ago

Alright - I think I may have fixed this issue. I've tested it over here and it looks like it works. Would you like to grab the latest commit from the PopPHP 1.4.0 branch and test it on your end?

Basically, the import function was setting up a bad/invalid pointer to the /Resources reference object within the Page objects, and I've corrected that.

Let me know if the patch works for you - thanks.

nicksagona commented 11 years ago

Also - I wrote in support for OCG's (Optional Content Groups) which came about in PDF v1.5+. That probably still needs to be tested further, but initially, it looks like it's picking them up from your test PDFs and keeping them intact.

nlessmann commented 11 years ago

Thanks a lot, works just fine!