|
|||
|
[EDITED]
Hi First off - thanks for a great piece of work. I find zf to be extremely promising. I post because I believe there is either a bug or an important deficiency in the PDF module. In the manual it says: New page can be obtained by creating new Zend_Pdf_Page object or calling Zend_Pdf::newPage() method, which returns Zend_Pdf_Page object. The difference is that Zend_Pdf::newPage() method creates a page, already attached to the document. As far as I can see this would mean that Code:
$newpage = new Zend_Pdf_Page($pdf->pages[$idx]); while this Code:
$newpage = Zend_Pdf::newPage($pdf->pages[$idx]); zf-pdf does not act like this i reality. Apparently you can't extract a page from one document and add it to another document. I went through the code of Zend_Pdf_Page and the only method for extracting existing pages is the one doing it within the context of the current document. It would be nice if it was clearly stated in the manual that it is not possible to share pages between documents but that this feature is coming really soon ![]() I have tried the following. And I have seen almost the same from several others with same result: ex Code:
//load two documents that I want to merge
$pdf1 = Zend_Pdf::load($pdf_path1);
$pdf2 = Zend_Pdf::load($pdf_path2);
//iterate through pdf2's pages, extract one at a time
foreach($pdf2->pages as $page)
{
//create a new page from current page in pdf2
$newpage = new Zend_Pdf_Page($page);
//attatch this page at the end of pdf1
$pdf1->pages[] = $newpage;
}
//save the merged document
$pdf1->save('new.pdf');
<b>Fatal error</b>: Uncaught exception 'Zend_Pdf_Exception' with message 'Page is attached to one documen, but rendered in context of another.' in /var/www/zendlib/Zend/Pdf/Page.php:499 Stack trace: #0 /var/www/zendlib/Zend/Pdf.php(474): Zend_Pdf_Page->render(Object(Zend_Pdf_ElementFactory_Proxy )) #1 /var/www/zendlib/Zend/Pdf.php(744): Zend_Pdf->_dumpPages() #2 /var/www/zendlib/Zend/Pdf.php(260): Zend_Pdf->render(false, Resource id #266) #3 /var/www/dev3/pdf_zf/index.php(27): Zend_Pdf->save('new.pdf') #4 {main} thrown in /var/www/zendlib/Zend/Pdf/Page.php on line <b>499</b><br /> Last edited by fsando : 04-15-2008 at 07:24 PM. Reason: various stupid 'quick posting' errors |
![]() |
| Thread Tools | |
| Display Modes | |
|
|