0

I'm new in Laravel, I use laravel 5.2 and I'm trying to generate a report using DomPdf but I'm getting error:

ErrorException in class.pdf.php line 3154

Undefined index:

in class.pdf.php line 3154
at HandleExceptions->handleError('8', 'Undefined index: ', 'C:\xampp\htdocs\balai\vendor\dompdf\dompdf\lib\class.pdf.php', '3154', array('size' => '12')) in class.pdf.php line 3154
at Cpdf->getFontHeight('12') in cpdf_adapter.cls.php line 740
at CPDF_Adapter->get_font_height('C:/xampp/htdocs/balai/vendor/dompdf/dompdf/lib/fonts/Times-Roman', '12') in font_metrics.cls.php line 122
at Font_Metrics::get_font_height('C:/xampp/htdocs/balai/vendor/dompdf/dompdf/lib/fonts/Times-Roman', '12') in text_frame_reflower.cls.php line 167
at Text_Frame_Reflower->_layout_line() in text_frame_reflower.cls.php line 332
at Text_Frame_Reflower->reflow(object(Block_Frame_Decorator)) in frame_decorator.cls.php line 711
at Frame_Decorator->reflow(object(Block_Frame_Decorator)) in block_frame_reflower.cls.php line 750
at Block_Frame_Reflower->reflow(null) in frame_decorator.cls.php line 711
at Frame_Decorator->reflow() in page_frame_reflower.cls.php line 123
at Page_Frame_Reflower->reflow(null) in frame_decorator.cls.php line 711
at Frame_Decorator->reflow() in dompdf.cls.php line 973
at DOMPDF->render() in PDF.php line 208
at PDF->render() in PDF.php line 154
at PDF->output() in PDF.php line 166
at PDF->save('documents.pdf') in LlajRambuController.php line 247
at LlajRambuController->printRambu('52', '1')
abarisone
  • 3,707
  • 11
  • 35
  • 54
  • This is probably due to an issue parsing the font for the metrics. I think an update to php-font-lib could help, but there are still some issues that need to be worked out. Have you tried dompdf 0.7.0 or another font? – BrianS Jun 13 '16 at 19:37
  • FYI, this is actually just a warning which does not require halting execution. Laravel is greedy with exceptions, but you *could* prevent this from halting execution by telling Laravel to ignore these errors (see [this answer](http://stackoverflow.com/a/18499557/264628)). I don't know enough about Laravel to stop it from halting on PHP notices/warning just for PDF rendering. – BrianS Jun 13 '16 at 19:39

1 Answers1

0

I was having this same problem, and I found a solution that makes no sense to me.

The HTML I was passing to dompdf didn't have any line breaks, like:

<html><body>content here<body></html>

Adding a break after the body tag fixed the problem.

<html><body>
content here
</body></html>

No clue what's going on, but now it works. Hope this fixes your problem too.

Woody
  • 1
  • 1