qt4x11 Posted November 9, 2012 Share Posted November 9, 2012 protected static byte[] exportReportToPdf(JasperPrint jasperPrint) throws JRException { JRPdfExporter exporter = new JRPdfExporter(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, baos); exporter.setParameter(JRPdfExporterParameter.PDF_JAVASCRIPT, "this.print({bUI: true,bSilent: false,bShrinkToFit: true});"); exporter.exportReport(); return baos.toByteArray();} We are using code like this to export a pdf from a jasper application. The line exporter.setParameter(JRPdfExporterParameter.PDF_JAVASCRIPT, "this.print({bUI: true,bSilent: false,bShrinkToFit: true});"); adds Javacript to send the pdf document directly to the printer. The expected behavior is that a print dialog will come up with a preview of the pdf document. This works fine most of the time - except I am having problems about one out of every 5-6 times in Internet Explorer 8 and Firefox. What happens is - the print preview dialog with the pdf does not appear or it appears with a blank document in the preview window.) -I've tried a number of different javascripts (different params to this.print() via exporter.setParameter -I've tried setting different response headers such as response.setContentType("application/pdf");response.setHeader("Content-disposition","inline; filename="" + reportName + """);response.setContentLength(baos.size()); these did not seem to help This seems to be an IE and FF issue. Has anyone ever dealt with this problem? I need to get it to work across all browsers 100% of the time. Perhaps a different approach to accomplish the goal of sending the pdf export directly to the printer? or a third party library that will work across browsers? Thanks for any advice. Link to comment Share on other sites More sharing options...
qt4x11 Posted November 19, 2012 Author Share Posted November 19, 2012 Any ideas? I'm still experiencing this problem. Thank you! Link to comment Share on other sites More sharing options...
mujahid.mms Posted December 30, 2013 Share Posted December 30, 2013 Are you getting the dialog box for print on client side or Server Side.If on the client side can you please share your code? Please. 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