Hey JR Community,
any hint how to solve my following problem would be great:
I have standalone Java Application (openJDK 11.0.2) with JR 6.8.0. I wand to create a PDF with a basic structure:
- <dynamic content>,
The dynamic content contains 1 to many pages which are designed equally (same report, different parameters).
How can Ì achieve to create such a PDF usind predesigned reports (e.g. basic-report.jasper and dynamic-content.jasper) and java code only? Especially adding x pages where every page depends on the same report.
Any help/hint would be great!
Best regards from Hamburg,
Hi, will the Title and also the TOC also be part of a JasperReport or is this some content you will generate manually with iText or whatever?
I'm not familiar with the (newer) Book logic as I was stuck several years to an older version of iReport/JapserReports (5.5.1) at my old company - but I've read something about generating TOCs etc with the later versions of JasperReports (6.x) . Perhaps you could start "googling" for that also.
Otherwise you could generate several so called JrPrint Objects (filled JasperReports) and combine them into one PDF File using the JRExporter Util (no matter if it's X-times the same report or perhaps also different reports) :
something like this:
JRExporter exporter = new JRPdfExporter(); exporter.setParameter(JRPdfExporterParameter.JASPER_PRINT_LIST, yourPreFilledJasperPrintList); exporter.setParameter(JRPdfExporterParameter.OUTPUT_STREAM, yourTargetPDFStream); exporter.exportReport();
Another solution could also be, to combine several reports into one "big" report using SubReports... so that ALL your static content and dynamic content is just one call to the FillManager and just one simple export call to the JRPdfExporter. You could also create at runtime via API an JRDesign and put several SubReports together using just the Jasper-API ... so many leads to Rome :-)
just give it a try.
hth + regards the river Elbe down from Dresden ;-)
Hey All, hey C-Box,
finally I managed to solve my problem (at least partially). What I did was:
- Created a Report-Book, saved as JRXML within my resources
- Created a bunch of SubReports, saved as JASPER within my resources
- NOTE: SubReports were not embedded inside my Report-Book
- Load Report-Book as JasperDesign
- In preferred Order and for each SubReport:
- Add JRDesignPart with SubReportPart to DetailsSection of ReportBook
- Load SubReport.JASPER as JasperReport
- Add SubReport to Parameters
- Add Custom Parameter Map as Parameter for Subreport