2
I am trying to download pdf files using the library mpdf.
Calling the php page in the browser it works normally.
Example:
require_once 'mpdf/mpdf.php';
$mpdf = new mPDF();
$boleto = '<h3>Boleto</h3>';
$mpdf->WriteHTML($boleto);
$mpdf->Output('teste.pdf',"D");
Now if I try to call it an html page using ajax its return looks like this:
As I call Ajax:
var salvarBoleto = function(parcelas) {
$.ajax({
url: boletoUrl,
data: {
"acao": "salvarBoleto",
"parcelas": parcelas
},
dataType: 'json',
type: 'POST',
success: function(data) {
},
error: function(data) {
console.warn("mostrar msg de erro");
}
});
};
Normally I call a new tab to issue the pdf, but in this case I would like to do it on the ajax page.
You can post the JS snippet that calls the ajax?
– Laerte
@Laerte ready :)
– Gabriel Rodrigues
@Gabrielrodrigues, remember you solved this ?
– Wagner Fillio
@Wagnerson if I remember well I had to open the file in an iframe to download on the same page, then I created an invisible iframe and acted his src.
– Gabriel Rodrigues