Jump to content

I have a problem in generating the report in pdf


rajesh_mwar1

Recommended Posts

JasperReport oJasperReport = JasperCompileManager.compileReport(reportSource);

JasperPrint oJasperPrint = JasperFillManager.fillReport(oJasperReport, oParms, iConn);

JasperExportManager.exportReportToPdfFile(oJasperPrint, reportDest);

 

Hi,

the above code is used by me..Where "reportDest" ia a path to store the generated pdf.Upto this Ok.But IF

pdf in a "reportDest" is showing the same result for different "Where" Conditions in my query..

So wht i want is i dont want the genrated pdf to be put put in a "reportDest" and i directly want pdf to be generated and should be run in my browser...

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

This may help u....

U have execute the query from jsp side or what ever and pass the JRDataSource to So that u can get the dynamic data in the pdf. This code it'll will display the pdf in the browser.

File reportFile = new File("Test.jasper");

JasperReport jasperReport = JasperReport)JRLoader.loadObject(reportFile.getPath());

Map param = (Map)session.getAttribute("param");

JasperPrint jasperPrint = (JasperPrint) JasperFillManager.fillReport(jasperReport,param, JRDataSource);

JRPdfExporter exporter = new JRPdfExporter();

 

response.setContentType("application/pdf");

ServletOutputStream ouputStream = response.getOutputStream();

exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);

exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, ouputStream);

exporter.exportReport();

ouputStream.flush();

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...