Ricerca…


Osservazioni

Per rendere i font corretti in font-extension pdf dovrebbe sempre essere usato (in classpath)

Con IDE (ambiente di sviluppo integrato)

JasperSoft Studio

In Anteprima, esegui il rapporto facendo clic sulla freccia verde, se non ci sono errori il menu di esportazione sarà abilitato, fai clic sul pulsante di esportazione (immagine del disco) e seleziona "Esporta come Pdf" Esporta come pdf

Con Java

Per esportare a è necessario compilare il report per ottenere l'oggetto JasperPrint .

Esportare singoli file JasperPrint (single jrxml) in un file

// 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();

Esportare più JasperPrint (più jrxml) in un singolo file

Solo i primi passi differiscono dal set precedente:

List<JasperPrint> jasperPrintList = new ArrayList<>();
jasperPrintList.add(jasperPrint1);
jasperPrintList.add(jasperPrint2);

JRPdfExporter exporter = new JRPdfExporter();
exporter.setExporterInput(SimpleExporterInput.getInstance(jasperPrintList));

I passaggi rimanenti sono gli stessi:

exporter.setExporterOutput(new SimpleOutputStreamExporterOutput("/path/filename.pdf"));
SimplePdfExporterConfiguration configuration = new SimplePdfExporterConfiguration();
exporter.setConfiguration(configuration);
exporter.exportReport();

Vedi API SimplePdfExporterConfiguration per i dettagli di configurazione.



Modified text is an extract of the original Stack Overflow Documentation
Autorizzato sotto CC BY-SA 3.0
Non affiliato con Stack Overflow