Search in sources :

Example 1 with SimplePdfReportConfiguration

use of net.sf.jasperreports.export.SimplePdfReportConfiguration in project tutorials by eugenp.

the class SimpleReportExporter method exportToPdf.

public void exportToPdf(String fileName, String author) {
    // print report to file
    JRPdfExporter exporter = new JRPdfExporter();
    exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
    exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(fileName));
    SimplePdfReportConfiguration reportConfig = new SimplePdfReportConfiguration();
    reportConfig.setSizePageToContent(true);
    reportConfig.setForceLineBreakPolicy(false);
    SimplePdfExporterConfiguration exportConfig = new SimplePdfExporterConfiguration();
    exportConfig.setMetadataAuthor(author);
    exportConfig.setEncrypted(true);
    exportConfig.setAllowedPermissionsHint("PRINTING");
    exporter.setConfiguration(reportConfig);
    exporter.setConfiguration(exportConfig);
    try {
        exporter.exportReport();
    } catch (JRException ex) {
        Logger.getLogger(SimpleReportFiller.class.getName()).log(Level.SEVERE, null, ex);
    }
}
Also used : SimplePdfExporterConfiguration(net.sf.jasperreports.export.SimplePdfExporterConfiguration) JRException(net.sf.jasperreports.engine.JRException) SimplePdfReportConfiguration(net.sf.jasperreports.export.SimplePdfReportConfiguration) SimpleOutputStreamExporterOutput(net.sf.jasperreports.export.SimpleOutputStreamExporterOutput) SimpleExporterInput(net.sf.jasperreports.export.SimpleExporterInput) JRPdfExporter(net.sf.jasperreports.engine.export.JRPdfExporter)

Aggregations

JRException (net.sf.jasperreports.engine.JRException)1 JRPdfExporter (net.sf.jasperreports.engine.export.JRPdfExporter)1 SimpleExporterInput (net.sf.jasperreports.export.SimpleExporterInput)1 SimpleOutputStreamExporterOutput (net.sf.jasperreports.export.SimpleOutputStreamExporterOutput)1 SimplePdfExporterConfiguration (net.sf.jasperreports.export.SimplePdfExporterConfiguration)1 SimplePdfReportConfiguration (net.sf.jasperreports.export.SimplePdfReportConfiguration)1