0

I'm getting error!!!

fatal error

here is my code

error_reporting(1);
ini_set('display_errors', 'on');
require_once "html2pdf/html2pdf.class.php";
$html_content = "<html lang='en'>
    <head> <title> Image </title> </head>
    <body> <h1> This is test, Now what do you want??? </h1> </body>
</html>";

$html2pdf = new HTML2PDF('P', 'A4');
$html2pdf->WriteHTML($html_content);
$file = $html2pdf->Output('temp.pdf', 'F');

$im = new imagick();
$im->setResolution(300,300);
$im->readimage('temp.pdf[0]');
$im->setImageFormat('jpeg');
$im->writeImage('thumb.jpg');
$im->clear();
$im->destroy();

getting error at this line of code $im->readimage('temp.pdf[0]'); I've search and find this link Convert PDF to JPEG with PHP and ImageMagick but this code is not working at my system using wamp server PHP Version 5.4.16, Apache 2.4.4, wampserver 2.4, windows 7 32 bit and ImageMagick 6.8.6 so what is the problem in my code why it is giving me this error and how to solve this???

Community
  • 1
  • 1
Google User
  • 171
  • 2
  • 12
  • Can you please check with providing the full path for `temp.pdf`. – prava Jun 06 '14 at 11:28
  • the file exists at my root directory the path is right I think the readimage function couldn't read pdf format `$im->readimage('temp.pdf[0]');`. – Google User Jun 06 '14 at 11:33
  • Yes true :), there is some issue, but not like `readimage` can't read from pdf files. It can. `Imagick` class can be used for reading from PDF files. – prava Jun 06 '14 at 12:04
  • So you're talking about this `$im = new imagick('temp.pdf'); $im->setImageFormat('jpg'); header('Content-Type: image/jpeg'); echo $im;` I've also tried this but didn't work. – Google User Jun 06 '14 at 12:08

0 Answers0