2

Using 4.7.22 and Drupal 7, I'm suddenly getting the fatal error "No block-level parent found. Not good" on various pdf generation screens (for example: when hitting Print Invoice button):

error screen

It started after a recent update to my OS (Centos6).

4

That error is coming from dompdf, bundled with CiviCRM.

Here are a couple of references to that error outside of CiviCRM:

https://github.com/dompdf/dompdf/issues/902
https://github.com/barryvdh/laravel-dompdf/issues/389

The error happens for both 4.6 and 4.7, different php, so the trigger to the issue appears to be somewhat removed.

I fixed one case using the pdf setting (here: /civicrm/admin/setting/misc?reset=1). Using the wkhtmltopdf binary instead of the dompdf bundled with CiviCRM solved the issue.

I upgraded to the latest 4.7.27 version with an updated dompdf, and that did not solve the issue, but instead generated a new problem of running out of memory.

I did a bit more research and fixed the 4.6 version of the problem by removing whitespace in the html that is being fed into dompdf, in the file CRM/Utils/PDF/Utils.php, as per the suggestion by benabbotnz in the second issue linked above.

  • FYI dompdf was updated in 4.7.24 by CRM-20960 – Aidan Nov 1 '17 at 18:50
  • Thanks - I'll have to see if that solves this error, I'm due to upgrade shortly. – Alan Dixon Nov 1 '17 at 19:28
  • Upgrade to 4.7.27 converted the issue into one of running out of memory (I would think 128 Mb should be enough ...). – Alan Dixon Nov 3 '17 at 20:26
  • The fix suggested work in 4.7.x, too. – BruceW Jun 7 '18 at 22:14
2

If you’re running out of memory, as per the comment in the other answer, apply this patch to dompdf (a project external to CiviCRM which you’ll find in the CiviCRM vendor directory).

https://github.com/dompdf/dompdf/pull/1570/files

Note: this patch has been merged into dompdf master, so it will be included in the CiviCRM code base in an upcoming release.

The patch above fixed the out-of-memory-problem for 4.7.27 (can now hit Print Invoice again).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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