[dompdf] Fatal error: Uncaught exception 'DOMPDF_Exception' with message 'No block-level parent found

2,581 views
Skip to first unread message

ervin

unread,
May 24, 2010, 11:50:14 PM5/24/10
to dompdf
Hi,

im new with dompdf. I'm using it in a cakephp project to generate and
download a pdf file from an html string that i read from an html file.
Im using dompdf 0-6-0-beta1.


Now the problem is that everything works fine in my localhost (xampp),
the pdf is rendered and generetad perfectly, but when i upload the
same code (no changes) it to the server it stops working.

Im wasting my days trying to find out whats happening so im looking
for some help here. I have tried re-uploading a new copy of dompdf,
and also checking and rechecking all the permissions. I have also
checked the html/css and it is ok (not broken)

So im just wondering if there are any external dependecies or php
modules that i need to enable on my server that makes dompdf
crashes??

Here is my html string, php code to generate the pdf and the errors im
getting:

HTML STRING:
---------------------------------------------------------------------------------------------------------------------------
<style type="text/css"> #cv-container { font-size: 12px; } .left-td
{ margin:0px; border-right: 1px solid grey; text-align: right; padding:
3px; width:200px; padding-right:10px; } .right-td { margin:0px; width:
600px; text-align: left; padding:3px; padding-left: 10px; } .bold-td
{ font-weight: bold; font-size: 16px; padding-top: 10px; padding-
bottom: 10px; } .lang-bold-td { font-weight: bold; font-size:
16px; } .head-td { padding-top:20px; padding-bottom:20px; font-size:
18px; } .lang-right,.lang-head,.lang-value { margin:0px; width:110px;
text-align: left; padding:3px; padding-left: 10px; } .lang-head { font-
weight: bold; } .lang-value { font-family: cursive; } #lang-
table,#skills-table { margin:0px; padding:0px; } .img-td { width:
105px; border-bottom: 1px solid grey; } </style> <div id="cv-
container"> <table id="cv-table" cellspacing="0px"> <tr> <td
class="img-td" ><img src="http://localhost/cv/img/europass.jpg"
height="80px" width="100px" alt="" /></td><td class="right-td"
style=""></td> </tr> <tr> <td class="left-td bold-td head-
td">Curriculum Vitae Europass</td> <td class="right-td" > </td> </tr>
<tr> <td class="left-td bold-td" >Informacione Personale</td><td
class="right-td" ></td> </tr> <tr> <td class="left-td bold-td">Emri/
Mbiemri</td><td class="right-td bold-td">name surname</td> </tr><tr>
<td class="left-td">Adresa</td><td class="right-td">address</td> </
tr><tr> <td class="left-td">Datelindja</td><td class="right-
td">02-05-2010</td> </tr> </table> </div>

PHP CODE
----------------------------------------------------------------------------------------------------------------------------------
$handle = fopen($myFile, "r");

$html = fread($handle, filesize($myFile));

fclose($handle);

$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->render();
$dompdf->stream("mycv.pdf");


ERRORS STACK TRACE
--------------------------------------------------------------------------------------------------------------------------------------
Notice (8): Undefined variable: data [APP/vendors/dompdf/include/
functions.inc.php, line 344]

Code | Context

$str = "inherit"
$encoding = "iso-8859-1"

return strlen(utf8_encode($data));
} else {
return strlen(utf8_decode($data));

mb_strlen - APP/vendors/dompdf/include/functions.inc.php, line 344
CSS_Color::parse() - APP/vendors/dompdf/include/css_color.cls.php,
line 207
Style::munge_color() - APP/vendors/dompdf/include/style.cls.php, line
737
Style::set_background() - APP/vendors/dompdf/include/style.cls.php,
line 1578
Style::__set() - APP/vendors/dompdf/include/style.cls.php, line 800
Stylesheet::_parse_properties() - APP/vendors/dompdf/include/
stylesheet.cls.php, line 1010
Stylesheet::_parse_sections() - APP/vendors/dompdf/include/
stylesheet.cls.php, line 1038
Stylesheet::_parse_css() - APP/vendors/dompdf/include/
stylesheet.cls.php, line 843
Stylesheet::load_css_file() - APP/vendors/dompdf/include/
stylesheet.cls.php, line 296
DOMPDF::_process_html() - APP/vendors/dompdf/include/dompdf.cls.php,
line 349
DOMPDF::render() - APP/vendors/dompdf/include/dompdf.cls.php, line 484
CvsController::download() - APP/controllers/cvs_controller.php, line
188
Object::dispatchMethod() - CORE/cake/libs/object.php, line 115
Dispatcher::_invoke() - CORE/cake/dispatcher.php, line 226
Dispatcher::dispatch() - CORE/cake/dispatcher.php, line 193
[main] - APP/webroot/index.php, line 87

Warning (2): DOMXPath::query() [domxpath.query]: Invalid expression
[APP/vendors/dompdf/include/stylesheet.cls.php, line 614]

Code | Context

$tree = Frame_Tree

$styles = array()
$xp = DOMXPath

$style = Style

$selector = "html"
$query = "//"

DOMXPath::query() - [internal], line ??
Stylesheet::apply_styles() - APP/vendors/dompdf/include/
stylesheet.cls.php, line 614
DOMPDF::render() - APP/vendors/dompdf/include/dompdf.cls.php, line 486
CvsController::download() - APP/controllers/cvs_controller.php, line
188
Object::dispatchMethod() - CORE/cake/libs/object.php, line 115
Dispatcher::_invoke() - CORE/cake/dispatcher.php, line 226
Dispatcher::dispatch() - CORE/cake/dispatcher.php, line 193
[main] - APP/webroot/index.php, line 87

Warning (2): Invalid argument supplied for foreach() [APP/vendors/
dompdf/include/stylesheet.cls.php, line 616]

Code | Context

$tree = Frame_Tree

$styles = array()
$xp = DOMXPath

$style = Style

$selector = "html"
$query = "//"
$nodes = false

$nodes = $xp->query($query);

foreach ($nodes as $node) {

Stylesheet::apply_styles() - APP/vendors/dompdf/include/
stylesheet.cls.php, line 616
DOMPDF::render() - APP/vendors/dompdf/include/dompdf.cls.php, line 486
CvsController::download() - APP/controllers/cvs_controller.php, line
188
Object::dispatchMethod() - CORE/cake/libs/object.php, line 115
Dispatcher::_invoke() - CORE/cake/dispatcher.php, line 226
Dispatcher::dispatch() - CORE/cake/dispatcher.php, line 193
[main] - APP/webroot/index.php, line 87


Fatal error: Uncaught exception 'DOMPDF_Exception' with message 'No
block-level parent found. Not good.' in /home/pulpfict/public_html/cv/
app/vendors/dompdf/include/inline_positioner.cls.php:68 Stack trace:
#0 /home/pulpfict/public_html/cv/app/vendors/dompdf/include/
frame_decorator.cls.php(382): Inline_Positioner->position() #1 /home/
pulpfict/public_html/cv/app/vendors/dompdf/include/
inline_frame_reflower.cls.php(56): Frame_Decorator->position() #2 /
home/pulpfict/public_html/cv/app/vendors/dompdf/include/
frame_decorator.cls.php(388): Inline_Frame_Reflower->reflow() #3 /home/
pulpfict/public_html/cv/app/vendors/dompdf/include/
page_frame_reflower.cls.php(96): Frame_Decorator->reflow() #4 /home/
pulpfict/public_html/cv/app/vendors/dompdf/include/
frame_decorator.cls.php(388): Page_Frame_Reflower->reflow() #5 /home/
pulpfict/public_html/cv/app/vendors/dompdf/include/
dompdf.cls.php(525): Frame_Decorator->reflow() #6 /home/pulpfict/
public_html/cv/app/controllers/cvs_controller.php(188): DOMPDF-
>render() #7 /home/pulpfict/public_ht in /home/pulpfict/public_html/cv/
app/vendors/dompdf/include/inline_positioner.cls.php on line 68

---------------------------------------------------------------------------------------------------------------------------

There are a couple of warnings and a notice (from the cakephp
framework) but those should not be important. What is making it to
crash is the Fatal error.

Please help, im getting mad with this.


Thanks

--
You received this message because you are subscribed to the Google Groups "dompdf" group.
To post to this group, send email to dom...@googlegroups.com.
To unsubscribe from this group, send email to dompdf+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/dompdf?hl=en.

Fabien Ménager

unread,
May 25, 2010, 4:00:52 AM5/25/10
to dompdf
Hello, your problem may come from the bug fixed by the revision 247 :
http://code.google.com/p/dompdf/source/diff?spec=svn247&r=247&format=side&path=/trunk/dompdf/include/functions.inc.php

Could you try the latest trunk or simply replace $data by $str in the
buggy function?

ervin hoxha

unread,
May 25, 2010, 1:18:27 PM5/25/10
to dom...@googlegroups.com
Hi,
thank you for the quick reply. I tried replacing $data with $str in line 342, 344 of the function.

I also enabled the php mbstring module and rebuild apache as i read that this module could also cause this issue.

 Now im getting no errors but the pdf download keeps  not working, it seams that nothing happens now only a blank page.

Everything is OK on localhost even with the changes.

I dont know what else i can do!

ervin hoxha

unread,
May 27, 2010, 11:11:32 AM5/27/10
to dom...@googlegroups.com
Ok, i think i solve it out. Here is what i've done:

- The i think the first error

Fatal error: Uncaught exception 'DOMPDF_Exception' with message 'No block-level parent found

 was caused from the missing php mbstring module, so after enabling this php module no errors were shown.

- The second issue of getting a blank page when trying to generate the pdf was caused by an image that i have inside my html string.

The problem is that if you need to render images with dompdf you need to specify the image url as an internal url on the server. For example

<img src="home/maccount/public_html/imgfolder/image.jpg"/>

and NOT

<img src="/imgfolder/image.jpg"/> or <img src="http://www.mysite.com/imgfolder/image.jpg"/>


Hope this would help someon as i already lost a couple of days trying to solve this out.

Buy

BrianS

unread,
May 30, 2010, 10:01:33 PM5/30/10
to dompdf
I'm not sure about your second issue. When you provide a full URL
(i.e. one that specifies the domain) DOMPDF should be able to work
with the image. DOMPDF treats URLs differently depending on how you
load the document and whether or not you are using a full URL. The
most consistent handling os images should always be when the
references includes the domain. There are some drawbacks, however,
since DOMPDF will need to download the image before it can be used ...
but you said you already checked permissions. Might you also not have
the GD extension enabled on your server?

Either way, I'm glad to see you got it working. Let us know if you run
into any other problems.
> > On Tue, May 25, 2010 at 10:00 AM, Fabien Ménager <fabien.mena...@gmail.com
> > > wrote:
>
> >> Hello, your problem may come from the bug fixed by the revision 247 :
>
> >>http://code.google.com/p/dompdf/source/diff?spec=svn247&r=247&format=...
> ...
>
> read more »
Reply all
Reply to author
Forward
0 new messages