tags:

views:

68

answers:

1

how to convert pdf URL to png ?

Hi, I convert my local pdf file pages to png files by this code:

$im = new imagick($url . '[' . $i . ']');
$im->setImageFormat("png");
$im->writeImage($thisFile);

this code works only when my pdf file exists on my local (for example $url = "./pdf_files/test.pdf"), a local file path. but, if I change it to a URL , $url = "http://khajenejad.staffcms.um.ac.ir/imagesm/1023/stories/pm-76.pdf" ,it can not convert pdf url page to png. it reports bellow error. By the way http://khajenejad.staffcms.um.ac.ir/imagesm/1023/stories/pm-76.pdf is a valid url.

exception 'ImagickException' with message 'unable to open image `/var/www/PDF/http:/khajenejad.staffcms.um.ac.ir/imagesm/1023/stories/pm-76.pdf': No such file or directory @ blob.c/OpenBlob/2439' in /var/www/PDF/index.php:37
Stack trace: #0 /var/www/PDF/index.php(37): Imagick->__construct('http://khajenej...') #1 {main}

what can I do?

A: 

Download the pdf to a temporary file on your server, then process that. Use curl or something similar.

Maerlyn