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

meeadhassan's avatar

pdf in laravel :(

how i can generate a pdf file using dompdf package i get this error

ErrorException (E_ERROR) Undefined variable: order (View: C:\xampp\htdocs\Partenrs\resources\views\orders\show.blade.php) Previous exceptions

this is my code

public function downloadPDF($id)
{
    $pdf = App::make('dompdf.wrapper');
    $order = MiniMarketOrder::find($id);
    $pdf = \PDF::loadView('orders/show',$order);

   return $pdf->download('show.pdf');
}
0 likes
4 replies
rawilk's avatar
$pdf = \PDF::loadView('orders/show', compact('order'));
1 like
meeadhassan's avatar

@WILK_RANDALL - i tried this and i got this error

fopen(C:\xampp\htdocs\Partenrs\storage\fonts/\da721d0a130f1478c521c119fd743c07.ufm): failed to open stream: No such file or directory

rawilk's avatar

You probably have to enter your view name like this:

$pdf = \PDF::loadView('orders.show', compact('order'));
1 like
rawilk's avatar

Also FYI, you don't need to create multiple threads for the same question.

1 like

Please or to participate in this conversation.