Return to Snippet

Revision: 40765
at February 7, 2011 22:48 by alessio2


Updated Code
/**
 * PDF2JPG script
 * with ImageMagick
 */

$pdf_file   = './pdf/demo.pdf';
$save_to    = './jpg/demo.jpg';     //make sure that apache has permissions to write in this folder! (common problem)

//execute ImageMagick command 'convert' and convert PDF to JPG with applied settings
exec('convert "'.$pdf_file.'" -colorspace RGB -resize 800 "'.$save_to.'"', $output, $return_var);


if($return_var == 0) {              //if exec successfuly converted pdf to jpg
    print "Conversion OK";
}
else print "Conversion failed.<br />".$output;

Revision: 40764
at February 7, 2011 22:41 by alessio2


Initial Code
/**
 * PDF2JPG script
 * with ImageMagick
 */

$pdf_file   = './pdf/demo.pdf';
$save_to    = './jpg/demo.jpg';     //make sure that apache has permissions to write in this folder! (common problem)

//execute ImageMagick command 'convert' and convert PDF to JPG with applied settings
exec('convert "'.$pdf_file.'" -colorspace RGB -size 800x800 "'.$save_to.'"', $output, $return_var);


if($return_var == 0) {              //if exec successfuly converted pdf to jpg
    print "Conversion OK";
}
else print "Conversion failed.<br />".$output;

Initial URL

                                

Initial Description
#ImageMagick must be installed on server for this operation

Initial Title
PDF2JPG - convert PDF to JPG images with ImageMagick

Initial Tags
image, convert

Initial Language
PHP