Jump to content

Client-side printing


dnvsrikanth

Recommended Posts

Hi all,

 

I am using JasperReports to generate reports in my application. I have a requirement in my application in which if a user clicks on print button, the report is to be printed on the printer which is located on client-side network. I am using the following code to do this:

 

 

Code:

PrintRequestAttributeSet printRequestAttributeSet = new HashPrintRequestAttributeSet();
printRequestAttributeSet.add(MediaSizeName.ISO_A4);

PrintServiceAttributeSet printServiceAttributeSet = new HashPrintServiceAttributeSet();
JRPrintServiceExporter printExporter = new JRPrintServiceExporter();

printExporter.setParameter(JRExporterParameter.JASPER_PRINT , jasperPrint);
printExporter.setParameter(JRPrintServiceExporterParameter.PRINT_REQUEST_ATTRIBUTE_SET, printRequestAttributeSet);
printExporter.setParameter(JRPrintServiceExporterParameter.PRINT_SERVICE_ATTRIBUTE_SET, printServiceAttributeSet);
printExporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PAGE_DIALOG, Boolean.FALSE);
printExporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PRINT_DIALOG, Boolean.FALSE);

printExporter.exportReport();

 

 

But the report is not getting printed on client-side printer :( Can anyone tell me what's wrong in this case...waiting for ur quick replies.

 

 

Thanks in Advance

DNV Srikanth

Link to comment
Share on other sites

  • Replies 7
  • Created
  • Last Reply

Top Posters In This Topic

I assume that the Java code that you posted is called from a servlet (either directly or indirectly via a MVC framework). Hence the code will be executed in the servlet container on the server machine. The client printer is not accessible from the server machine, therefore what you are trying to do doesn't make sense from an architectural point of view.

 

If you want to print on the client printer, and you intend to use JasperReports/Java printing, you'll need to execute some Java code on the client machine, i.e. in an applet. Otherwise, you should choose a different printing mechanism such as browser printing, PDF printing, etc.

 

Regards,

Lucian

Link to comment
Share on other sites

Hi lucianc,

 

 

Thanx for ur reply.

 

 

I am using JSF, Spring, Hibernate in my application.

 

 

Can you please explain me the other alternative what you have told.. I'll be done with all functionalities in my application if this is done.

 

 

Thanks in Advance

DNV Srikanth

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...