0

I'm using Laravel 5.8 and installed Dompdf for creating some pdf files as view.

So in the Controller method for making pdf files, I added this:

public function convertToPdf(Request $request, Order $order)
    {
        $args = [
          'order'  => $order,
          'address'  => $order->order_address->first(),
          'details'  => $order->orderDetail,
          'sendType'  => $order->productSubmit,
          'coupons'  => $this->cartController->computeDiscountForOutRequests($order->ord_object_id, $order->ord_creator_id),
          'payments'  => $order->payments,
          'user'      => User::query()->find($order->ord_creator_id)
        ];
        
        $dompdf = new Dompdf();
        $dompdf->loadHtml(view('admin.shop.orders.order_details_pdf',compact('args')));
        
        $dompdf->setPaper('A4','landscape');
        
        $dompdf->render();
        
        $dompdf->stream('demo.pdf',['Attachment' => false]);
    }

And in the view order_details_pdf:

{{ $args['order']->ord_title }}

However, it is not printing anything on the screen.

So what's going wrong here? How can I show data on this blade when using Dompdf?

Pouya
  • 114
  • 1
  • 8
  • 36
  • i use $pdf = PDF::loadView('my.path.to.view', $data); return $pdf->setPaper('a4', 'portrait')->stream('filename.pdf'); – Jack Nov 26 '22 at 10:00

0 Answers0