为什么 imagemagick 可以保存图像预览,但 fpdf 不能将 pdf 文件保存到服务器端文件夹
我尝试了 imagemagick 的示例代码,它能够将文档预览保存到服务器上的文件夹中。
我尝试了 fpdf 的示例代码,它在发送时能够很好地渲染 PDF 文件,但当我要求它保存目录时却失败了。
在线研究表明,fpdf 问题的解决方案是将文件权限设置为 777(据我所知,允许任何源访问)。我的默认文件夹权限是755。
我想问是否有人知道为什么我可以用imagemagick保存但不能用fpdf保存。
我怀疑原因是 imagemagick 调用需要 exec() ,这实际上是命令行访问。然而,据我了解,fpdf 只是服务器上已存在的 PDF 库的 PHP 包装器,因此应该与 exec() 具有相同的可用性。
还没有机会浏览 fpdf 的代码,但由于我是 PHP 菜鸟,我认为这不会特别有启发性。
请帮忙!
编辑: 根据要求
FPDF
$pdf->Output('testdocument.pdf', 'F');
http://www.fpdf.org/en/doc/output.htm< /a>
Imagmagick
exec('convert "docprev.pdf[0]" -colorspace RGB -geometry 200 "document2.png"');
那么这些分别是FPDF和Imagemagick的输出命令。
I tried the sample codes for imagemagick and it was able to save out document previews to the folder on the server.
I tried sample code for fpdf and it was able to render the PDF file fine when it is sent but fails when I ask it to save for directory.
Researching online it says the resolution to the fpdf issue is to set file permission to 777 (any source access permitted, as I understand). My default folder permission is 755.
I want to ask if anyone knows why I can save with imagemagick but not with fpdf.
The reason, I suspect, is because imagemagick calls requires exec() which is effectively command line access. As I understand it however, fpdf is just a PHP wrapper for PDF libraries already present on the server so should have the same availability to exec().
Haven't had a chance to go through the code of fpdf yet but as I am a noob to PHP I don't think that is going to be particularly enlightening.
Please help!
EDIT:
As requested
FPDF
$pdf->Output('testdocument.pdf', 'F');
http://www.fpdf.org/en/doc/output.htm
Imagmagick
exec('convert "docprev.pdf[0]" -colorspace RGB -geometry 200 "document2.png"');
So those are the output commands of FPDF and Imagemagick respectively.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论