Chandu Chandu - 4 months ago 18
Java Question

How to integrate JasperViewer with Swing based application

can I integrate the JasperReports Viewer to my Swing application as like if I click on view report button from my application then viewer should be opened. If so could you advise me with code snippet for this integration and in this viewer the save as type should be restricted for PDF only rather than every other download option filter available.

Please advice me in this regard.

Answer

Yes you can, Jasper Reports come with a usable (albeit simple) report viewer:

...
           JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
           JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport...);
           JasperViewer.viewReport(jasperPrint);
...

The last line is what displays the viewer. I'm not sure if you can restrict the available output formats to PDF, though.

Comments