ZF-4320: Moving a page between document fails with exception

Issue Type: Bug Created: 2008-09-17T14:27:44.000+0000 Last Updated: 2011-08-13T22:12:49.000+0000 Status: Postponed Fix version(s): Reporter: Alex Sherman (alxshr) Assignee: Alexander Veremyev (alexander) Tags: - Zend_Pdf

  • zf-crteam-padraic
  • zf-crteam-priority

Related issues: Attachments:


using the following code: require_once 'Zend/Loader.php'; Zend_Loader::registerAutoload(); echo "


pre>"; try { $pdf = Zend_Pdf::load("test/pages.pdf"); $pdfNew = new Zend_Pdf(); $page1 = new Zend_Pdf_Page($pdf->pages[0]); $pdfNew->pages[] = $page1; $pdfNew->save("ttt/p1.pdf"); echo "Done.".PHP_EOL; } catch (Exception $e) { echo $e; }

The following exception is received: exception 'Zend_Pdf_Exception' with message 'Page is attached to one documen, but rendered in context of another.' in /var/www/html/library/Zend/Pdf/Page.php:499 Stack trace:

0 /var/www/html/library/Zend/Pdf.php(474): Zend_Pdf_Page->render(Object(Zend_Pdf_ElementFactory_Proxy))

1 /var/www/html/library/Zend/Pdf.php(742): Zend_Pdf->_dumpPages()

2 /var/www/html/library/Zend/Pdf.php(260): Zend_Pdf->render(false, Resource id #263)

3 /var/www/html/index.php(13): Zend_Pdf->save('ttt/p1.pdf')

4 {main}


Posted by Daniel Hartmann (danielmitd) on 2008-09-24T04:51:32.000+0000

I've got the same problem here. If I want to merge some PDF files like:

$pdf = new Zend_Pdf(); ... $template = new Zend_Pdf("template.pdf", null, true); $pdf->pages[0] = new Zend_Pdf_Page($template->pages[0]);

$pdfPage = new Zend_Pdf_Page(); $pdf->pages[1] = $pdfPage;

is there any plan to implement this?

Posted by Benjamin Eberlei (beberlei) on 2008-11-18T03:32:40.000+0000

From the source code that throws that exception:

<pre class="highlight">            /**
             * @todo Page cloning must be implemented here instead of exception.
             *       PDF objects (ex. fonts) can be shared between pages.
             *       Thus all referenced objects, which can be modified, must be cloned recursively,
             *       to avoid producing wrong object references in a context of source PDF.

I look into it if it can be implemented.

Posted by Benjamin Eberlei (beberlei) on 2008-11-18T03:35:15.000+0000

On first sight, this cannot be implemented in a fast way.

Posted by Oliver Griebl (oliver75) on 2010-10-08T03:45:46.000+0000

We are generating several reports from our database automaticaly with Zend PDF, but are not able to merge different reports into one PDF document or to move pages between documents. Would it be possible that one of the developers of Zend PDF could solve this? We would be gladly willing to give a donation to support zend framework in order to get this issue solved.

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.