How to solve convert pdf to jpg not authorized error on Ubuntu 18.04 command line

Find this line in /etc/{ImagemagickFolder}/policy.xml

<policy domain="coder" rights="none" pattern="PDF" />

Replace with this line

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