Adding metadata to a PDF produces working but invalid PDF

Started by pagameba, January 12, 2016, 10:06:09 AM

Previous topic - Next topic

pagameba

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

StarGeek

You might try re-linearizing the pdf using something like qpdf.  A quick google shows the command line would be something like qpdf –linearize InFile.pdf OutFile.pdf.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

Phil Harvey

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
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).