I\'m using a litte script to convert PDF to JPG. That works but the quality is very poor.
The script:
$im = new imagick( \'document.pdf[ 0]\' );
$im
Click here for more details. Try this:
HTML
PHP
$pdfAbsolutePath = __DIR__."/test.pdf";
if (move_uploaded_file($_FILES['templateDoc']["tmp_name"], $pdfAbsolutePath)) {
$im = new imagick($pdfAbsolutePath);
$noOfPagesInPDF = $im->getNumberImages();
if ($noOfPagesInPDF) {
for ($i = 0; $i < $noOfPagesInPDF; $i++) {
$url = $pdfAbsolutePath.'['.$i.']';
$image = new Imagick($url);
$image->setImageFormat("jpg");
$image->writeImage(__DIR__."/".($i+1).'-'.rand().'.jpg');
}
echo "All pages of PDF is converted to images";
}
echo "PDF doesn't have any pages";
}