I am trying to open a PDF document received as a response text, in a new browser tab.
My controller code is :
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord,'HTML');
$objWriter->save('helloWorld.html');
$pdf = App::make('dompdf.wrapper');
$pdf->loadHTML('helloWorld.html');
$data = $pdf->stream();
return $data;
And the ajax code so far (not working) :
$('body').on('click', '.printInvoice', function () {
var purchase_id = $(this).data("id");
$.ajax({
type: "GET",
url: "/purchases/print" + '/' + purchase_id,
success: function (data) {
console.log(data);
var blob = data;
var link = document.createElement('a');
link.href = window.URL.createObjectURL(blob);
link.download = "PdfName-" + new Date().getTime() + ".pdf";
document.body.appendChild(link);
link.click();
},
error: function (data) {
var data2 = JSON.parse(data.responseText);
alert(data2['errors']);
}
});
});
The code above is generating following error : 'createObjectURL' on 'URL': No function was found that matched the signature provided.
Please help to fix above code, or give a better solution to the problem.
from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2YT71FE
via IFTTT
Aucun commentaire:
Enregistrer un commentaire