Export JasperReport to PDF OutputStream?

后端 未结 3 1585
萌比男神i
萌比男神i 2020-12-02 10:34

I\'m writing a pretty simple sample project for familiarizing myself with Jasper Reports. I\'d like to export a report I\'ve configured to a PDF OutputStream, b

3条回答
  •  借酒劲吻你
    2020-12-02 11:12

    JRExporterParameter is deprecated in latest versions, This is a non deprecated solution of @stevemac answer

    JRPdfExporter exporter = new JRPdfExporter();
    exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
    exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(outputStream));
    SimplePdfExporterConfiguration configuration = new SimplePdfExporterConfiguration();
    configuration.setMetadataAuthor("Petter");  //why not set some config as we like
    exporter.setConfiguration(configuration);
    exporter.exportReport();
    

提交回复
热议问题