繁体   English   中英

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

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

Java Web应用程序安装在服务器中。 客户端可以使用浏览器通过URL访问应用程序。 应用程序需要与直接连接到客户端的本地打印机或网络打印机进行通信,并在A4纸上打印pdf文件。

这里的打印操作是自动完成的,无需用户交互。 用户只需单击打印按钮,我们需要在客户端机器中找到默认的打印设置,并在该打印机的A4纸张中打印pdf文件。

多个客户端计算机和多个基于用户设置的默认打印机。

如何使用Java或JavaScript?

您可以在window对象上使用方法print

print()方法打印当前窗口的内容。

print()方法打开“打印”对话框,允许用户选择首选打印选项。

用法示例:

 <!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