This example describes the way PHP uses image magick to convert PDF files to JPG files. Share to everyone for your reference. Specifically as follows:
This is a very simple format conversion code that can be put. The PDF file is converted to a. jpg file, the code will work, and the server must install the image Magick extension.
$pdf _file = './pdf/demo.pdf ';
$save _to = './jpg/demo.jpg ';
Make sure so Apache has permissions to write in this folder!
(common problem)
//execute ImageMagick command ' convert ' and convert PDF
//to JPG with applied settings
exe C (' Convert "'. $pdf _file. '" "-colorspace rgb-resize) '. $save _to. '", $output, $return _var);
if ($return _var = = 0) {
//if exec successfuly converted PDF To JPG
print "conversion OK";
}
else print "conversion failed." $output;
I hope this article will help you with your PHP program design.