Loading...
X

Error “attempt to perform an operation not allowed by the security policy `PDF’” (SOLVED)

On Debian, Ubuntu, Linux Mint, Arch Linux, and derivative systems, when converting documents from PDF to PNG, an error occurs:

attempt to perform an operation not allowed by the security policy `PDF'

An example of a command that causes this error:

convert -density 300 -quality 100 PL48536179.pdf out.jpg
convert-im6.q16: attempt to perform an operation not allowed by the security policy `PDF' @ error/constitute.c/IsCoderAuthorized/421.
convert-im6.q16: no images defined `out.jpg' @ error/convert.c/ConvertImageCommand/3229.

Apparently Imagemagick's security policy does not allow this conversion from pdf to png. Converting other formats seems to work, but not from pdf. This happens with the default imagemagick settings.

Two options for solving the problem:

1.

In the file /etc/ImageMagick-6/policy.xml before the line

</policymap>

insert the line:

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

and everything will work.

Note: The path to the policy.xml file may differ depending on the version of ImageMagick, for example, the path may be: /etc/ImageMagick-7/policy.xml

2.

The second option is similar, you also need to open the file /etc/ImageMagick-6/policy.xml

Find uncommented lines there

  <policy domain="coder" rights="none" pattern="PS" />
  <policy domain="coder" rights="none" pattern="PS2" />
  <policy domain="coder" rights="none" pattern="PS3" />
  <policy domain="coder" rights="none" pattern="EPS" />
  <policy domain="coder" rights="none" pattern="PDF" />
  <policy domain="coder" rights="none" pattern="XPS" />

And comment them out, that is, put <!-- in front of them, and --> at the end.

This should work for Debian, Ubuntu, Linux Mint, and derivative systems.

In Arch Linux open the file /etc/ImageMagick-7/policy.xml

Find the uncommented line there

<policy domain="coder" rights="none" pattern="{PS,PS2,PS3,EPS,PDF,XPS}" />

And comment them out, that is, put <!-- in front of them, and --> at the end.

After that pdf conversion should work again.

No need to do two options at once – choose one of them. The first option will only allow conversion from PDF, the second option will allow conversion from all PS, PS2, PS3, EPS, PDF, XPS formats.

This PDF policy was added due to a bug in Ghostscript that has now been fixed. That is, if you are using the current version of Ghostscript, then this policy is no longer needed.

That is, don't forget to update your Ghostscript to the latest version!


Leave Your Observation

Your email address will not be published.