Category Archives: Linux and OSS hints

Quick PDF conversion with convert blocked? [Solved]

Very recently I had to convert a PDF (i.e. concatenate three PDFs into one file) and I was blocked for security reasons. 

convert *pdf complete.pdf usually adds the files it finds in alphanumerical order to complete.pdf.

But not this time: 

“convert: attempt to perform an operation not allowed by the security policy `PDF’ @ error/constitute.c/IsCoderAuthorized/408.”

Googling helped, as it often does, and I found this hint at [Imagemagick security policy ‘PDF’ blocking conversion – Stack Overflow] … :

Well, I added

  <policy domain=”coder” rights=”read | write” pattern=”PDF” />

I added just before in /etc/ImageMagick-7/policy.xml and that makes it work again, but not sure about the security implications of that.”

A comment says that was a Ghostscript vulnerability, but new gs-versions are fine. Let’s hope that’s true…:-)

Update: 

Since the convert process resulted in bad quality (after I applied the changes above), I had to do some more homework and play with the values of this convert command: 

convert -density 200 -trim [Input_PDF_Files]* -quality 50 output.pdf

In my setup, that ends up with decent quality but 2.5 MByte per page.