Javascript call programmatically the “Save as PDF” feature of Chrome dialog print

北城余情 提交于 2019-11-30 11:51:29

问题


Google Chrome have the option "Save as PDF" when you enter the Print dialog or window.print(). The user need to choice this option in dialog to save the page as pdf.

Can I call some funcion or pass an argument to window.print() in chrome to "print" the page as a pdf without the print dialog appears?

Any ideas?


回答1:


Unfortunately there isn't any param you could pass to window.print(); and force it to print pdf unless there is a pdf driver plugin already present on the client's browser. There are plugins for firefox and IE (JS Print Setup and MeadCo Script respectively).

You may want to look at MrRio/jsPDF, a tool to generate pdf files at client-side JS.



来源:https://stackoverflow.com/questions/22096749/javascript-call-programmatically-the-save-as-pdf-feature-of-chrome-dialog-prin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!