Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-15-2008, 12:17 PM
Junior Member
 
Join Date: Mar 2008
Posts: 7
Default Annoying Bug in Zf_Pdf - how to report?

[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]);
Will create an unattached page that can be shared between documents
while this
Code:
$newpage = Zend_Pdf::newPage($pdf->pages[$idx]);
Will create a page attatched to the current document.

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');
With the error:
<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-&gt;render(Object(Zend_Pdf_ElementFactory_Proxy ))
#1 /var/www/zendlib/Zend/Pdf.php(744): Zend_Pdf-&gt;_dumpPages()
#2 /var/www/zendlib/Zend/Pdf.php(260): Zend_Pdf-&gt;render(false, Resource id #266)
#3 /var/www/dev3/pdf_zf/index.php(27): Zend_Pdf-&gt;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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 08:16 PM.