I am using HTML2PDF with Laravel 5.1. I have a problem with showing the pdf file on the page and downloading it to the server.
When I use this code, it shows the pdf file without problems:
$pdf = $html2pdf->Output('', 'S');
return response($pdf)
->header('Content-Type', 'application/pdf')
->header('Content-Length', strlen($pdf))
->header('Content-Disposition', 'inline; filename="sample.pdf"');
However, the above code does not save the file to the server. So I tried this:
$filename = '\Report-' . $project->id . '.pdf';
$output_path = base_path() . '\public\reports' . $filename;
$pdf = $html2pdf->Output($output_path, 'F');
return response($pdf)
->header('Content-Type', 'application/pdf')
->header('Content-Length', strlen($pdf))
->header('Content-Disposition', 'inline; filename="'.$output_path.'"');
I've tried this in Chrome and in Firefox but it does not display the document, it just downloads the file to the server. What am I doing wrong?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire