Jasper PDF export printing in Internet Explorer


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);
              "this.print({bUI: true,bSilent: false,bShrinkToFit: true});");
  return baos.toByteArray();
We are using code like this to export a pdf from a jasper application.
The line
             "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.setHeader("Content-disposition","inline;  filename=\"" 
                   + reportName 
                   + "\"");
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.
qt4x11's picture
Joined: Oct 5 2012 - 8:58pm
Last seen: 9 years 8 months ago
Any ideas? I'm still experiencing this problem. Thank you!
qt4x11 - 10 years 4 months ago

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.


mujahid.mms - 9 years 3 months ago

0 Answers:

No answers yet