I have this endpoint, which outputs (render in the browser) a PDF file:
$pdf = PDF::loadView('print.property', $data, []); // DOMPDF
$filename = 'test.pdf';
if($show) {
return $pdf->stream( $filename );
}
return $pdf->download($filename);
, where $show
means render, but not download the PDF file.
For desktop everything works fine and the PDF file is rendered, but when I set with Chrome Dev Tools, the mobile simulator, the server doesn't response, but just stays in load mode.
I have tried with exit, without return with headers:
header("Content-Type: application/octet-stream");
header("Content-Disposition: inline; filename=\"$filename\"");
With Content-Disposition: attachment
, it downloads the correct generated file.
The problem is somewhere in the headers I guess.
* I am using LiteServer
.
This are some of the generated from the library response headers:
content-disposition: inline; filename="test.pdf"
content-type: application/pdf
I have tried and with this headers before: die ($pdf->stream( $filename));
header('Content-Length: 101840');
header('Content-Type: application/octet-stream');
or:
header('Content-Type: application/pdf');
or: header('Content-Disposition: inline; filename="'.$filename.'"'); or: header('Content-Disposition: attachment; filename="'.$filename.'"');
Nothing works. The closest that I ca get is downloading or render it as a string in the browser in Chrome (mobile).