PHP/Imagick 复合 Gif & PDF什么也没输出?
我有以下代码将 gif 叠加到 pdf 中并将其返回到浏览器以供下载。
<?php
$first = new Imagick('PDF/page.pdf');
$second = new Imagick('images/image.gif');
$first->setImageColorspace($second->getImageColorspace() );
$first->compositeImage($second, imagick::COMPOSITE_DEFAULT, 1630, 2100);
header('Content-type: application/pdf');
header('Content-Disposition: attachment; filename="download.pdf"');
echo $first;
?>
我没有收到任何错误或任何东西,只是一个空白页和一个空白页。没有下载...谁能告诉我出了什么问题吗?
I have the following code to overlay a gif into a pdf and return it to the browser for download.
<?php
$first = new Imagick('PDF/page.pdf');
$second = new Imagick('images/image.gif');
$first->setImageColorspace($second->getImageColorspace() );
$first->compositeImage($second, imagick::COMPOSITE_DEFAULT, 1630, 2100);
header('Content-type: application/pdf');
header('Content-Disposition: attachment; filename="download.pdf"');
echo $first;
?>
I don't get any errors or anything, just a blank page & no downloads... can anybody tell me what's going wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
删除标题并重试。可能是您的 pdf 数据中写入了一些额外的错误文本。并确保显示错误已打开。
Remove headers and try again. May be you have some additional error text written in your pdf data. And be sure display errors are on.
实际上这段代码没有任何问题,我的服务器配置错误......然后我的偏移量数字就偏离了(因为它们在服务器上与在 Photoshop 中不一样)
Actually there's nothing wrong with this code, I had my server misconfigured... and then my numbers for the offset were way off (because they're not the same on the server as they were in photoshop)