Reputation: 121
I am trying to download pdf file in my Laravel 5.4 application using dompdf. here is my controller code:
public function htmltopdfview($master_id) {
$ordermaster=DB::table('allorder')->where([['user_id',Auth::user()->id],
['id',$master_id]])->first();
$orderdetails=DB::table('allorder_details')->where('master_id',$master_id)->get();
$pdf = PDF::loadView('OrderReport',compact('ordermaster','orderdetails'));
return $pdf->download('invoice.pdf');
return view('OrderReport',compact('ordermaster','orderdetails'));
}
Here is my blade file code:
@foreach($orderdetails as $details)
<tr>
<td class="col-md-9"><em>{{$details->product}}</em></td>
<td class="col-md-1" style="text-align: center">{{$details->product_price}} TK </td>
<td class="col-md-1" style="text-align: center">${{$details->product_price/80}} </td>
<td class="col-md-1 text-center">{{$details->barnd}}</td>
</tr>
@endforeach
<div>
<h1 style="text-align:center;">
Thank you for your order.
<a href="{{route('pdfdownload',$ordermaster->id)}}">Download PDF</a>
</h1>
</div>
Here is my route:
Route::get('htmltopdfview/{id}','CheckoutController@htmltopdfview')->name('pdfdownload');
error screenshot :
Please help me on this. Thanks in advance
Upvotes: 1
Views: 1323
Reputation: 8663
Just in case I recommend to make sure that your Dompdf is latest version. Block.php only has 287 lines in latest version and you error happens on line 741.
Otherwise your HTML is not valid and table rows have no table. Dompdf is very sensitive to any invalid HTML code.
Upvotes: 1