jsPDF无法在Safari上运行
我需要在生成并保存PDF的HTML页面末尾有一个按钮,所以我决定尝试使用jsPDF。
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');
}
我在几个浏览器上测试了这个并且它不适用于Safari(5.1.7)版本)。
I tested this on several browsers and it's not working for Safari (5.1.7 version).
doc.output('dataurlnewwindow');
如果我用这个替换save(),它可以工作,但我不能使用这个解决方案,因为弹出窗口拦截器。
It works if I replace the save() with this, but I can't use this solution because of popup blockers.
我在Github问了你的问题,因为我有同样的问题。以下是对我有用的开发人员的回复:
I asked your question on Github, because I had the same the issue. Here is the response of the developer which works for me:
doc.output('dataurl')怎么样; ?
What about doc.output('dataurl'); ?
PDF现在以内联方式显示。用户可以保存,打印并且不会生成新的弹出窗口。
The PDF is now displayed inline. The user can save it, print it and no new popup is generated.
问候