Currently I am developing an application which will show BIRT Report when user clicks preview report button.
Following is my java code for pdf generation.
private String rptFileLocation = "D:/Java Development/Projects/CustomerSubReport.rptdesign";
private String pdfDownloadLocation = "E://logs/customer_subreport.pdf";
public void previewReportInPdf(String rptFileLocation, String pdfDownloadLocation) throws EngineException{
IReportEngine engine = null;
EngineConfig config = null;
try{
config = new EngineConfig();
config.setLogConfig("E://logs", Level.FINEST);
Platform.startup(config);
IReportEngineFactory factory =
(IReportEngineFactory)Platform.createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY);
engine = factory.createReportEngine(config);
IReportRunnable design = null;
design = engine.openReportDesign(rptFileLocation);
IRunAndRenderTask task = engine.createRunAndRenderTask(design);
PDFRenderOption options = new PDFRenderOption();
options.setOutputFileName(pdfDownloadLocation);
options.setOutputFormat("pdf");
task.setRenderOption(options);
task.run();
task.close();
engine.destroy();
}
catch(Exception ex){
ex.printStackTrace();
}
finally{
Platform.shutdown();
}
}
Following is the jsf code segment
<h:commandButton value="Preview Report(PDF)" action="#{birtBean.previewReportInPdf()}" ></h:commandButton>
Currently the pdf is downloading in the specified path of my disk. I want to display the report as pdf in new browser tab. How can I achieve this?