My controller
$pdf = PDF::loadView('pdf', $data);
$pdf->setPaper('a6', 'landscape')->setWarnings(false);
return $pdf->stream();
My function in VueJS
preview() {
axios.post('/orders/preview')
.then(function (response) {
window.open("data:application/pdf," + encodeURI(response.data));
})
.catch(function (error) {
// Error callback
});
}
However I get this string in return
%PDF-1.3
1 0 obj
<< /Type /Catalog
/Outlines 2 0 R
/Pages 3 0 R >>
endobj
2 0 obj
<< /Type /Outlines /Count 0 >>
endobj
3 0 obj
<< /Type /Pages
/Kids [6 0 R
10 0 R
13 0 R
18 0 R
21 0 R
...
If I try to open that with window.open it just opens an empty page...
Should domPDF not open a new tab automatically with ->stream()
?
Or how can I open the pdf with the given string in JS?