2006 IR Open Dicussion Posted August 27, 2006 Share Posted August 27, 2006 By: karibouxe - karibouxe open pdf in my browser IE 2006-05-19 02:19 Hi, When do i want create my pdf report. I write this ligne in my jsp: OutputStream outStr = response.getOutputStream(); JasperExportManager.exportReportToPdfStream(jasperPrint,outStr); But it's acrobat that open my pdf report and my browser IE is blank. I want to open my report in my browser IE. Have you any idea? Thanks for your advices By: Adeel - revenger55 RE: open pdf in my browser IE 2006-05-19 03:35 It is very Easy: (considering the scenario) when u click on "Generate Report" button call java scripting function window.open ('/file.jsp?param1=val¶m2=val2','','toolbar=yes') where file.jsp is the jsp(make sure the path is right) that creates the pdf report and send the parameters if required along with the url this will open a window of IE in which acrobat is present Hope this will help By: karibouxe - karibouxe RE: open pdf in my browser IE 2006-05-19 05:50 thanks but it don't work. in my format.jsp, i choose my format of my report: and in my generate.jsp, i've the code to generate my rapport. With that, the HTML is oki: exporter.setParameter(JRHtmlExporterParameter.OUTPUT_STREAM, outStr); but my pdf is always open acrobat :( i don't see with this ligne. JasperExportManager.exportReportToPdfStream(jasperPrint,outStr); How open it in my browser ie? Do I may obligatory save my report in my hard disk to open it on my browser? Any hints? By: Sanjeev Saha - sanjeevsaha RE: open pdf in my browser IE 2006-05-19 06:00 Try setting "Content-Disposition: INLINE" in the response header. This should (theoretically) invoke the Acrobat reader plugin provided all the other header variables are set appropriately. hth, Sanjeev By: karibouxe - karibouxe RE: open pdf in my browser IE 2006-05-19 06:36 I try this: response.setContentType(CONTENT_TYPE_PDF); response.setHeader("Content-disposition", "inline; filename=???????"); JRPdfExporter exporter = new JRPdfExporter(); exporter.setParameter(JRHtmlExporterParameter.CHARACTER_ENCODING, "iso-8859-1"); exporter.setParameter(JRPdfExporterParameter.JASPER_PRINT, jasperPrint); exporter.setParameter(JRPdfExporterParameter.OUTPUT_STREAM, response.getOutputStream()); exporter.exportReport(); i don't know what i write in line "setHeader" my pdf is not existing physically. is ti a problem? Or else what can i write? thanks for any advice By: Sanjeev Saha - sanjeevsaha RE: open pdf in my browser IE 2006-05-19 06:54 Give some dummy name for the file name, say response.setHeader("Content-disposition", "inline; filename=test.pdf"); The name will only be used if someone tries to save the file once it has been displayed within the browser. hth, Sanjeev By: karibouxe - karibouxe RE: open pdf in my browser IE 2006-05-19 07:13 it don't work. It don't open with ie but always adobe reader Look my code: }else if (formatRapport.equals("pdf")){ //JasperExportManager.exportReportToPdfStream(jasperPrint,outStr); response.setContentType("application/pdfred; charset=windows-1252"); response.setHeader("Content-disposition", "inline; filename=test.pdf"); JRPdfExporter exporter = new JRPdfExporter(); exporter.setParameter(JRHtmlExporterParameter.CHARACTER_ENCODING, "iso-8859-1"); exporter.setParameter(JRPdfExporterParameter.JASPER_PRINT, jasperPrint); exporter.setParameter(JRPdfExporterParameter.OUTPUT_STREAM, response.getOutputStream()); exporter.exportReport(); } i'm get demoralized :'-( I've not idea By: Sanjeev Saha - sanjeevsaha RE: open pdf in my browser IE 2006-05-19 07:22 does response.setContentType("application/pdf"); result in the same thing? -Sanjeev By: karibouxe - karibouxe RE: open pdf in my browser IE 2006-05-19 07:35 yes, it's the same result. but it work in mozilla. I prefer it work in IE. I must be read, it's a bug between acrobat and ie. It's called "blank page syndrome". I think that we must wait :-S tanks for your help Sanjeev, Francis By: Sanjeev Saha - sanjeevsaha RE: open pdf in my browser IE 2006-05-19 08:08 It is in fact a bug (or expected behavior as is always the case) with IE. When using content-disposition, IE receives the data and tries to start the plug-in associated with it. Then, for some unknown reason it forget's the content-type and requires another call to be made just to retrieve the content type. You can read up on it. It's pretty interesting. Just one more thing. If you start Adobe in the background before you run the report, does it still display a blank page? -Sanjeev By: Sanjeev Saha - sanjeevsaha RE: open pdf in my browser IE 2006-05-19 08:14 Setting response.setContentLength() to the size of the jasperPrint object is another recommended step for handling content-disposition for IE. hth, Sanjeev By: karibouxe - karibouxe RE: open pdf in my browser IE 2006-05-19 08:37 - If you start Adobe in the background before you run the report, does it still display a blank page? yes, it display always a blank page. for the second request, response.setContentLength(?????) What do i write? A hint? By: karibouxe - karibouxe RE: open pdf in my browser IE 2006-05-19 09:21 response.setContentLength() is maybe the solution but in jsp, i haven't the length of my report. when i write a random number: for example 1000: my browser display: Char 49/Encoding<>/Widths[556]>> endobj 6 0 obj<> endobj 8 0 obj<> endobj 9 0 obj<> endobj 10 0 obj<> endobj 11 0 obj<> endobj xref 0 12 0000000000 65535 f 0000000543 00000 n 0000000751 00000 n 0000000838 00000 n 0000000930 00000 n 0000000015 00000 n 0000001076 00000 n 0000000717 00000 n 0000001126 000001210 00000 n 0000001267 00000 n trailer <<1facf254fb5d50f30c16e29ddcdd7e74>]/Root 10 0 R/Size 12/Info 11 0 R>> startxref 1464 %%EOF By: Sanjeev Saha - sanjeevsaha RE: open pdf in my browser IE 2006-05-20 19:16 Instead of JRExporterParameter.OUTPUT_STREAM = response.getOutputStream(), set it to a ByteArrayOutputStream. That'll allow you to get the length of the report from there. After that, you just need to write the contents of the ByteArrayOutputStream to the response. hth, Sanjeev By: Nitz - nitzien RE: open pdf in my browser IE 2006-05-21 04:47 Please forgive me, if I sound very stupid.. What i understand is that when you print a report in pdf, its acrobat that opens ur report and IE is blank.. This doesn't seems to be problem of jasperreport but issue with ur acrobat preferences. In Acrobat (7.0), Go to Edit> Preference > Internet and check if the flag "display in browser" is checked or unchecked.. Nitin nitzien@gmail.com By: karibouxe - karibouxe RE: open pdf in my browser IE 2006-05-22 01:13 to nitzien: you're understand my problem, but all flag checked. It's not the solution, thanks for your help. to Sanjeev: How can i transform this: OutputStream outStr = response.getOutputStream(); ... exporter.setParameter(JRHtmlExporterParameter.OUTPUT_STREAM, outStr); i'm difficulty in writing a new type ByteArrayOutputStream. By: karibouxe - karibouxe RE: open pdf in my browser IE 2006-05-22 01:53 I try this solution but it don't work. }else if (formatRapport.equals("pdf")){ response.setContentType("application/pdf; charset=windows-1252"); JRPdfExporter exporter = new JRPdfExporter(); exporter.setParameter(JRPdfExporterParameter.CHARACTER_ENCODING, "iso-8859-1"); exporter.setParameter(JRPdfExporterParameter.JASPER_PRINT, jasperPrint); exporter.setParameter(JRPdfExporterParameter.OUTPUT_STREAM, bArray); exporter.exportReport(); JRPdfExporter exporter2 = new JRPdfExporter(); response.setContentLength(bArray.size()); exporter2.setParameter(JRPdfExporterParameter.JASPER_PRINT,jasperPrint); exporter2.setParameter(JRPdfExporterParameter.CHARACTER_ENCODING, "iso-8859-1"); exporter2.setParameter(JRPdfExporterParameter.OUTPUT_STREAM,response.getOutputStream()); exporter2.exportReport(); } my pdf is open by acrobat reader and not by IE. another solution? By: invisible - vohinh RE: open pdf in my browser IE 2006-05-22 03:04 Hi, I'm working with displaying report in pdf format in browser like you, maybe you can try as follow: byte[] bytes = JasperRunManager.runReportToPdf(path, params, conn); response.setContentLength(bytes.length); ServletOutputStream outputStream = response.getOutputStream(); outputStream.write(bytes, 0, bytes.length); outputStream.flush(); outputStream.close(); I compiled jrxml file to jasper file by iReport and succeed with old version, but when I use newest version (1.2.2), it always shows the error about incompatible serialVersionUID: stream class = 607, local class = 604. By: karibouxe - karibouxe RE: open pdf in my browser IE 2006-05-22 03:20 i try your code but my browser IE is blank and acrobat reader open the report. It's very strange bacause on Mozilla, it work. Thanks for your help. By: Ionut Nedelcu - ionutned RE: open pdf in my browser IE 2006-05-22 07:07 Hello Most likely this is a IE related problem, and has nothing to do with content length or disposition. The JasperReports team never had such problems with PDF, the only export that needed content length was the XLS. So, since it works in Mozilla, probably it's the IE plugin for Adobe that's causing the problem. I had the same problem on my home computer, although the same code worked on other computers. By: karibouxe - karibouxe RE: open pdf in my browser IE 2006-05-23 00:34 oki! i keep watch on this problem. And wait :-( Thanks for your help. By: invisible - vohinh RE: open pdf in my browser IE 2006-05-23 06:19 Yes, I think it's IE plugin for Adobe problem, now after replacing all old libraries with the newest ones, I can display report in pdf normaly on both IE and Firefox browsers By: karibouxe - karibouxe RE: open pdf in my browser IE 2006-05-23 06:30 What are the old librairies you replaced? By: gio1313 - gio1313 RE: open pdf in my browser IE 2006-05-23 09:31 Hi, when i want create a pdf file my browsers (both)EI and Firefox browsers send me this error: java.lang.Error: Problema di compilazione non risolto: Impossibile risolvere PdfContentByte.LINE_CAP_PROJECTING_SQUARE net.sf.jasperreports.engine.export.JRPdfExporter.exportReportToStream(JRPdfExporter.java:394) net.sf.jasperreports.engine.export.JRPdfExporter.exportReport(JRPdfExporter.java:250) net.sf.jasperreports.engine.JasperExportManager.exportReportToPdf(JasperExportManager.java:188) reportRun.doGet(reportRun.java:161) javax.servlet.http.HttpServlet.service(HttpServlet.java:689) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) i have this problem only with pdf exporter. Xls, html,cvs are ok. i use the servlet and my code is : byte[] pdfByteArray = JasperExportManager.exportReportToPdf(jasperPrint); res.setContentType("application/pdf;charset=windows-1252"); res.setHeader("Content-disposition","inline; filename=Prova.pdf"); res.setContentLength(pdfByteArray.length); ServletOutputStream out = res.getOutputStream(); out.write(pdfByteArray, 0, pdfByteArray.length); out.flush(); out.close(); Thanks and sorry for my english :) By: Lucian Chirita - lucianc RE: open pdf in my browser IE 2006-05-23 10:23 Hi What iText version do you have on your classpath? JR versions >= 1.1.1 need iText >= 1.02(b). The requirements page states that iText >= 1.01 is needed, we'll have to fix the discrepancy. Regards, Lucian By: Lucian Chirita - lucianc RE: open pdf in my browser IE 2006-05-24 00:23 iText 1.01 compatibility has been restored on CVS. The fix will be part of the next release. Regards, Lucian By: gio1313 - gio1313 RE: open pdf in my browser IE 2006-05-23 10:56 Hi, i use jasperreports-0.6.5 and itext-1.3.1 By: Lucian Chirita - lucianc RE: open pdf in my browser IE 2006-05-24 00:10 Are you sure about this? The stack trace you posted does not correspond to 0.6.5 sources (you can check this yourself). Are you using modified sources? By: gio1313 - gio1313 RE: open pdf in my browser IE 2006-05-24 03:02 Thanks lucianc...i used another version!Now it's ok!!!!!! 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