I'm trying to convert a pdf file into png. It works on command line, but it won't work via php code. I tried this code example from the php.net:
<?php
$imagick = new Imagick();
$imagick->readImage('myfile.pdf');
$imagick->writeImages('converted.jpg', false);
?>
When I use a relative path, it gives the following error:
Fatal error: Uncaught exception 'ImagickException' with message 'UnableToOpenBlob 'myfile.pdf': No such file or directory @ error/blob.c/OpenBlob/2702' in C:\xampp\htdocs\portalgoogle\views\ticket.php:4 Stack trace: #0 C:\xampp\htdocs\portalgoogle\views\ticket.php(4): Imagick->readimage('etiqueta.pdf') #1 {main} thrown in C:\xampp\htdocs\portalgoogle\views\ticket.php on line 4
When I use the fullpath, it just gives a fatal error on the readImage line. Could someone show me what I need to do or suggest an easier way to convert pdf to png? I tried pdf.js, but it didn't work on Chrome.
myfile.pdf
in the same directory as your PHP file? What is your directory structure? – BenM