ZF-5832: removing pages from a Zend_Pdf's pages[] array causes some PDF readers to issue warning


Zend_Pdf, 37.4.2 (…) gives an example of cloning a page and using it as a template for other pages and then removing the template page. To remove the template page, the example code is


I'm noticing that the documents in which I am using this technique, when opened in Adobe Acrobat, cause a warning message: "The document's page tree contains an invalid node." I suspect that the gap left in the indices of the Zend_Pdf pages[] property by removing pages in this way is causing a null, "invalid" page in the document. Perhaps it would be better for the example to use:

array_splice($pdf>pages, $templatePageIndex, 1);


I'm noticing the same behaviour also using the proposed array_splice method.

Darn. I thought that might do it since it wouldn't leave a gap in the array indices, but hadn't had a chance to try it out as I didn't have a Windows box handy to try and open the resulting file in AA. It's too bad because the document views and prints fine after issuing the warning, but the warning seems seems to freak people out a little.

For me, the same error. Would like the error as quickly as possible to have resolved.

The same problem occurs after overwriting a page:

$pdf = Zend_Pdf::load('pdf/xyz.pdf'); $template = $pdf->pages[0]; $page = new Zend_Pdf_Page($template); $pdf->pages[0] = $page;

This should be the alternative to: $pdf = Zend_Pdf::load('pdf/xyz.pdf'); $template = $pdf->pages[0]; $page = new Zend_Pdf_Page($template); $pdf->pages[1] = $page;


But the same warning appears!!

Problem appears if deleted page is referred by document open action attribute or within bookmarks (and probably in some other places).

Fixed for ZF 1.9.0