2

I'm having a problem converting a pdf to png, but only when the pdf file has more than one page.

this is what I have:

shell_exec("convert -density 600 -quality 100 ".$filepath."/".$filename.$extension." ".$filepath."/".$filename.".png");

The funny part is that it works if the pdf has one page and it also works if I run it on the terminal even if it is a multi page pdf.

Any thoughts?

1 Answer 1

1

I do not see any problem in your code, except if there is any white space or any special character in the $filename or $pathname, so you must use escapeshellarg().

$filepath = escapeshellarg( $filepath.'/'.$filename.$extension );
$outfile  = escapeshellarg( $filepath.'/'.$filename.'.png' );
shell_exec( "convert -density 600 -quality 100 $filepath  $outfile" );

Can you share with us what you get in the logs, so we can have an idea about what's wrong.

Sign up to request clarification or add additional context in comments.

1 Comment

in which log should I search

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.