ZF2的DOMPDF中的图像错误 [英] Image error in DOMPDF for ZF2
问题描述
大家好,欢迎光临,对不起我的英语而不是我的主要语言。我也是Zend Framework 2的初学者。
当我尝试在我的网页中显示图像(带有apache2的虚拟主机,桌面中的文件夹)时,ZF2中的DOMPDF出现了问题。例如:
Hello everyone and welcome, sorry about my english not my main language. I'm a beginner on Zend Framework 2 also. I got an issue with DOMPDF in ZF2, when i try to show an image in my web page (virtualhost with apache2, the folder in desktop). For example:
<img src="/home/luifer/logo_uca.png" alt="logo_uca" />
出现错误:
[2014年5月18日星期日12:28:45.023452] [:error] [pid 7195] [client 127.0.0.1:57089] PHP致命错误:消息'No block-的未捕获异常'DOMPDF_Exception'找到了一级父级。不好。 。在/home/luifer/Desktop/zf2-tutorial/vendor/dompdf/dompdf/include/inline_positioner.cls.php:37\nStack trace:\n#0 / home / luifer /桌面/ zf2-tutorial /供应商/dompdf/dompdf/include/frame_decorator.cls.php(700):Inline_Positioner-> position()\n#1 / home / luifer / Desktop / zf2-tutorial / vendor / dompdf / dompdf /include/inline_frame_reflower.cls.php(36):Frame_Decorator-> position()\n#2 /home/luifer/Desktop/zf2-tutorial/vendor/dompdf/dompdf/include/frame_decorator.cls.php(711) :Inline_Frame_Reflower-> reflow(NULL)\n#3 /home/luifer/Desktop/zf2-tutorial/vendor/dompdf/dompdf/include/page_frame_reflower.cls.php(123):Frame_Decorator-> reflow()\n #4 /home/luifer/Desktop/zf2-tutorial/vendor/dompdf/dompdf/include/frame_decorator.cls.php(711):Page_Frame_Reflower-> reflow(NULL)\n#5 / home / luifer / Desktop / zf2 -tutorial / vendor / dompdf / dompdf / include / dompdf.cls.php(949):Frame_Decorator-> reflow()\n#6 / home / luifer / Desktop / zf2-tutorial / vendor / dino / dompdf-module / src /在/ home / luifer / Desktop / zf2-tuto中第37行上的rial / vendor / dompdf / dompdf / include / inline_positioner.cls.php
[Sun May 18 12:28:45.023452 2014] [:error] [pid 7195] [client 127.0.0.1:57089] PHP Fatal error: Uncaught exception 'DOMPDF_Exception' with message 'No block-level parent found. Not good.' in /home/luifer/Desktop/zf2-tutorial/vendor/dompdf/dompdf/include/inline_positioner.cls.php:37\nStack trace:\n#0 /home/luifer/Desktop/zf2-tutorial/vendor/dompdf/dompdf/include/frame_decorator.cls.php(700): Inline_Positioner->position()\n#1 /home/luifer/Desktop/zf2-tutorial/vendor/dompdf/dompdf/include/inline_frame_reflower.cls.php(36): Frame_Decorator->position()\n#2 /home/luifer/Desktop/zf2-tutorial/vendor/dompdf/dompdf/include/frame_decorator.cls.php(711): Inline_Frame_Reflower->reflow(NULL)\n#3 /home/luifer/Desktop/zf2-tutorial/vendor/dompdf/dompdf/include/page_frame_reflower.cls.php(123): Frame_Decorator->reflow()\n#4 /home/luifer/Desktop/zf2-tutorial/vendor/dompdf/dompdf/include/frame_decorator.cls.php(711): Page_Frame_Reflower->reflow(NULL)\n#5 /home/luifer/Desktop/zf2-tutorial/vendor/dompdf/dompdf/include/dompdf.cls.php(949): Frame_Decorator->reflow()\n#6 /home/luifer/Desktop/zf2-tutorial/vendor/dino/dompdf-module/src/ in /home/luifer/Desktop/zf2-tutorial/vendor/dompdf/dompdf/include/inline_positioner.cls.php on line 37
当我在浏览器中打开同一页面时
When i open the same page on the browser manually (right click open page with browser) the image shows in the page.
以防万一,我的控制器功能为:
Just in case, my controller function:
public function extraordinarioAction()
{
//quitar de la bd
$pdf = new PdfModel();
return $pdf;
}
我的查看页面是 extraordinario.phtml 并带有html页面。我尝试了一个带有加载图像的简单页面,但没有任何显示,只有一个空白页面出现了此错误。
And my view page is extraordinario.phtml with a html page on it. I tried a simple page with a loading image and nothing shows, just a blank page with this error.
有人知道如何解决此问题吗?我已经做了一些事情,例如启用 mbstring 。
Anyone knows how to solve this problem? I already did some things like enabling the mbstring.
有什么想法吗?
推荐答案
其他答案:由于DomPDF无法读取文件,因此可能会出现此问题。由于您的Web应用程序中正在运行DomPDF,因此php可能拥有该进程(例如 www-data
)。该用户应该对您要阅读的图像具有读取权限。
Per the other answer: the issue might be raised because DomPDF cannot read the file. Since you have DomPDF running in your web application, php probably is owning the process (e.g. www-data
). This user should have read access to the image you want to read.
另一个问题是您的图像位于 / home / luifer
。有时其他用户无法读取用户目录。
Another issue is that you have the image inside /home/luifer
. Sometimes user directories are unreadable for other users.
因此:您最好的选择是将图像放置在共享位置(例如 / var中的某个位置) / www
)。否则,请确保该文件可被其他人读取( chmod a + r logo_uca.png
),并且所有父目录都可被其他人执行( chmod a + x / home / luifer
)。请检查每个目录,说桌面上的文件夹,因此,如果文件位于 / home / luifer / Desktop
中,请检查 Desktop
文件。
So: your best option is to place the image in a shared location (e.g. somewhere in /var/www
). Otherwise, make sure the file is readable for others (chmod a+r logo_uca.png
) and all parent directories are executable for others (chmod a+x /home/luifer
). Please check every directory, you say "the folder in desktop" so if your file is placed in /home/luifer/Desktop
, check the Desktop
file as well.
这篇关于ZF2的DOMPDF中的图像错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!