如何直接从Web应用程序将PDF打印到客户端计算机默认打印机 [英] How can I print a PDF directly from a web app to a client machines default printer

查看:468
本文介绍了如何直接从Web应用程序将PDF打印到客户端计算机默认打印机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个存储pdf文档的服务器。该服务器托管一个网站,以便用户可以在线访问他们的文档。

我希望能够点击一个通常在浏览器中打开文档的链接,而不是显示我想要的文档它会自动打印到客户端默认打印机,而不会弹出任何打印机对话框窗口。

我需要这个才能在Chrome中运行。

我发现可能存在安全隐患,但我相信它是可行的。



我尝试过的:



我搜索了几个小时并尝试了很多不同的东西。



我有尝试了Print.js,但它打开了一个对话框。



我最接近的是使用此链接中的解决方案。唯一的问题是它似乎是特定于Firefox。

打印时没有打印确认对话框。 •mozillaZine论坛 [ ^ ]

I have a server that stores pdf documents. A website is hosted from this server so users can access their documents online.
I want to be able to click a link that would normally open the document in the browser, but instead of displaying the document I want it to automatically print to the clients default printer without any printer dialog windows popping up.
I need this to work in Chrome.
I realize there may be security risks involved, but I do believe it is do-able.

What I have tried:

I have searched for hours and tried many different things.

I have tried Print.js, but it opens a dialog.

The closest I have come is using the solution in this link. Only problem is it seems to be Firefox specific.
Printing without print confirmation dialog. • mozillaZine Forums[^]

推荐答案

您不能:您无法直接访问任何客户端硬件,也无法以任何方式控制您从服务器提供的文档发生的情况。客户端浏览器完全控制发生的事情:打开,保存,打印;这一切都取决于用户在其特定浏览器中选择的设置。



想一想:如果你能做到,那么任何人都可以 - 而且我们已经够了垃圾传真当天回来了,我们不希望垃圾网站打印输出......:笑:
You can't: you have no direct access to any client hardware, and cannot control in any way what happens to a document you provide from the server. The client browser is in complete control of what happens to it: opened, saved, printed; it all depends on the settings the user has selected in his specific browser.

Think about it: if you could do it, so could anyone - and we had enough of spam faxes back in the day, we don't want spam website printouts ... :laugh:


Quote:

我意识到可能存在安全风险,但我相信它是可行的。

I realize there may be security risks involved, but I do believe it is do-able.



简答:出于安全原因禁止使用,否则任何被黑客入侵的页面都会被禁止开始打印垃圾。

即使你找到了办法,它也是黑客的东西,并且将特定于浏览器和版本,并且可能随时出现。


Short answer: it is forbidden for security reasons, otherwise any hacked page would start print garbage.
Even if you find ways to do it, it is hacker stuff and will be specific to browser and version and may disapeer anytime.


这篇关于如何直接从Web应用程序将PDF打印到客户端计算机默认打印机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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