Skip to content

Instantly share code, notes, and snippets.

@susanBuck
Created February 1, 2024 15:51
Show Gist options
  • Save susanBuck/0c907c4d42fa217251f8bc9e163e1da0 to your computer and use it in GitHub Desktop.
Save susanBuck/0c907c4d42fa217251f8bc9e163e1da0 to your computer and use it in GitHub Desktop.
Fix for Dompdf downloading instead of streaming to the browser
<?php
/**
Fix for Dompdf downloading instead of streaming to the browser
⭐ Video guide: https://youtu.be/ktOoBDSFTgI ⭐
**/
require 'vendor/autoload.php';
use Dompdf\Dompdf;
$dompdf = new Dompdf();
$dompdf->loadHtml('<h1>hello world</h1>');
$dompdf->render();
# Before 😔
#$dompdf->stream();
# After 😀
$dompdf->stream("", ["Attachment" => false]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment