简体   繁体   English

从服务器端触发网页打印

[英]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.

相关问题 从服务器端脚本中打印出Java Web应用程序 - print out of java web application from server side script 在java web应用程序中如何从客户端打印服务器文件 - In java web application how to print server file from client side 服务器端Web应用程序中的页面重定向 - Page redirecting in a web application at server side 从移动设备打印4英寸打印机上的网页 - Print Web page on 4 inch printer from mobile 从没有小程序的网页访问客户端的扫描仪 - Accessing scanner at client side from a web page without applet JAX-RS端点触发服务器端操作 - JAX-RS Endpoint triggering server-side actions 如何从Java Web服务器打印Microsoft Word文档? - How to print a microsoft word document from Java web server? 如何使用WebDriver将副标题数据与Web上的边表数据一起打印到excel - How to print column headers along side table data from web to excel with webdriver 我需要更改网页的内容而不刷新服务器端发生更改的位置 - I need to change the content of a web page without refreshing where the change happens in the server side 当我使用services.msc启动服务器时,打印在tomcat中不起作用(从客户端我们无法打印) - Printing is not working in tomcat, when i start server with services.msc(From client side we could not print )
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM