jasper-reports
Exporteren naar pdf
Zoeken…
Opmerkingen
Voor het correct weergeven van lettertypen in pdf moeten lettertype-extensies altijd worden gebruikt (in classpath)
Met IDE (geïntegreerde ontwikkelomgeving)
JasperSoft Studio
Voer in Preview een rapport uit door op de groene pijl te klikken. Als er geen fouten zijn, wordt het exportmenu ingeschakeld, klik op de exportknop (schijfkopie) en selecteer "Exporteren als PDF"
Met Java
Om een te exporteren, moet u het rapport invullen om het JasperPrint- object te krijgen.
Exporteer enkele JasperPrint (enkele jrxml) naar bestand
// 1. Create exporter instance
JRPdfExporter exporter = new JRPdfExporter();
// 2. Set exporter input document
exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
// 3. Set file path for exporter output
exporter.setExporterOutput(new SimpleOutputStreamExporterOutput("/path/filename.pdf"));
// 4. Create configuration instance
SimplePdfExporterConfiguration configuration = new SimplePdfExporterConfiguration();
// 5. Associate configuration with exporter
exporter.setConfiguration(configuration);
// 6. Fill export and write to file path
exporter.exportReport();
Exporteer meerdere JasperPrint's (meerdere jrxml) naar één bestand
Alleen de eerste stappen verschillen van de vorige set:
List<JasperPrint> jasperPrintList = new ArrayList<>();
jasperPrintList.add(jasperPrint1);
jasperPrintList.add(jasperPrint2);
JRPdfExporter exporter = new JRPdfExporter();
exporter.setExporterInput(SimpleExporterInput.getInstance(jasperPrintList));
De resterende stappen zijn hetzelfde:
exporter.setExporterOutput(new SimpleOutputStreamExporterOutput("/path/filename.pdf"));
SimplePdfExporterConfiguration configuration = new SimplePdfExporterConfiguration();
exporter.setConfiguration(configuration);
exporter.exportReport();
Zie SimplePdfExporterConfiguration API voor configuratiegegevens.
Modified text is an extract of the original Stack Overflow Documentation
Licentie onder CC BY-SA 3.0
Niet aangesloten bij Stack Overflow