Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jsPDF not working on Safari

I need to have a button at the end of a HTML page that generates and saves a PDF, so I decided to try jsPDF.

function pdfComprovativo(arg){
    var doc = new jsPDF();
    doc.text(20, 20, 'Hello world!');
    doc.save('Test.pdf');
}

I tested this on several browsers and it's not working for Safari (5.1.7 version).

doc.output('dataurlnewwindow');

It works if I replace the save() with this, but I can't use this solution because of popup blockers.

like image 457
Catpixels Avatar asked Sep 06 '25 03:09

Catpixels


1 Answers

I asked your question on Github, because I had the same the issue. Here is the response of the developer which works for me:

What about doc.output('dataurl'); ?

The PDF is now displayed inline. The user can save it, print it and no new popup is generated.

regards

like image 76
Hannes_hal Avatar answered Sep 07 '25 19:09

Hannes_hal