Ok, with a guide from the comment by @Gordon in my question, I got a solution.
- You should have at least Zend Framework 1.11 (I was in 1.9, the first error) (found thanks to the 3rd comment on this question)
- You must
clone page from the PDF file you want to combine, otherwise your application will print an error message (self-evident) (found thanks to this slideshare , which is very interesting for Zend_Pdf) - Static PDF should be PDF <= 1.4 (mine was 1.6). Zend_Pdf cannot parse PDF version> 1.4
I used this application to convert static files that I had in versions 1.6 to 1.4.
Here is the crude code that I have and works (I know that it is not optimized, I will do it later, but still, it may be useful)
$pdf2show = new Zend_Pdf(); // Initializing the merged PDF $pdf1 = Zend_Pdf::parse($pdfContent, 1); // $pdfContent is the generated one, got the content... $template = clone $pdf1->pages[0]; // cloning the page (a must do) $page1 = new Zend_Pdf_Page($template); // Creating the first page of the merged PDF with the previous content $pdf2show->pages[] = $page1; // Adding this page to the final PDF $pdf2 = Zend_Pdf::load('urlToYourPDF.pdf'); // Loading the statif PDF $template2 = clone $pdf2->pages[0]; // cloning the page (a must do) $page2 = new Zend_Pdf_Page($template2); // Creating the second page of the merged PDF with the previous content $pdf2show->pages[] = $page2; // Adding this page to the final PDF sendToWebBrowser('title', $pdf2show->render());
sendToWebBrowser is a function to send PDF content to a browser with the title title as .... $pdf2show->render() creates a merged PDF file as a string.
Shikiryu Nov 23 '10 at 13:44 2010-11-23 13:44
source share