Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

irenehavsa's avatar

DomPDF Stream Doesn't Work on Shared Host

Hi, I use the DomPDF wrapper for Laravel from barryvdh/laravel-dompdf . I use it to show invoices so that the user can review and then print them.

This code below works fine on my local machine but not on the shared hosting. Instead of showing the PDF, it redirects to the same page.

return $pdf->stream("invoice.pdf", array('Attachment'=>0));

I have also tried modifying the code and add "exit;" after the PDF stream, but it only gave me a blank page.

$pdf->stream("invoice.pdf", array('Attachment'=>0)); 
exit;

$pdf->download also gives the same behavior.

Any idea what could be the problem? Any leads would be really helpful. Thank you :)

**Update: Apparently the stream function does work sometimes, but I am yet to figure out in what condition it does/doesn't work.

0 likes
0 replies

Please or to participate in this conversation.