dnvsrikanth Posted March 12, 2008 Share Posted March 12, 2008 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 AdvanceDNV Srikanth Link to comment Share on other sites More sharing options...
dnvsrikanth Posted March 13, 2008 Author Share Posted March 13, 2008 can any body help me in this regard??? Link to comment Share on other sites More sharing options...
dnvsrikanth Posted March 13, 2008 Author Share Posted March 13, 2008 bump Link to comment Share on other sites More sharing options...
lucianc Posted March 13, 2008 Share Posted March 13, 2008 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 More sharing options...
dnvsrikanth Posted March 14, 2008 Author Share Posted March 14, 2008 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 AdvanceDNV Srikanth Link to comment Share on other sites More sharing options...
dnvsrikanth Posted March 15, 2008 Author Share Posted March 15, 2008 Hi lucianc, Can u please tell me what is meant by pdf printing. Thanks in AdavanceDNV Srikanth Link to comment Share on other sites More sharing options...
dnvsrikanth Posted March 17, 2008 Author Share Posted March 17, 2008 bump Link to comment Share on other sites More sharing options...
lucianc Posted March 17, 2008 Share Posted March 17, 2008 dnvsrikanth wrote:Can u please tell me what is meant by pdf printing. I meant sending the user PDF report output (by exporting the report to PDF), and letting the user print the report from the PDF viewer. Regards,Lucian Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now