Switching over to a new server and using PHP 7.0 (and 7.1) everything looked to be fine until I tried to view an order PDF within an email from Craft Commerce. Even using the email template provided by the plugin. The error is:

No block-level parent found. Not good.

I can't remember which DOM-PDF issue thread I came across it in, but the solution is to remove


from the document. Does anyone know of a more elegant solution? I don't think it's my server.

2 Answers 2


I came across the same issue yesterday. After a bit of reading and trial and error I found the most elegant way for now is to remove the white space between these elements.

<html><head> </head><body> </body></html>

Personally I achieved this by adding comments <!-- --> between to remove the white space

<html><!-- --><head> </head><!-- --><body> </body><!-- --></html>

I piked this up from this thread initially. https://github.com/barryvdh/laravel-dompdf/issues/389

I think that the proper solution might be to enable the html5 parser, but I think this might be a config setting within the DomPDF? Would this fall ino the Craft Commerce files?

"enable_html5_parser" => true,

  • I set tried both of those and had no success. I set "enable_html5_parser" within dompdf inside Craft Commerce and even created a template with zero whitespace! Commented Jan 22, 2018 at 9:13
  • In the end, I've gone with your solution but without comments. It seems it's just having no whitespace before <head> and after </head> that works for me, so that was easy enough. Separately, I then found an issue with <thead> and <tbody> elements no longer being supoported. So I've taken them out as well. Commented Jan 22, 2018 at 11:31

This should be fixed as of Commerce 1.2.1354


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.