dstwfcz1377 2014-05-18 16:48
浏览 64
已采纳

DOMFDF中ZF2的图像错误

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" />

With the error:

[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 Stack trace: #0 /home/luifer/Desktop/zf2-tutorial/vendor/dompdf/dompdf/include/frame_decorator.cls.php(700): Inline_Positioner->position() #1 /home/luifer/Desktop/zf2-tutorial/vendor/dompdf/dompdf/include/inline_frame_reflower.cls.php(36): Frame_Decorator->position() #2 /home/luifer/Desktop/zf2-tutorial/vendor/dompdf/dompdf/include/frame_decorator.cls.php(711): Inline_Frame_Reflower->reflow(NULL) #3 /home/luifer/Desktop/zf2-tutorial/vendor/dompdf/dompdf/include/page_frame_reflower.cls.php(123): Frame_Decorator->reflow() #4 /home/luifer/Desktop/zf2-tutorial/vendor/dompdf/dompdf/include/frame_decorator.cls.php(711): Page_Frame_Reflower->reflow(NULL) #5 /home/luifer/Desktop/zf2-tutorial/vendor/dompdf/dompdf/include/dompdf.cls.php(949): Frame_Decorator->reflow() #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;

}

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.

Anyone knows how to solve this problem? I already did some things like enabling the mbstring.

Any ideas? And thanks in advance.

  • 写回答

2条回答 默认 最新

  • drhzn3911 2014-05-19 19:08
    关注

    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.

    Another issue is that you have the image inside /home/luifer. Sometimes user directories are unreadable for other users.

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 poi合并多个word成一个新word,原word中横版没了.
  • ¥15 求MCSCANX 帮助
  • ¥15 机器学习训练相关模型
  • ¥15 Todesk 远程写代码 anaconda jupyter python3
  • ¥15 我的R语言提示去除连锁不平衡时clump_data报错,图片以下所示,卡了好几天了,苦恼不知道如何解决,有人帮我看看怎么解决吗?
  • ¥15 在获取boss直聘的聊天的时候只能获取到前40条聊天数据
  • ¥20 关于URL获取的参数,无法执行二选一查询
  • ¥15 液位控制,当液位超过高限时常开触点59闭合,直到液位低于低限时,断开
  • ¥15 marlin编译错误,如何解决?
  • ¥15 VUE项目怎么运行,系统打不开