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');
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();
There are several debug options: debugPng, debugKeepTemp, debugCss, debugLayout, debugLayoutLines, debugLayoutBlocks, debugLayoutInline, debugLayoutPaddingBox. They can be passed to constructor like this:
<?php
require_once 'vendor/autoload.php';
$dompdf = new \Dompdf\Dompdf(array(
'debugLayout' => true,
));
$html = '<b>BOLD</b>';
$dompdf->loadHtml($html);
$dompdf->render();
$dompdf->stream("sample.pdf", array("Attachment"=>0));
If you want some text debugging try setting the following global variables prior to using Dompdf:
global $_dompdf_warnings = array();
global $_dompdf_show_warnings = true;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.