- Type Parameters:
R- the export result type
Applied by JasperReports.export(JRReport, JRExport), which runs the export wherever the
report is filled. Filling a report through an EntityConnection runs it on the server, so a
report exported to PDF reaches the client as bytes, which no reporting engine is required
to read.
ReportType<Map<String, Object>, byte[]> REPORT = reportType("customer_report");
add(REPORT, export(classPathReport(Store.class, "customer_report.jasper"), PDF));
Exports beyond the ones defined here are lambdas, JasperReports exporters all following the same shape:
JRExport<byte[]> xlsx = print -> {
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
JRXlsxExporter exporter = new JRXlsxExporter();
exporter.setExporterInput(new SimpleExporterInput(print));
exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(bytes));
exporter.exportReport();
return bytes.toByteArray();
};
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final JRExport<byte[]> Exports to PDF.static final JRExport<net.sf.jasperreports.engine.JasperPrint> The identity export, the filled report itself.static final JRExport<byte[]> Serializes the filled report to bytes, reconstructed withJasperReports.loadPrint(byte[]).Exports to the JasperReports XML print format. -
Method Summary
-
Field Details
-
PRINT
The identity export, the filled report itself.Requires JasperReports wherever the result is received,
JasperPrintbeing a JasperReports type, serialized when the report is filled through a remote connection. -
SERIALIZED
Serializes the filled report to bytes, reconstructed withJasperReports.loadPrint(byte[]).The
JasperPrintitself, unlikePRINT, but carried as abyte[], which any connection transfers, a JSON one included, where aJasperPrintcannot go. A client with the reporting engine, one displaying reports with aJRViewer, can therefore keep filling them to aJasperPrintover any connection, reconstructing it from the bytes:ReportType<Map<String, Object>, byte[]> REPORT = reportType("customer_report"); add(REPORT, export(classPathReport(Store.class, "customer_report.jasper"), SERIALIZED)); //client side, with the engine on hand JasperPrint print = loadPrint(connection.report(REPORT, parameters));The bytes are the report's own Java serialization, so a client reconstructing them needs the
net.sf.jasperreports.engine.**classes allowed by any deserialization filter it applies, the same classes a server loading a.jasperfile needs.- See Also:
-
PDF
Exports to PDF.Requires the
net.sf.jasperreports:jasperreports-pdfartifact, which is not a dependency of this plugin. It registers itself through ajasperreports_extension.propertiesresource, which is scanned off the classpath, so nothing requires its module and it is neither resolved on the module path nor included in a jlink image unless named explicitly, via--add-modules net.sf.jasperreports.pdf. A missing extension surfaces as aReportExceptionwhen the report is filled. -
XML
Exports to the JasperReports XML print format.
-
-
Method Details
-
export
R export(net.sf.jasperreports.engine.JasperPrint print) throws net.sf.jasperreports.engine.JRException - Parameters:
print- the filled report to export- Returns:
- the exported report
- Throws:
net.sf.jasperreports.engine.JRException- in case of an exception
-