Java Reference
In-Depth Information
public static void main(String[] args)
{
new PdfExportDemo().pdfExport(args[0]);
}
}
As we can see in the example, the
JRExporter
implementation used to export
to PDF is
net.sf.jasperreports.engine.export.JRPdfExporter
. We need
to pass it the compiled report in native JasperReports format by setting the
JRExporterParameter.JASPER_PRINT
parameter to the appropriate instance of
net.sf.jasperreports.engine.JasperPrint
.
Since in this case we are saving the report to disk, we set the output file name to the
report name. The only difference is we substitute the file extension to
.pdf
.
The code above will generate a PDF that looks like the following screenshot: