JRExporter exporter = null; exporter = new JRPdfExporter(); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, outputStream); exporter.exportReport();
List jpList = new ArrayList(); jpList.add(JRLoader.loadObjectFromFile("build/reports/Report1.jrprint")); ... JRExporter exporter = new JRPdfExporter(); exporter.setParameter(JRPdfExporterParameter.JASPER_PRINT_LIST, jpList); exporter.setParameter(JRPdfExporterParameter.OUTPUT_STREAM, stream); exporter.exportReport();
@Override public InputStream write() throws IOException, JRException { LOGGER.info("entering FileReportWriter.writeTo()"); final File file = File.createTempFile("djreport", ".tmp"); file.deleteOnExit(); exporter.setParameter(JRExporterParameter.OUTPUT_FILE, file); exporter.exportReport(); return new FileInputStream(file); }
@Override public InputStream write() throws IOException, JRException { LOGGER.info("entering MemoryReportWriter.write()"); final ByteArrayOutputStream stream = new ByteArrayOutputStream(); exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, stream); exporter.exportReport(); return new ByteArrayInputStream(stream.toByteArray()); } }
@Override public InputStream write() throws IOException, JRException { LOGGER.info("entering FileReportWriter.writeTo()"); final File file = File.createTempFile("djreport", ".tmp"); file.deleteOnExit(); exporter.setParameter(JRExporterParameter.OUTPUT_FILE, file); exporter.exportReport(); return new FileInputStream(file); }
@Override public InputStream write() throws IOException, JRException { LOGGER.info("entering MemoryReportWriter.write()"); final ByteArrayOutputStream stream = new ByteArrayOutputStream(); exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, stream); exporter.exportReport(); return new ByteArrayInputStream(stream.toByteArray()); } }
public void writeTo(final HttpServletResponse _response) throws IOException, JRException { LOGGER.info("entering FileReportWriter.writeTo()"); final File file = File.createTempFile("djreport", ".tmp"); try { exporter.setParameter(JRExporterParameter.OUTPUT_FILE, file); exporter.exportReport(); _response.setContentLength((int)file.length()); copyStreams(new FileInputStream(file), _response.getOutputStream()); } finally { LOGGER.info("deleting " + file.getAbsolutePath()); file.delete(); } }
public void writeTo(final HttpServletResponse _response) throws IOException, JRException { LOGGER.info("entering MemoryReportWriter.writeTo(HttpServletResponse)"); final ByteArrayOutputStream stream = new ByteArrayOutputStream(); exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, stream); exporter.exportReport(); _response.setContentLength(stream.size()); copyStreams(new ByteArrayInputStream(stream.toByteArray()), _response.getOutputStream()); }
public void writeTo(final HttpServletResponse _response) throws IOException, JRException { LOGGER.info("entering MemoryReportWriter.writeTo(HttpServletResponse)"); final ByteArrayOutputStream stream = new ByteArrayOutputStream(); exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, stream); exporter.exportReport(); _response.setContentLength(stream.size()); copyStreams(new ByteArrayInputStream(stream.toByteArray()), _response.getOutputStream()); }
public void writeTo(final HttpServletResponse _response) throws IOException, JRException { LOGGER.info("entering FileReportWriter.writeTo()"); final File file = File.createTempFile("djreport", ".tmp"); try { exporter.setParameter(JRExporterParameter.OUTPUT_FILE, file); exporter.exportReport(); _response.setContentLength((int)file.length()); copyStreams(new FileInputStream(file), _response.getOutputStream()); } finally { LOGGER.info("deleting " + file.getAbsolutePath()); file.delete(); } }
JRExporter exporter = new JRPdfExporter(); exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, new FileOutputStream("c:/mipdf.pdf")); //The following is the important line exporter.setParameter(JRExporterParameter.JASPER_PRINT_LIST, Arrays.asList(jasperPrint, jasperPrint)); exporter.exportReport();
JasperReport ordersReport = JasperCompileManager.compileReport(srcOrdersReport); JasperPrint jpOrdersReport = JasperFillManager.fillReport(ordersReport, ordersParamsMap, ordersDataSource); JasperReport receiptsReport = JasperCompileManager.compileReport(srcReceiptsReport); JasperPrint jpReceiptsReport = JasperFillManager.fillReport(receiptsReport, receiptsParamsMap, receiptsDataSource); JasperReport invoicesReport = JasperCompileManager.compileReport(srcInvoicesReport); JasperPrint jpInvoicesReport = JasperFillManager.fillReport(invoicesReport, invoicesParamsMap, invoicesDataSource); List<JasperPrint> printList = new ArrayList<JasperPrint>(); printList.add(jpOrdersReport); printList.add(receiptsReport); printList.add(invoicesReport); JRExporter exporter = new JRPdfExporter(); exporter.setParameter(JRPdfExporterParameter.JASPER_PRINT_LIST, printList); exporter.setParameter(JRPdfExporterParameter.OUTPUT_STREAM, output); exporter.exportReport();
/** * Render the supplied <code>JasperPrint</code> instance using the * supplied <code>JRAbstractExporter</code> instance and write the results * to the supplied <code>OutputStream</code>. * <p>Make sure that the <code>JRAbstractExporter</code> implementation you * supply is capable of writing to a <code>OutputStream</code>. * @param exporter the <code>JRAbstractExporter</code> to use to render the report * @param print the <code>JasperPrint</code> instance to render * @param outputStream the <code>OutputStream</code> to write the result to * @throws JRException if rendering failed */ public static void render(JRExporter exporter, JasperPrint print, OutputStream outputStream) throws JRException { exporter.setParameter(JRExporterParameter.JASPER_PRINT, print); exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, outputStream); exporter.exportReport(); }
/** * Render the supplied {@code JasperPrint} instance using the * supplied {@code JRAbstractExporter} instance and write the results * to the supplied {@code OutputStream}. * <p>Make sure that the {@code JRAbstractExporter} implementation you * supply is capable of writing to a {@code OutputStream}. * @param exporter the {@code JRAbstractExporter} to use to render the report * @param print the {@code JasperPrint} instance to render * @param outputStream the {@code OutputStream} to write the result to * @throws JRException if rendering failed */ public static void render(net.sf.jasperreports.engine.JRExporter exporter, JasperPrint print, OutputStream outputStream) throws JRException { exporter.setParameter(net.sf.jasperreports.engine.JRExporterParameter.JASPER_PRINT, print); exporter.setParameter(net.sf.jasperreports.engine.JRExporterParameter.OUTPUT_STREAM, outputStream); exporter.exportReport(); }
/** * Render the supplied <code>JasperPrint</code> instance using the * supplied <code>JRAbstractExporter</code> instance and write the results * to the supplied <code>Writer</code>. * <p>Make sure that the <code>JRAbstractExporter</code> implementation * you supply is capable of writing to a <code>Writer</code>. * @param exporter the <code>JRAbstractExporter</code> to use to render the report * @param print the <code>JasperPrint</code> instance to render * @param writer the <code>Writer</code> to write the result to * @throws JRException if rendering failed */ public static void render(JRExporter exporter, JasperPrint print, Writer writer) throws JRException { exporter.setParameter(JRExporterParameter.JASPER_PRINT, print); exporter.setParameter(JRExporterParameter.OUTPUT_WRITER, writer); exporter.exportReport(); }
File myJasperFile // reference to compiled Jasper file JRExporter exp = new JRPdfExporter() ByteArrayOutputSream b; JasperPrint p = JasperFillManager.fillReport(...) exp.setParameter(JRExporterParameter.OUTPUT_STREAM, b) exp.setParameter(JRExporterParameter.JASPER_PRINT, p) exp.exportReport() // b now contains the PDF binary
private File exportReportPDF(JasperPrint jp, File file) throws JRException, FileNotFoundException { JRExporter exporter = new JRPdfExporter(); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jp); exporter.setParameter(JRExporterParameter.OUTPUT_FILE, file); exporter.exportReport(); return file; }
JRExporter exporter = new JRXhtmlExporter(); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, ouputStream); exporter.exportReport();
//add all three JasperPrints to the list below List<JasperPrint> jasperPrints = new ArrayList<JasperPrint>(); ... //create an exporter JRExporter exporter = new JRPrintServiceExporter(); //add the JasperPrints to the exporter via the JASPER_PRINT_LIST param exporter.setParameter(JRExporterParameter.JASPER_PRINT_LIST, jasperPrints); exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PAGE_DIALOG, Boolean.FALSE); exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PRINT_DIALOG, Boolean.TRUE); //this one makes it so that the settings choosen in the first dialog will be applied to the //other documents in the list also exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PRINT_DIALOG_ONLY_ONCE, Boolean.TRUE); exporter.exportReport();
// build dynamicreport instance DynamicReportBuilder dynamicReportBuilder = new DynamicReportBuilder(); dynamicReportBuilder.setHeaderHeight(50); //sets the column header height dynamicReportBuilder.setDetailHeight(50); //sets the detail band rows height DynamicReport dynamicReport = dynamicReportBuilder.build(); // build jasperprint.. JasperPrint jasperPrint = DynamicJasperHelper.generateJasperPrint( dynamicReport, new ClassicLayoutManager(), dataSource, new HashMap<String, Object>()); // export as html JRExporter exporter = new JRHtmlExporter(); // tell jasper not to use images for aligning exporter.setParameter(JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN, Boolean.FALSE); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, targetFile); exporter.exportReport();