简体   繁体   中英

Communicate with client side printer and print A4 sheet

Java web application installed in server. The client's can access the application using browser through 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.

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.

Multiple client machine and multiple default printer based on user setup.

How to do it using Java or JavaScript?

You can just use method print on window object.

The print() method prints the contents of the current window.

The print() method opens the Print Dialog Box, which lets the user to select preferred printing options.

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> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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