net.sf.jasperreports.engine.export.JRPdfExporter Java Examples

The following examples show how to use net.sf.jasperreports.engine.export.JRPdfExporter. 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 vote down vote up
/**
 *
 */
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: SimpleReportExporter.java    From tutorials with MIT License 6 votes vote down vote up
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 #3
Source File: PdfReport.java    From carbon-commons with Apache License 2.0 6 votes vote down vote up
/**
 * generate a ByteArrayOutputStream from given JasperPrint object for the PDF report
 *
 * @param jasperPrint transform to pdf report
 * @return reporting ByteArrayOutputStream
 * @throws ReportingException when the JasperPrint null
 * @throws JRException
 * @throws IOException
 */
public ByteArrayOutputStream generatePdfReport(JasperPrint jasperPrint) throws JRException, ReportingException {

    ByteArrayOutputStream pdfOutputStream = new ByteArrayOutputStream();
    if (jasperPrint == null) {
        throw new ReportingException("jasperPrint null, can't convert to  PDF report");
    }
    try {

        JRPdfExporter jrPdfExporter = new JRPdfExporter();
        jrPdfExporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
        jrPdfExporter.setParameter(JRExporterParameter.OUTPUT_STREAM, pdfOutputStream);
        jrPdfExporter.exportReport();

    } catch (JRException e) {
        throw new JRException("Error occurred exporting PDF report ", e);
    }
    return pdfOutputStream;
}
 
Example #4
Source File: MapElementPdfHandler.java    From jasperreports with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void exportElement(
	JRPdfExporterContext exporterContext,
	JRGenericPrintElement element
	)
{
	try
	{
		JRPdfExporter exporter = (JRPdfExporter)exporterContext.getExporterRef();
		exporter.exportImage(MapElementImageProvider.getImage(exporterContext.getJasperReportsContext(), element));
	}
	catch (Exception e)
	{
		throw new RuntimeException(e);
	}
}
 
Example #5
Source File: BookApp.java    From jasperreports with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 *
 */
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 #6
Source File: PdfEncryptApp.java    From jasperreports with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 *
 */
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 #7
Source File: ChartNoPdfHandler.java    From jasperreports with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void exportElement(JRPdfExporterContext exporterContext, JRGenericPrintElement element)
{
	JRPdfExporter exporter = (JRPdfExporter)exporterContext.getExporterRef();
	
	JRPrintText text = getTextElementReplacement(exporterContext, element);
	
	try
	{
		exporter.exportText(text);
	}
	catch (Exception e)
	{
		throw new RuntimeException(e);
	}
}
 
Example #8
Source File: JasperReportsUtil.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
private static byte[] getBytes(JRAbstractExporter exporter, ByteArrayOutputStream baos,
                                  JasperPrint jasperPrint) throws JRException {

       printNextReportsParameters();

       // for csv delimiter
       //exporter.setParameter(JRCsvExporterParameter.FIELD_DELIMITER, ";");
       exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
       exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, baos);

       if (exporter instanceof JRPdfExporter) {
           exporter.setParameter(JRExporterParameter.CHARACTER_ENCODING, encoding);

           // create embedded pdf font (like in nextreports)
           if (embeddedFont != null) {
               HashMap<FontKey, PdfFont> fontMap = new HashMap<FontKey, PdfFont>();
               FontKey key = new FontKey("Arial", false, false);
               PdfFont font = new PdfFont(embeddedFont, BaseFont.IDENTITY_H, true);
               fontMap.put(key, font);
               exporter.setParameter(JRPdfExporterParameter.FONT_MAP, fontMap);
           }
       } else {
           exporter.setParameter(JRExporterParameter.CHARACTER_ENCODING, "UTF-8");
       }

       exporter.exportReport();
       return baos.toByteArray();
   }
 
Example #9
Source File: JasperReportsUtil.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
public static byte[] getPdf(JasperPrint jasperPrint) throws JRException {
    byte[] content = null;
    ByteArrayOutputStream baos = null;
    try {
        baos = new ByteArrayOutputStream();
        JRPdfExporter exporter = new JRPdfExporter();
        content = getBytes(exporter, baos, jasperPrint);
    } finally {
        if (baos != null) {
            try {
                baos.flush();
                baos.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
    return content;
}
 
Example #10
Source File: JasperReportsPdfExporter.java    From tutorials with MIT License 5 votes vote down vote up
/**
 * Generates a ByteArrayOutputStream from the provided JasperReport using
 * the {@link JRPdfExporter}. After that, the generated bytes array is
 * written in the {@link HttpServletResponse}
 * 
 * @param jp
 *            The generated JasperReport.
 * @param fileName
 *            The fileName of the exported JasperReport
 * @param response
 *            The HttpServletResponse where generated report has been
 *            written
 * @throws JRException
 *             during JasperReport export.
 * @throws IOException
 *             when writes the ByteArrayOutputStream into the
 *             HttpServletResponse
 */
@Override
public void export(JasperPrint jp, String fileName, HttpServletResponse response) throws JRException, IOException {

	ByteArrayOutputStream baos = new ByteArrayOutputStream();

	// Create a JRPdfExporter instance
	JRPdfExporter exporter = new JRPdfExporter();

	// Here we assign the parameters jp and baos to the exporter
	exporter.setParameter(JRExporterParameter.JASPER_PRINT, jp);
	exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, baos);

	// Retrieve the exported report in PDF format
	exporter.exportReport();

	// Specifies the response header
	response.setHeader("Content-Disposition", "inline; filename=" + fileName);

	// Make sure to set the correct content type
	// Each format has its own content type
	response.setContentType("application/pdf");
	response.setContentLength(baos.size());

	// Retrieve the output stream
	ServletOutputStream outputStream = response.getOutputStream();
	// Write to the output stream
	baos.writeTo(outputStream);
	// Flush the stream
	outputStream.flush();

}
 
Example #11
Source File: JasperExportManager.java    From jasperreports with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * 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 #12
Source File: JasperExportManager.java    From jasperreports with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * 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 #13
Source File: JasperExportManager.java    From jasperreports with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * 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 #14
Source File: HtmlElementHandlerBundle.java    From jasperreports with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public GenericElementHandler getHandler(String elementName,
		String exporterKey)
{
	if (NAME.equals(elementName)
			&& JRPdfExporter.PDF_EXPORTER_KEY.equals(exporterKey))
	{
		return new HtmlElementPdfHandler();
	}
	else if (NAME.equals(elementName)
			&& HtmlExporter.HTML_EXPORTER_KEY.equals(exporterKey))
	{
		return new HtmlElementHtmlHandler();
	}
	else if (NAME.equals(elementName)
			&& JRXlsExporter.XLS_EXPORTER_KEY.equals(exporterKey))
	{
		return new HtmlElementXlsHandler();
	}
	else if (NAME.equals(elementName)
			&& JRGraphics2DExporter.GRAPHICS2D_EXPORTER_KEY.equals(exporterKey))
	{
		return new HtmlElementGraphics2DHandler();
	}		
	else if (NAME.equals(elementName)
			&& JRDocxExporter.DOCX_EXPORTER_KEY.equals(exporterKey))
	{
		return new HtmlElementDocxHandler();
	}		
	else if (NAME.equals(elementName)
			&& JRPptxExporter.PPTX_EXPORTER_KEY.equals(exporterKey))
	{
		return new HtmlElementPptxHandler();
	}
	else if (NAME.equals(elementName)
			&& JRXlsxExporter.XLSX_EXPORTER_KEY.equals(exporterKey))
	{
		return new HtmlElementXlsxHandler();
	}
	else if (NAME.equals(elementName)
			&& JRRtfExporter.RTF_EXPORTER_KEY.equals(exporterKey))
	{
		return new HtmlElementRtfHandler();
	}
	else if (NAME.equals(elementName)
			&& JROdtExporter.ODT_EXPORTER_KEY.equals(exporterKey))
	{
		return new HtmlElementOdtHandler();
	}
	else if (NAME.equals(elementName)
			&& JROdsExporter.ODS_EXPORTER_KEY.equals(exporterKey))
	{
		return new HtmlElementOdsHandler();
	}		
	return null;
}
 
Example #15
Source File: GeneratePDFReport.java    From elasticsearch-report-engine with GNU General Public License v3.0 5 votes vote down vote up
private void exportPdf(JasperPrint jp, ByteArrayOutputStream baos, Map params) {
  // Create a JRPdfExporter instance
  JRPdfExporter exporter = new JRPdfExporter();
  exporter.setParameter(JRExporterParameter.JASPER_PRINT, jp);
  exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, baos);
  try {
    exporter.exportReport();
  } catch (JRException e) {

  }
}
 
Example #16
Source File: JasperReportsUtilsTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void renderWithOutputStream() throws Exception {
	ByteArrayOutputStream os = new ByteArrayOutputStream();
	JasperPrint print = JasperFillManager.fillReport(getReport(), getParameters(), getDataSource());
	JasperReportsUtils.render(new JRPdfExporter(), print, os);
	byte[] output = os.toByteArray();
	assertPdfOutputCorrect(output);
}
 
Example #17
Source File: ConfigurableJasperReportsViewWithWriterTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
protected AbstractJasperReportsView getViewImplementation() {
	ConfigurableJasperReportsView view = new ConfigurableJasperReportsView();
	view.setExporterClass(JRPdfExporter.class);
	view.setUseWriter(false);
	view.setContentType("text/html");
	return view;
}
 
Example #18
Source File: PdfView.java    From spring-boot-doma2-sample with Apache License 2.0 5 votes vote down vote up
@Override
protected void renderMergedOutputModel(Map<String, Object> model, HttpServletRequest request,
        HttpServletResponse response) throws Exception {

    // IEの場合はContent-Lengthヘッダが指定されていないとダウンロードが失敗するので、
    // サイズを取得するための一時的なバイト配列ストリームにコンテンツを書き出すようにする
    val baos = createTemporaryOutputStream();

    // 帳票レイアウト
    val report = loadReport();

    // データの設定
    val dataSource = new JRBeanCollectionDataSource(this.data);
    val print = JasperFillManager.fillReport(report, model, dataSource);

    val exporter = new JRPdfExporter();
    exporter.setExporterInput(new SimpleExporterInput(print));
    exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(baos));
    exporter.exportReport();

    // ファイル名に日本語を含めても文字化けしないようにUTF-8にエンコードする
    val encodedFilename = EncodeUtils.encodeUtf8(filename);
    val contentDisposition = String.format("attachment; filename*=UTF-8''%s", encodedFilename);
    response.setHeader(CONTENT_DISPOSITION, contentDisposition);

    writeToResponse(response, baos);
}
 
Example #19
Source File: JRReportUtil.java    From opencps-v2 with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
	 * @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 #20
Source File: JasperApp.java    From jasperreports with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
	 * 
	 */
	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));
	}
 
Example #21
Source File: StylesApp.java    From jasperreports with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 *
 */
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 #22
Source File: JasperReportsPdfView.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
protected net.sf.jasperreports.engine.JRExporter createExporter() {
	return new JRPdfExporter();
}
 
Example #23
Source File: IconLabelElementPdfHandler.java    From jasperreports with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void exportElement(JRPdfExporterContext exporterContext, JRGenericPrintElement element)
{
	JRPrintText labelPrintText = (JRPrintText)element.getParameterValue(IconLabelElement.PARAMETER_LABEL_TEXT_ELEMENT);
	if (labelPrintText == null) //FIXMEINPUT deal with xml serialization
	{
		return;
	}
	
	JRBasePrintFrame frame = new JRBasePrintFrame(element.getDefaultStyleProvider());
	frame.setX(element.getX());
	frame.setY(element.getY());
	frame.setWidth(element.getWidth());
	frame.setHeight(element.getHeight());
	frame.setStyle(element.getStyle());
	frame.setBackcolor(element.getBackcolor());
	frame.setForecolor(element.getForecolor());
	frame.setMode(element.getModeValue());
	JRLineBox lineBox = (JRLineBox)element.getParameterValue(IconLabelElement.PARAMETER_LINE_BOX);
	if (lineBox != null)
	{
		frame.copyBox(lineBox);
	}
	
	frame.addElement(labelPrintText);
	
	JRPrintText iconPrintText = (JRPrintText)element.getParameterValue(IconLabelElement.PARAMETER_ICON_TEXT_ELEMENT);
	if (iconPrintText != null) //FIXMEINPUT deal with xml serialization
	{
		frame.addElement(iconPrintText);
	}

	JRPdfExporter exporter = (JRPdfExporter)exporterContext.getExporterRef();
	try
	{
		exporter.exportFrame(frame);
	}
	catch(Exception e)
	{
		throw new JRRuntimeException(e);
	}
}
 
Example #24
Source File: CVComponentExtensionsRegistryFactory.java    From jasperreports with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
@SuppressWarnings("deprecation")
public GenericElementHandler getHandler(String elementName, String exporterKey)
{
	if (CVConstants.COMPONENT_NAME.equals(elementName))
	{
		if (JRGraphics2DExporter.GRAPHICS2D_EXPORTER_KEY.equals(exporterKey))
		{
			return CVElementGraphics2DHandler.getInstance();
		}
		if (HtmlExporter.HTML_EXPORTER_KEY.equals(exporterKey))
		{
			return CVElementHtmlHandler.getInstance();
		}
		else if (JRPdfExporter.PDF_EXPORTER_KEY.equals(exporterKey))
		{
			return CVElementPdfHandler.getInstance();
		}
		else if (JsonExporter.JSON_EXPORTER_KEY.equals(exporterKey))
		{
			return CVElementJsonHandler.getInstance();
		}
		else if (JRXlsExporter.XLS_EXPORTER_KEY.equals(exporterKey))
		{
			return CVElementXlsHandler.getInstance();
		}
		else if (JRXlsxExporter.XLSX_EXPORTER_KEY.equals(exporterKey))
		{
			return CVElementXlsxHandler.getInstance();
		}
		else if (JRDocxExporter.DOCX_EXPORTER_KEY.equals(exporterKey))
		{
			return CVElementDocxHandler.getInstance();
		}
		else if (JRPptxExporter.PPTX_EXPORTER_KEY.equals(exporterKey))
		{
			return CVElementPptxHandler.getInstance();
		}
		else if (JRRtfExporter.RTF_EXPORTER_KEY.equals(exporterKey))
		{
			return CVElementRtfHandler.getInstance();
		}
		else if (JROdtExporter.ODT_EXPORTER_KEY.equals(exporterKey))
		{
			return CVElementOdtHandler.getInstance();
		}
		else if (JROdsExporter.ODS_EXPORTER_KEY.equals(exporterKey))
		{
			return CVElementOdsHandler.getInstance();
		}
	}

	return null;
}
 
Example #25
Source File: JasperReportsPdfView.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected net.sf.jasperreports.engine.JRExporter createExporter() {
	return new JRPdfExporter();
}
 
Example #26
Source File: JasperReportsUtils.java    From spring4-understanding with Apache License 2.0 3 votes vote down vote up
/**
 * Render a report in PDF format using the supplied report data.
 * Writes the results to the supplied {@code OutputStream}.
 * @param report the {@code JasperReport} instance to render
 * @param parameters the parameters to use for rendering
 * @param stream the {@code OutputStream} to write the rendered report to
 * @param reportData a {@code JRDataSource}, {@code java.util.Collection} or object array
 * (converted accordingly), representing the report data to read fields from
 * @param exporterParameters a {@link Map} of {@code JRExporterParameter exporter parameters}
 * @throws JRException if rendering failed
 * @see #convertReportData
 */
public static void renderAsPdf(JasperReport report, Map<String, Object> parameters, Object reportData,
		OutputStream stream, Map<net.sf.jasperreports.engine.JRExporterParameter, Object> exporterParameters)
		throws JRException {

	JasperPrint print = JasperFillManager.fillReport(report, parameters, convertReportData(reportData));
	JRPdfExporter exporter = new JRPdfExporter();
	exporter.setParameters(exporterParameters);
	render(exporter, print, stream);
}
 
Example #27
Source File: JasperReportsUtils.java    From spring4-understanding with Apache License 2.0 3 votes vote down vote up
/**
 * Render a report in PDF format using the supplied report data.
 * Writes the results to the supplied {@code OutputStream}.
 * @param report the {@code JasperReport} instance to render
 * @param parameters the parameters to use for rendering
 * @param stream the {@code OutputStream} to write the rendered report to
 * @param reportData a {@code JRDataSource}, {@code java.util.Collection} or object array
 * (converted accordingly), representing the report data to read fields from
 * @throws JRException if rendering failed
 * @see #convertReportData
 */
public static void renderAsPdf(JasperReport report, Map<String, Object> parameters, Object reportData,
		OutputStream stream) throws JRException {

	JasperPrint print = JasperFillManager.fillReport(report, parameters, convertReportData(reportData));
	render(new JRPdfExporter(), print, stream);
}
 
Example #28
Source File: JasperReportsUtils.java    From lams with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Render a report in PDF format using the supplied report data.
 * Writes the results to the supplied {@code OutputStream}.
 * @param report the {@code JasperReport} instance to render
 * @param parameters the parameters to use for rendering
 * @param stream the {@code OutputStream} to write the rendered report to
 * @param reportData a {@code JRDataSource}, {@code java.util.Collection} or object array
 * (converted accordingly), representing the report data to read fields from
 * @param exporterParameters a {@link Map} of {@code JRExporterParameter exporter parameters}
 * @throws JRException if rendering failed
 * @see #convertReportData
 */
public static void renderAsPdf(JasperReport report, Map<String, Object> parameters, Object reportData,
		OutputStream stream, Map<net.sf.jasperreports.engine.JRExporterParameter, Object> exporterParameters)
		throws JRException {

	JasperPrint print = JasperFillManager.fillReport(report, parameters, convertReportData(reportData));
	JRPdfExporter exporter = new JRPdfExporter();
	exporter.setParameters(exporterParameters);
	render(exporter, print, stream);
}
 
Example #29
Source File: JasperReportsUtils.java    From lams with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Render a report in PDF format using the supplied report data.
 * Writes the results to the supplied {@code OutputStream}.
 * @param report the {@code JasperReport} instance to render
 * @param parameters the parameters to use for rendering
 * @param stream the {@code OutputStream} to write the rendered report to
 * @param reportData a {@code JRDataSource}, {@code java.util.Collection} or object array
 * (converted accordingly), representing the report data to read fields from
 * @throws JRException if rendering failed
 * @see #convertReportData
 */
public static void renderAsPdf(JasperReport report, Map<String, Object> parameters, Object reportData,
		OutputStream stream) throws JRException {

	JasperPrint print = JasperFillManager.fillReport(report, parameters, convertReportData(reportData));
	render(new JRPdfExporter(), print, stream);
}