Java Code Examples for net.sf.jasperreports.engine.export.JRPdfExporter#setExporterOutput()
The following examples show how to use
net.sf.jasperreports.engine.export.JRPdfExporter#setExporterOutput() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BatchExportApp.java From jasperreports with GNU Lesser General Public License v3.0 | 8 votes |
/** * */ public void pdf() throws JRException { long start = System.currentTimeMillis(); List<JasperPrint> jasperPrintList = new ArrayList<JasperPrint>(); jasperPrintList.add((JasperPrint)JRLoader.loadObjectFromFile("build/reports/Report1.jrprint")); jasperPrintList.add((JasperPrint)JRLoader.loadObjectFromFile("build/reports/Report2.jrprint")); jasperPrintList.add((JasperPrint)JRLoader.loadObjectFromFile("build/reports/Report3.jrprint")); JRPdfExporter exporter = new JRPdfExporter(); exporter.setExporterInput(SimpleExporterInput.getInstance(jasperPrintList)); exporter.setExporterOutput(new SimpleOutputStreamExporterOutput("build/reports/BatchExportReport.pdf")); SimplePdfExporterConfiguration configuration = new SimplePdfExporterConfiguration(); configuration.setCreatingBatchModeBookmarks(true); exporter.setConfiguration(configuration); exporter.exportReport(); System.err.println("PDF creation time : " + (System.currentTimeMillis() - start)); }
Example 2
Source File: BookApp.java From jasperreports with GNU Lesser General Public License v3.0 | 6 votes |
/** * */ public void pdf() throws JRException { long start = System.currentTimeMillis(); JRPdfExporter exporter = new JRPdfExporter(); exporter.setExporterInput(new SimpleExporterInput("build/reports/BookReport.jrprint")); exporter.setExporterOutput(new SimpleOutputStreamExporterOutput("build/reports/BookReport.pdf")); SimplePdfExporterConfiguration configuration = new SimplePdfExporterConfiguration(); configuration.setCreatingBatchModeBookmarks(true); exporter.setConfiguration(configuration); exporter.exportReport(); //JasperExportManager.exportReportToPdfFile("build/reports/BookReport.jrprint"); System.err.println("PDF creation time : " + (System.currentTimeMillis() - start)); }
Example 3
Source File: PdfEncryptApp.java From jasperreports with GNU Lesser General Public License v3.0 | 6 votes |
/** * */ public void pdf() throws JRException { long start = System.currentTimeMillis(); File sourceFile = new File("build/reports/PdfEncryptReport.jrprint"); JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObject(sourceFile); File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".pdf"); JRPdfExporter exporter = new JRPdfExporter(); exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(destFile)); SimplePdfExporterConfiguration configuration = new SimplePdfExporterConfiguration(); configuration.setEncrypted(true); configuration.set128BitKey(true); configuration.setUserPassword("jasper"); configuration.setOwnerPassword("reports"); configuration.setPermissions(PdfWriter.ALLOW_COPY | PdfWriter.ALLOW_PRINTING); exporter.setConfiguration(configuration); exporter.exportReport(); System.err.println("PDF creation time : " + (System.currentTimeMillis() - start)); }
Example 4
Source File: SimpleReportExporter.java From tutorials with MIT License | 6 votes |
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); } }
Example 5
Source File: JRReportUtil.java From opencps-v2 with GNU Affero General Public License v3.0 | 5 votes |
/** * @param jasperPrints * @param destFileName * @return * @throws JRException */ protected static String exportPdfFile(List<JasperPrint> jasperPrints, String destFileName) throws JRException { JRPdfExporter exporter = new JRPdfExporter(); exporter.setExporterInput(SimpleExporterInput.getInstance(jasperPrints)); exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(destFileName)); SimplePdfExporterConfiguration configuration = new SimplePdfExporterConfiguration(); configuration.setCreatingBatchModeBookmarks(true); exporter.setConfiguration(configuration); exporter.exportReport(); // ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); // // JRPdfExporter exporter = new JRPdfExporter(); // // exporter.setParameter(JRExporterParameter.JASPER_PRINT_LIST, jasperPrints); // exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, outputStream); // // exporter.exportReport(); // // try (OutputStream outputStreamWrite = new FileOutputStream(destFileName)) { // outputStream.writeTo(outputStreamWrite); // } // catch (IOException e) { // // } return destFileName; }
Example 6
Source File: JasperExportManager.java From jasperreports with GNU Lesser General Public License v3.0 | 5 votes |
/** * Exports the generated report file specified by the first parameter into PDF format, * the result being placed in the second file parameter. * * @param jasperPrint report object to export * @param destFileName file name to place the PDF content into * @see net.sf.jasperreports.engine.export.JRPdfExporter */ public void exportToPdfFile( JasperPrint jasperPrint, String destFileName ) throws JRException { /* */ JRPdfExporter exporter = new JRPdfExporter(jasperReportsContext); exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(destFileName)); exporter.exportReport(); }
Example 7
Source File: JasperExportManager.java From jasperreports with GNU Lesser General Public License v3.0 | 5 votes |
/** * Exports the generated report object received as first parameter into PDF format and * writes the results to the output stream specified by the second parameter. * * @param jasperPrint report object to export * @param outputStream output stream to write the resulting PDF content to * @see net.sf.jasperreports.engine.export.JRPdfExporter */ public void exportToPdfStream( JasperPrint jasperPrint, OutputStream outputStream ) throws JRException { JRPdfExporter exporter = new JRPdfExporter(jasperReportsContext); exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(outputStream)); exporter.exportReport(); }
Example 8
Source File: JasperExportManager.java From jasperreports with GNU Lesser General Public License v3.0 | 5 votes |
/** * Exports the generated report object received as parameter into PDF format and * returns the binary content as a byte array. * * @param jasperPrint report object to export * @return byte array representing the resulting PDF content * @see net.sf.jasperreports.engine.export.JRPdfExporter */ public byte[] exportToPdf(JasperPrint jasperPrint) throws JRException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); JRPdfExporter exporter = new JRPdfExporter(jasperReportsContext); exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(baos)); exporter.exportReport(); return baos.toByteArray(); }
Example 9
Source File: StylesApp.java From jasperreports with GNU Lesser General Public License v3.0 | 4 votes |
/** * */ public void pdf() throws JRException { long start = System.currentTimeMillis(); File sourceFile = new File("build/reports/StylesReport.jrprint"); JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObject(sourceFile); File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".pdf"); JRPdfExporter exporter = new JRPdfExporter(); exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(destFile)); exporter.exportReport(); System.err.println("PDF creation time : " + (System.currentTimeMillis() - start)); }
Example 10
Source File: JasperApp.java From jasperreports with GNU Lesser General Public License v3.0 | 4 votes |
/** * */ public void pdfa1() throws JRException { long start = System.currentTimeMillis(); try{ ByteArrayOutputStream os = new ByteArrayOutputStream(); JRPdfExporter exporter = new JRPdfExporter(); exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(os)); JasperPrint jp = (JasperPrint)JRLoader.loadObject(new File("build/reports/FirstJasper.jrprint")); // Exclude transparent images when exporting to PDF; elements marked with the key 'TransparentImage' // will be excluded from the exported PDF jp.setProperty("net.sf.jasperreports.export.pdf.exclude.key.TransparentImage", null); exporter.setExporterInput(new SimpleExporterInput(jp)); SimplePdfExporterConfiguration configuration = new SimplePdfExporterConfiguration(); // Include structure tags for PDF/A-1a compliance; unnecessary for PDF/A-1b configuration.setTagged(true); configuration.setPdfaConformance(PdfaConformanceEnum.PDFA_1A); // Uncomment the following line and specify a valid path for the ICC profile // configuration.setIccProfilePath("path/to/ICC/profile"); exporter.setConfiguration(configuration); exporter.exportReport(); FileOutputStream fos = new FileOutputStream("build/reports/FirstJasper_pdfa.pdf"); os.writeTo(fos); fos.close(); }catch(Exception e){ e.printStackTrace(); } System.err.println("PDF/A-1a creation time : " + (System.currentTimeMillis() - start)); }