I use dompdf in a number of sites to produce PDF documents from HTML and CSS. It works brilliantly most of the time, but one slight annoyance I’ve experienced recently is that the file is always downloaded by my browser. If I’m working on and testing a site, this can result in hundreds of PDF files littering my downloads folder, with no automated way to clean them up.
Fortunately there’s a simple way to suggest to the browser that it should display the PDF file inline instead of downloading it, by passing an additional argument to the
$dompdf->stream( 'file.pdf', array( 'Attachment' => 0 ) );
This isn’t guaranteed to work as it’s merely a hint to the browser, but it does the trick in Google Chrome.