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

melx's avatar
Level 4

DomPdf does not works

hello i try to make a pdf, but the browser is loading to much, and does not work

   public function export_pdf($invoice_no)
{


  $customerInvoice1 = Sales::with('customer')
  ->where('invoice_no', $invoice_no)->first();

  $customerInvoice = Sales::with('customer')
   
  ->where('invoice_no', $invoice_no)->get();

    $totalAmount = $customerInvoice->sum('amount');


$pdf =PDF::loadView('sales.pdf',compact('customerInvoice','totalAmount','customerInvoice1'));

$fieldName=$customerInvoice1->invoice_no;
return $pdf->stream($fieldName. '.pdf'); 

}
0 likes
3 replies
bobbybouwmann's avatar

Describe "does not work". Maybe because you're loading the same data twice it's getting really slow. You should first make sure you don't send too much data to the view.

Does a file called pdf.blade.php exists in the resources/views/sales directory? If not than that might be one of the issues.

yibr's avatar
yibr
Best Answer
Level 23

if you load CSS a framework it takes very long

just use basic CSS

Please or to participate in this conversation.