Zend Framework

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

Details

  • Type: Docs:  Improvement Docs: Improvement
  • Status: Resolved Resolved
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 1.7.5
  • Fix Version/s: 1.9.0
  • Component/s: Zend_Pdf
  • Labels:
    None

Description

Zend_Pdf, 37.4.2 (http://framework.zend.com/manual/en/zend.pdf.pages.html) 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

unset($pdf->pages[$templatePageIndex]);

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);

Activity

Hide
Leonardo Piseri added a comment -

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

Show
Leonardo Piseri added a comment - I'm noticing the same behaviour also using the proposed array_splice method.
Hide
Charles Hoffman added a comment -

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.

Show
Charles Hoffman added a comment - 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.
Hide
Blue added a comment -

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

Show
Blue added a comment - For me, the same error. Would like the error as quickly as possible to have resolved.
Hide
Michael Raschke added a comment -

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;

unset($pdf->pages[0]);

But the same warning appears!!

Show
Michael Raschke added a comment - 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; unset($pdf->pages[0]); But the same warning appears!!
Hide
Alexander Veremyev added a comment -

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

Show
Alexander Veremyev added a comment - Problem appears if deleted page is referred by document open action attribute or within bookmarks (and probably in some other places).
Hide
Alexander Veremyev added a comment -

Fixed for ZF 1.9.0

Show
Alexander Veremyev added a comment - Fixed for ZF 1.9.0

People

Vote (4)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: