I found the solution.
It was an imagemagick policy that needed to be turn on.
First I run manually the same convert command and got this error: “convert: not authorized `test.pdf’ @ error/constitute.c/ReadImage/412.” Then I searched google and got this: https://stackoverflow.com/questions/42928765/convertnot-authorized-aaaa-error-constitute-c-readimage-453
So, the solution is to modify “/etc/ImageMagick-6/policy.xml” and change
<policy domain="coder" rights="none" pattern="PDF" />
to
<policy domain="coder" rights="read|write" pattern="PDF" />