gettalong / hexapdf

Versatile PDF creation and manipulation for Ruby
https://hexapdf.gettalong.org
Other
1.25k stars 70 forks source link

Validate absence of superfluous entries in trailer dictionary #327

Closed KoffeinFlummi closed 2 months ago

KoffeinFlummi commented 2 months ago

See #326 for context.

Validate the absence of non-standard trailer dictionary keys (i.e. those listed in ISO 32000-2 7.5.5.). If desired, this could also be extended to allow second class entries as per Annex E, although I'm not sure how prevalent their use in trailer dictionaries is, or if their use causes issues with some readers.

gettalong commented 2 months ago

It is usually not a good idea with PDF to delete unknown entries as there are many ways in which an entry might be added to a certain dictionary object. This can range from newer versions of the spec itself to official extensions like PDF/X and certain applications like LibreOffice that add entries to the trailer to provide a "hybrid" PDF that also includes the original ODT file.

Note that this is true for any dictionary object in PDF.