aspose file tools*
The moose likes Unified Printing API - JSR6 and the fly likes Printing Jasper Reports in Local and Network Printer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java JSRs » Unified Printing API - JSR6
Bookmark "Printing Jasper Reports in Local and Network Printer" Watch "Printing Jasper Reports in Local and Network Printer" New topic
Author

Printing Jasper Reports in Local and Network Printer

Anant K Agarwal
Greenhorn

Joined: Mar 01, 2012
Posts: 9
Hello Ranchers,

I have a web application running using Struts2 framework. The requirement is

a. User's perform various transactions.
b. Each transaction needs to be printed.
c. Each transaction has a jrxml attached to it (configured using a property file).
d. Once the user completes the transaction, print should happen seamlessly.

Printing can be done in two ways.
1. If a Network printer is configured for that particular user and the transaction, the print will be fired in that particular network printer.
2. If a Local Printer (attached to the desktop) is configured for the user, the print should be fired in his local printer.

I have achieved the first part (network) printing using Java Print Services. But need a solution around the local printing requirements.
For local printing, once the user completes the txn, the report should be printed to his local printer, without any user intervention.
User may have more than one printer installed to his local machine, based on the txn type routing will happen to the appropriate local printer.

Any help or suggestions would be of great help.
Luan Cestari
Ranch Hand

Joined: Feb 07, 2010
Posts: 163

The only way you could achieve the printing part is with an applet running in the client. To be the most seamless, I would make the applet not visible and using JSObject (http://docs.oracle.com/javase/6/docs/technotes/guides/plugin/developer_guide/java_js.html) I would make the authentication only be possible if the user authorize to the applet to run. To make the communication between the server side (Servlet/Struts2), you need to pass the session id as parameter to the applet. Another problem that you could face using the Java Print API is if the printer is available and can print the file you want.

Best Regards,
Luan

Anant K Agarwal wrote:Hello Ranchers,

I have a web application running using Struts2 framework. The requirement is

a. User's perform various transactions.
b. Each transaction needs to be printed.
c. Each transaction has a jrxml attached to it (configured using a property file).
d. Once the user completes the transaction, print should happen seamlessly.

Printing can be done in two ways.
1. If a Network printer is configured for that particular user and the transaction, the print will be fired in that particular network printer.
2. If a Local Printer (attached to the desktop) is configured for the user, the print should be fired in his local printer.

I have achieved the first part (network) printing using Java Print Services. But need a solution around the local printing requirements.
For local printing, once the user completes the txn, the report should be printed to his local printer, without any user intervention.
User may have more than one printer installed to his local machine, based on the txn type routing will happen to the appropriate local printer.

Any help or suggestions would be of great help.


Please, visit me for some cool tech post at www.ourdailycodes.com
ramita vijay
Greenhorn

Joined: Apr 22, 2009
Posts: 1
Hi Anant,

I am working on a similar solution. I have a Java Web Application with Struts, Spring and Hibernate.
I want to send printout of receipts (PDF generated by JasperReport Library) to a network printer.
My application is running in JBoss AS 7 and deployed on a Linux server.

1- How can I print to a network printer from my server? Could you please send me some code
2- Did you try the applet solution?

Regards,
Ramita Vijay
 
 
subject: Printing Jasper Reports in Local and Network Printer