當前位置: 首頁>>代碼示例>>Java>>正文


Java JRPdfExporter類代碼示例

本文整理匯總了Java中net.sf.jasperreports.engine.export.JRPdfExporter的典型用法代碼示例。如果您正苦於以下問題:Java JRPdfExporter類的具體用法?Java JRPdfExporter怎麽用?Java JRPdfExporter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


JRPdfExporter類屬於net.sf.jasperreports.engine.export包,在下文中一共展示了JRPdfExporter類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: concatPDFReport

import net.sf.jasperreports.engine.export.JRPdfExporter; //導入依賴的package包/類
/**
 * Returns a PDF file into an output stream as result of the concatenation of the JasperPrint
 * objects list passed as parameter.
 * 
 * @param jasperPrintList
 *          A list of JasperPrint objects.
 * @param createBookmarks
 *          A flag to indicate if the document should contain bookmarks, to mark the beginning of
 *          each individual document that was part of the initial document list.
 * @param outputStream
 *          The output stream used for returning the report.
 * @param reportConfiguration
 *          An optional configuration for the report.
 * @throws JRException
 *           In case there is any error compiling the report an exception is thrown with the error
 *           message.
 */
public static void concatPDFReport(List<JasperPrint> jasperPrintList, boolean createBookmarks,
    OutputStream outputStream, SimplePdfExporterConfiguration reportConfiguration)
    throws JRException {

  JRPdfExporter exporter = new JRPdfExporter();
  SimpleOutputStreamExporterOutput exporterOutput = new SimpleOutputStreamExporterOutput(
      outputStream);
  SimplePdfExporterConfiguration configuration = reportConfiguration != null ? reportConfiguration
      : new SimplePdfExporterConfiguration();

  reportConfiguration.setCreatingBatchModeBookmarks(createBookmarks);
  exporter.setConfiguration(configuration);
  exporter.setExporterInput(SimpleExporterInput.getInstance(jasperPrintList));
  exporter.setExporterOutput(exporterOutput);

  exporter.exportReport();
}
 
開發者ID:mauyr,項目名稱:openbravo-brazil,代碼行數:35,代碼來源:ReportingUtils.java

示例2: exportElement

import net.sf.jasperreports.engine.export.JRPdfExporter; //導入依賴的package包/類
@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);
	}
}
 
開發者ID:TIBCOSoftware,項目名稱:jasperreports,代碼行數:17,代碼來源:MapElementPdfHandler.java

示例3: export

import net.sf.jasperreports.engine.export.JRPdfExporter; //導入依賴的package包/類
public void export(HttpServletRequest req, HttpServletResponse res) throws Exception {
	String fileName=this.getExportFileName(req);
	fileName+=".pdf";
	res.setContentType("application/octet-stream");
	res.setHeader("Connection", "close");
	res.setHeader("Content-Disposition", "attachment;filename=\"" + new String(fileName.getBytes("utf-8"),"ISO-8859-1") + "\"");
	JRPdfExporter exporter = new JRPdfExporter(DefaultJasperReportsContext.getInstance());
	JasperPrint jasperPrint=this.getJasperPrint(req);
	exporter.setParameter(JRExporterParameter.JASPER_PRINT,jasperPrint);
	OutputStream ouputStream = res.getOutputStream();
	exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, ouputStream);
	try {
		exporter.exportReport();
	} catch (JRException e) {
		throw new ServletException(e);
	} finally {
		if (ouputStream != null) {
			ouputStream.flush();
			ouputStream.close();
		}
	}
}
 
開發者ID:bsteker,項目名稱:bdf2,代碼行數:23,代碼來源:PdfExporter.java

示例4: savePDFReportToOutputStream

import net.sf.jasperreports.engine.export.JRPdfExporter; //導入依賴的package包/類
/**
 * Generates a PDF report from a pre-compiled report and returns it into an output stream.
 * 
 * @param jasperPrint
 *          JasperPrint object which contains a compiled report.
 * @param exportParameters
 *          Export parameters than can be added to configure the resulting report.
 * @param outputStream
 *          The output stream used to return the report.
 * @throws JRException
 *           In case there is any error generating the report an exception is thrown with the
 *           error message.
 */
public static void savePDFReportToOutputStream(JasperPrint jasperPrint,
    Map<Object, Object> exportParameters, OutputStream outputStream) throws JRException {
  if (exportParameters != null && exportParameters.size() > 0) {
    final JRPdfExporter exporter = new JRPdfExporter();
    SimpleExporterInput exporterInput = new SimpleExporterInput(jasperPrint);
    SimpleOutputStreamExporterOutput exporterOutput = new SimpleOutputStreamExporterOutput(
        outputStream);
    SimplePdfExporterConfiguration configuration = new SimplePdfExporterConfiguration();
    String jsContent = (String) exportParameters.get(PDF_JAVASCRIPT);
    if (jsContent != null) {
      configuration.setPdfJavaScript(jsContent);
    }
    exporter.setExporterInput(exporterInput);
    exporter.setExporterOutput(exporterOutput);
    exporter.setConfiguration(configuration);
    exporter.exportReport();
  } else {
    JasperExportManager.exportReportToPdfStream(jasperPrint, outputStream);
  }
}
 
開發者ID:mauyr,項目名稱:openbravo-brazil,代碼行數:34,代碼來源:ReportingUtils.java

示例5: concatPDFReportEncrypted

import net.sf.jasperreports.engine.export.JRPdfExporter; //導入依賴的package包/類
/**
 * Returns an encrypted PDF file into an output stream as result of the concatenation of the
 * JasperPrint objects list passed as parameter.
 * 
 * @param jasperPrintList
 *          A list of JasperPrint objects.
 * @param createBookmarks
 *          A flag to indicate if the document should contain bookmarks, to mark the beginning of
 *          each individual document that was part of the initial document list.
 * @param userPassword
 *          A String that contains the user password of the resulting document.
 * @param ownerPassword
 *          A String that contains the owner password of the resulting document.
 * @param outputStream
 *          The output stream used for returning the report.
 * @throws JRException
 *           In case there is any error compiling the report an exception is thrown with the error
 *           message.
 */
public static void concatPDFReportEncrypted(List<JasperPrint> jasperPrintList,
    boolean createBookmarks, String userPassword, String ownerPassword, OutputStream outputStream)
    throws JRException {

  JRPdfExporter exporter = new JRPdfExporter();
  SimpleOutputStreamExporterOutput exporterOutput = new SimpleOutputStreamExporterOutput(
      outputStream);
  SimplePdfExporterConfiguration reportConfiguration = new SimplePdfExporterConfiguration();

  reportConfiguration.setEncrypted(true);
  reportConfiguration.set128BitKey(true);
  reportConfiguration.setUserPassword(userPassword);
  reportConfiguration.setOwnerPassword(ownerPassword);
  reportConfiguration.setCreatingBatchModeBookmarks(createBookmarks);
  exporter.setConfiguration(reportConfiguration);
  exporter.setExporterInput(SimpleExporterInput.getInstance(jasperPrintList));
  exporter.setExporterOutput(exporterOutput);

  exporter.exportReport();
}
 
開發者ID:mauyr,項目名稱:openbravo-brazil,代碼行數:40,代碼來源:ReportingUtils.java

示例6: pdf

import net.sf.jasperreports.engine.export.JRPdfExporter; //導入依賴的package包/類
/**
 *
 */
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));
}
 
開發者ID:TIBCOSoftware,項目名稱:jasperreports,代碼行數:20,代碼來源:BookApp.java

示例7: pdf

import net.sf.jasperreports.engine.export.JRPdfExporter; //導入依賴的package包/類
/**
 *
 */
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));
}
 
開發者ID:TIBCOSoftware,項目名稱:jasperreports,代碼行數:28,代碼來源:PdfEncryptApp.java

示例8: pdf

import net.sf.jasperreports.engine.export.JRPdfExporter; //導入依賴的package包/類
/**
 *
 */
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));
}
 
開發者ID:TIBCOSoftware,項目名稱:jasperreports,代碼行數:24,代碼來源:BatchExportApp.java

示例9: execute

import net.sf.jasperreports.engine.export.JRPdfExporter; //導入依賴的package包/類
@Override
public void execute(Connection connection) throws SQLException {
	InputStream relatorioStream = this.getClass().getResourceAsStream(this.caminhoRelatorio);

	try {
		JasperPrint print = JasperFillManager.fillReport(relatorioStream, this.parametros, connection);

		this.relatorioGerado = print.getPages().size() > 0;

		if (this.relatorioGerado) {
			JRExporter exportador = new JRPdfExporter();
			exportador.setParameter(JRExporterParameter.OUTPUT_STREAM, this.response.getOutputStream());
			exportador.setParameter(JRExporterParameter.JASPER_PRINT, print);

			this.response.setContentType("application/pdf");
			this.response
					.setHeader("Content-Disposition", "attachment; filename=\"" + this.nomeArquivoSaida + "\"");

			exportador.exportReport();
		}
	} catch (Exception e) {
		throw new SQLException("Erro ao executar relatorio " + this.caminhoRelatorio, e);
	}

}
 
開發者ID:fabiohxcx,項目名稱:PedidoVenda,代碼行數:26,代碼來源:ExecutorRelatorio.java

示例10: exportToPdf

import net.sf.jasperreports.engine.export.JRPdfExporter; //導入依賴的package包/類
@Override
public byte[] exportToPdf(final JasperPrint jasperPrint)
{
	final JRPdfExporter exporter = new JRPdfExporter();

	final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();

	exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
	exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, outputStream);
	exporter.setParameter(JRExporterParameter.CHARACTER_ENCODING, "UTF8");

	try
	{
		exporter.exportReport();
	}
	catch (JRException e)
	{
		throw new AdempiereException("Cannot create PDF from " + jasperPrint, e);
	}

	return outputStream.toByteArray();
}
 
開發者ID:metasfresh,項目名稱:metasfresh,代碼行數:23,代碼來源:AbstractJasperService.java

示例11: generatePdfReport

import net.sf.jasperreports.engine.export.JRPdfExporter; //導入依賴的package包/類
/**
 * 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;
}
 
開發者ID:wso2,項目名稱:carbon-commons,代碼行數:28,代碼來源:PdfReport.java

示例12: exportPrintObject

import net.sf.jasperreports.engine.export.JRPdfExporter; //導入依賴的package包/類
private void exportPrintObject(ReporterConfig rc, final JasperPrint print, final ComponentExecutionApi reporter) {
	// build the export filename
	String filename = buildFilename(reporter, rc);

	// do each export option
	if (rc.isCsv()) {
		export(new JRCsvExporter(), print, filename, "csv", rc.isOpenExportFile());
	}
	if (rc.isDocx()) {
		export(new JRDocxExporter(), print, filename, "docx", rc.isOpenExportFile());
	}
	if (rc.isOdt()) {
		export(new JROdtExporter(), print, filename, "odt", rc.isOpenExportFile());
	}
	if (rc.isHtml()) {
		export(new JRHtmlExporter(), print, filename, "html", rc.isOpenExportFile());
	}
	if (rc.isPdf()) {
		export(new JRPdfExporter(), print, filename, "pdf", rc.isOpenExportFile());
	}
	if (rc.isXls()) {
		export(new JRXlsExporter(), print, filename, "xls", rc.isOpenExportFile());
	}

	// do show viewer at the end so it pops up after everything else
	if (rc.isShowViewer()) {
		reporter.submitControlLauncher(new ControlLauncherCallback() {
			
			@Override
			public void launchControls(ComponentControlLauncherApi launcherApi) {
				class DisposableViewer extends JRViewer implements Disposable {

					DisposableViewer(JasperPrint jrPrint) {
						super(jrPrint);
					}

					@Override
					public void dispose() {
					}

				}
				DisposableViewer viewer = new DisposableViewer(print);
				launcherApi.registerPanel("report", null, viewer, true);
			}
		});

	}
}
 
開發者ID:PGWelch,項目名稱:com.opendoorlogistics,代碼行數:49,代碼來源:ReporterComponent.java

示例13: getPdf

import net.sf.jasperreports.engine.export.JRPdfExporter; //導入依賴的package包/類
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;
}
 
開發者ID:nextreports,項目名稱:nextreports-server,代碼行數:20,代碼來源:JasperReportsUtil.java

示例14: exportPdf

import net.sf.jasperreports.engine.export.JRPdfExporter; //導入依賴的package包/類
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) {

    }
}
 
開發者ID:malike,項目名稱:elasticsearch-report-engine,代碼行數:13,代碼來源:GeneratePDFReport.java

示例15: genPDF

import net.sf.jasperreports.engine.export.JRPdfExporter; //導入依賴的package包/類
/**
 * Метод генерации PDF-отчетов через файл. Вынесен в отдельный метод для синхронизации.
 *
 * @param jasperPrint этот готовый отчет и экспортим в PDF
 * @return возвращает готовый отчет в виде массива байт
 */
synchronized private static byte[] genPDF(JasperPrint jasperPrint)
    throws JRException, FileNotFoundException, IOException {
    // сгенерим отчет во временный файл
    JRPdfExporter exporter = new JRPdfExporter();
    exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
    exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME,
        Uses.TEMP_FOLDER + File.separator + "temppdf.pdf");
    exporter.exportReport();
    // отправим данные из файла и удалим его
    final File pdf = new File(Uses.TEMP_FOLDER + File.separator + "temppdf.pdf");
    final FileInputStream inStream = new FileInputStream(pdf);
    pdf.delete();
    return Uses.readInputStream(inStream);
}
 
開發者ID:bcgov,項目名稱:sbc-qsystem,代碼行數:21,代碼來源:AGenerator.java


注:本文中的net.sf.jasperreports.engine.export.JRPdfExporter類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。