[英]Triggering a web page print from server side
This question might be very basic. 这个问题可能非常基础。 Till now I thought a command to print a webpage can only be initiated at the client side.
到目前为止,我认为打印网页的命令只能在客户端启动。
(window.print when using javascript) (使用javascript时的window.print)
But I came across http://juixe.com/techknow/index.php/2008/01/17/print-a-pdf-document-in-java/ which states about printing using Java. 但我遇到了http://juixe.com/techknow/index.php/2008/01/17/print-a-pdf-document-in-java/ ,其中说明了使用Java进行打印。 I think this seems to be related to some desktop client and the same may not be possible in a web client.
我认为这似乎与某些桌面客户端有关,并且在Web客户端中可能无法实现。 Can anyone confirm and explain this?
谁能确认并解释这个?
You can't execute server side code on the client, so the only way to do it in browser is through javascript or using plugins/flash/java applets. 您无法在客户端上执行服务器端代码,因此在浏览器中执行此操作的唯一方法是通过javascript或使用plugins / flash / java小程序。
You could print using java, but for that java needs to run on the client. 您可以使用java进行打印,但是需要在客户端上运行java。
A website can ask the browser to open its print dialog (Google Maps does this on the "print directions" page, for example), but it can't actually force the browser to print anything. 网站可以要求浏览器打开其打印对话框(例如,谷歌地图在“打印方向”页面上执行此操作),但它实际上无法强制浏览器打印任何内容。 (If it could, you can be sure that advertisers would use it to print ads on your printer.)
(如果可以,您可以确定广告客户会使用它在您的打印机上打印广告。)
A Java application running locally with sufficient permissions can print, just like any other desktop application. 与任何其他桌面应用程序一样,可以打印具有足够权限的本地Java应用程序。 That has nothing to do with web pages.
这与网页无关。
Don't confuse Java and JavaScript. 不要混淆Java和JavaScript。 When trying to use Java within a browser, you'd have to look into using applets.
在浏览器中尝试使用Java时,您必须考虑使用applet。 A Java applet could definitely be used to do the kind of work you'd normally have a rich client do from within a browser.
Java applet肯定可以用来完成您在浏览器中通常有富客户端所做的工作。
Java applets could also receive events sent out from a server via sockets or some other mechanism, although I'm not certain if security constraints would allow it. Java applet还可以通过套接字或其他一些机制接收从服务器发出的事件,尽管我不确定安全约束是否允许它。 Also seems a bit of a roundabout way to do things.
也似乎有点迂回做事的方式。
Remember that web browsing is a client-side-driven affair. 请记住,网页浏览是一个客户端驱动的事情。 There's some push models in certain infrastructures (I believe it's possible using JavaServer Faces).
在某些基础架构中有一些推送模型(我相信它可以使用JavaServer Faces)。 But those are probably just a sort of polling mechanism initiated by the client that is abstracted away to look like a server-side push.
但这些可能只是一种由客户端发起的轮询机制,它被抽象出来,看起来像服务器端推送。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.