Javascript以编程方式调用“另存为PDF” Chrome对话框打印功能 [英] Javascript call programmatically the "Save as PDF" feature of Chrome dialog print

查看:3143
本文介绍了Javascript以编程方式调用“另存为PDF” Chrome对话框打印功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当您进入打印对话框或window.print()时,Google Chrome可以选择另存为PDF。
用户需要在对话框中选择此选项以将页面保存为pdf。



我可以调用一些函数或将参数传递给chrome中的window.print(),以便将页面打印为pdf,而不显示打印对话框?



有什么想法?

解决方案

到window.print();并强制它打印pdf,除非在客户端浏览器上已经存在pdf驱动程序插件。有Firefox和IE插件(分别是JS打印设置和MeadCo脚本)。



你可能想看看 MrRio / jsPDF ,一个在客户端JS生成PDF文件的工具。


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?

解决方案

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.

这篇关于Javascript以编程方式调用“另存为PDF” Chrome对话框打印功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆