mardi 26 juin 2018

Show on-the-fly PDF (Content-type:application/pdf) in Laravel Blade view

I've created the DHL label creation script in Laravel and get the generated PDF, in the Controller. The "$image" is created based on the user input and supplied by DHL API as on the fly. In general (in normal PHP script, not in Laravel), we do the following to show the PDF as I see this is working fine:

header("Content-type:application/pdf");
header("Content-Disposition:inline;filename=label_123demo.pdf");
echo $image; 

So, in the controller file, I have written the code as below:

$data['image'] = $image; // generated image from DHL API
return view('Administrator.shipments.dhl-post', $data);

And in the Blade file, I wrote the following:

<div style="border: 2px solid #B0AFBE; width:800px;">
@php
header("Content-type:application/pdf");
header("Content-Disposition:inline;filename=label_123demo.pdf");
echo $image; 
@endphp
</div>

But it shows nothing.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire