Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I enable debug on dompdf library?

Tags:

php

dompdf

I am using dompdf library to output some reports. I got a file outputing but I am having some strange behavior. How do I enable debug reporting in dompdf?

  $dompdf = new Dompdf();

  // something like this
  $dompdf->enableDebug();

  $dompdf->loadHtml($template);
  $dompdf->setBasePath(realpath('./'));
  $dompdf->render();
  $dompdf->stream('note');
like image 577
danielson317 Avatar asked May 03 '26 04:05

danielson317


1 Answers

Set up the globals like BrianS says:

global $_dompdf_warnings;
$_dompdf_warnings = array();
global $_dompdf_show_warnings;
$_dompdf_show_warnings = true;

Then, instead of streaming the pdf to the browser, dump the warnings array:

header('Content-type: text/plain');
var_dump($_dompdf_warnings);
die();
like image 72
Maarten Wolzak Avatar answered May 04 '26 18:05

Maarten Wolzak



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!