dompdf = new Dompdf($options ?? $this->getDefaultOptions()); $this->setPaper('A4', 'portrait'); } private function getDefaultOptions() : Options { $options = new Options; $options->set('isPhpEnabled', true); return $options; } public function setPaper(string $type, string $orientation) : void { $this->dompdf->setPaper($type, $orientation); } public function stream(string $html, string $fileName = 'documento') { $this->dompdf->loadHtml($html); $this->dompdf->render(); return response()->streamDownload( function () { echo $this->dompdf->output(); }, "{$fileName}.pdf", ['Content-Type' => 'Application/pdf'] ); } public function output(string $html) { $this->dompdf->loadHtml($html); $this->dompdf->render(); return $this->dompdf->output(); } }