0

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\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;

}

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.

luifervillalba
  • 148
  • 1
  • 3
  • 10
  • Can you clarify your setup? The `No block-level parent found` message usually indicates that no HTML was passed to dompdf. Could be an issue with an earlier version of dompdf or it could be that you're passing uninitialized/null data to dompdf. – BrianS May 21 '14 at 19:35

2 Answers2

1

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.

Jurian Sluiman
  • 13,498
  • 3
  • 67
  • 99
0

As per the dompdf documentation which can be found here: https://code.google.com/p/dompdf/wiki/FAQ

It says "This should be fixed in versions 0.4.1 and up. The error was caused by parse_url() thinking that the 'c' in 'c:\' was a protocol. Version 0.4.1 works around this issue. Another possible issue is caused by files not uploading correctly. Try re-uploading the files."

Hope that helps.

alex
  • 602
  • 4
  • 7