ExifTool Forum

ExifTool => Bug Reports / Feature Requests => Topic started by: pagameba on January 12, 2016, 10:06:09 AM

Title: Adding metadata to a PDF produces working but invalid PDF
Post by: pagameba on January 12, 2016, 10:06:09 AM
Hi,

I'm using exiftool to add metadata (title, subject, author, creator and keywords) to a PDF created using rsvg-convert (converting an SVG to a PDF).  The resulting PDFs work fine in Acrobat Reader.  I've recently been tasked with adding some DRM to the PDFs created using this process and we've settled on using FileOpen.  The FileOpen encryption program complains that the PDF is invalid.


Ill formed PDF file == The document was first created as a linearized document (it has a linearized dic) but
was modified later (it has multiple xref tables).


If we bypass adding the metadata with exiftool, the encryption software works just fine so I'm fairly sure exiftool is changing the metadata structure of the PDF such that it is not strictly valid (although it does actually work).  If we open the PDF and save it using Acrobat, it seems the metadata gets fixed and the PDF will work with the encryption software.  This is not a practical solution as the PDF generation and encryption needs to be part of an automated process.

Is there any way to get exiftool to produce a valid PDF while adding metadata?

Cheers

Paul
Title: Re: Adding metadata to a PDF produces working but invalid PDF
Post by: StarGeek on January 12, 2016, 01:39:13 PM
You might try re-linearizing the pdf using something like qpdf (http://qpdf.sourceforge.net/).  A quick google shows the command line would be something like qpdf –linearize InFile.pdf OutFile.pdf.
Title: Re: Adding metadata to a PDF produces working but invalid PDF
Post by: Phil Harvey on January 12, 2016, 04:24:54 PM
Hi Paul,

ExifTool uses an incremental update on PDF files, which should produce a valid PDF, but it will not longer be linearized.  StarGeek has given you information about one way to re-linearize it.

- Phil