I need to create thumbnails from dynamic (database driven) pdf's. I've used a variation of the script below in the past, but this doesn't seem to be working for me now (page just hangs).
<?php
require_once('./template/all_includes.php');
$descriptorspec = array(
0 => array("pipe", "r"), // stdin is a pipe that the child will read from
1 => array("pipe", "w"), // stdout is a pipe that the child will write to
2 => array("pipe", "w") // stderr is a file to write to
);
$cwd = '/tmp';
$env = array('asdfadf' => '193');
$convert = "convert pdf:- png:-";
$process = proc_open($convert, $descriptorspec, $pipes, $cwd, $env);
fwrite($pipes[0], 'php /var/www/html/domain.co.uk/store/pdf.php');
fclose($pipes[0]);
while(!feof($pipes[1])) $im .= fread($pipes[1], 1024);
fclose($pipes[1]);
$return_value = proc_close($process);
header("Content-Type: image/png");
echo $im;
?>
Could anyone help me out with this please? Much appreciated :)