ZF-2944: File trailer dictionary keys should not be limited
Description
The entries in a PDF document's file trailer dictionary are currently limited to one of the following ten values: Size, Prev, Root, Encrypt, Info, ID, Index, W, XRefStm, DocChecksum
Most of these entry types are described in the current version of the PDF reference. However, for forward-compatibility, this list should not be limited at all. Future versions of the PDF standard may introduce new dictionary keys which our implementation does not recognize. Additionally, other PDF implementations may add keys which do not appear in any version of the standard (see ZF-2603).
Our behavior should be to preserve and ignore any unrecognized keys. Change the Zend_Pdf_Trailer class and subclasses so that no key name validation is performed. Create and use class constants for the trailer keys generated/consumed by the framework to protect against bugs.
Comments
Posted by Willie Alberty (willie) on 2008-03-21T18:10:45.000+0000
Linking to OpenOffice issue which is a practical example of this problem.
Posted by Wil Sinclair (wil) on 2008-03-25T20:20:16.000+0000
Please categorize/fix as needed.
Posted by jim sloan (jsloan) on 2008-10-08T03:53:26.000+0000
This is still not fixed in version 1.6, but I do see the comment at line 52: /** @todo Make warning (log entry) instead of an exception */
For now I have to path the code to add 'PDFCreactiveX' to the $_allowedKeys array so that I can process PDF's generated by the Net-It Central publishing software.
Posted by Marques Johansson (displague) on 2011-10-19T14:56:30.000+0000
I don't like modifying ZF source directly because time has a tendency to forget modifications to external libraries.
I ran into this problem with an ABCpdf trailer in a PDF I was trying to parse and append. I assume this was generated using the VB.net / ASP generator of the same name.
My work-around was to add this block of code before any Zend_Pdf instances are made:
$zpt_other_allowed_keys = array('ABCpdf'); $zpt = new ReflectionProperty('Zend_Pdf_Trailer', '_allowedKeys'); $zpt->setAccessible(true); $zpt->setValue(null, array_merge($zpt->getValue(), $zpt_other_allowed_keys));