← Other topics

dompdf - View PDF in browser instead of downloading

Video Notes

When using the package dompdf/dompdf an issue I faced was despite using the stream method, my PDFs were always being downloaded instead of displaying directly in the browser.

To fix this, replace:



$dompdf->stream("", ["Attachment" => false]);

Full code example:


require 'vendor/autoload.php';

use Dompdf\Dompdf;

$dompdf = new Dompdf();
$dompdf->loadHtml('<h1>hello world</h1>');

# Before 😔

# After 😀
$dompdf->stream("", ["Attachment" => false]);
If this info helped you out, toss a coin in the tip jar?
← Other topics