将动态 PDF 传输到 Imagemagick 并转换为 PNG
我需要从动态(数据库驱动)pdf 创建缩略图。我过去使用过下面脚本的变体,但这现在似乎对我不起作用(页面只是挂起)。
<?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;
?>
有人可以帮我解决这个问题吗?非常感谢:)
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 :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Magick 可以本地打开 PDF:
Magick can open PDFs natively: