File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Printing Jasper Reports in Local and Network Printer

 
Anant K Agarwal
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 163
C++ Redhat Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
ramita vijay
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Claude Moore
Ranch Hand
Posts: 747
7
IBM DB2 Java Netbeans IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For similar problem, I used to use gsprint port on windows. Gsprint let you to send PDF to a network or local printer, so you may generate via jasper your report,receipes and so on and then invoke gsprint against them.
You may write a simple daemon program which invokes gsprint to avoid calling an external program from within your web app.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic