Issues

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

Linking to OpenOffice issue which is a practical example of this problem.

Please categorize/fix as needed.

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.

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