简体   繁体   English

与客户端打印机通信并打印A4纸

[英]Communicate with client side printer and print A4 sheet

Java web application installed in server. Java Web应用程序安装在服务器中。 The client's can access the application using browser through URL. 客户端可以使用浏览器通过URL访问应用程序。 The application need to communicate with local printers or network printers which is directly connected to client and print pdf file in A4 sheet. 应用程序需要与直接连接到客户端的本地打印机或网络打印机进行通信,并在A4纸上打印pdf文件。

Here the print operation done by automatically without user interaction. 这里的打印操作是自动完成的,无需用户交互。 User will just click print button, we need to find the default print setup in client machine and print pdf file in A4 sheet in that printer. 用户只需单击打印按钮,我们需要在客户端机器中找到默认的打印设置,并在该打印机的A4纸张中打印pdf文件。

Multiple client machine and multiple default printer based on user setup. 多个客户端计算机和多个基于用户设置的默认打印机。

How to do it using Java or JavaScript? 如何使用Java或JavaScript?

You can just use method print on window object. 您可以在window对象上使用方法print

The print() method prints the contents of the current window. print()方法打印当前窗口的内容。

The print() method opens the Print Dialog Box, which lets the user to select preferred printing options. print()方法打开“打印”对话框,允许用户选择首选打印选项。

Example of usage: 用法示例:

 <!DOCTYPE html> <html> <body> <p>Click the button to print the current page.</p> <button onclick="myFunction()">Print this page</button> <script> function myFunction() { window.print(); } </script> </body> </html> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM