当前位置: 首页>>代码示例>>Java>>正文


Java JRPdfExporter.exportReport方法代码示例

本文整理汇总了Java中net.sf.jasperreports.engine.export.JRPdfExporter.exportReport方法的典型用法代码示例。如果您正苦于以下问题:Java JRPdfExporter.exportReport方法的具体用法?Java JRPdfExporter.exportReport怎么用?Java JRPdfExporter.exportReport使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.sf.jasperreports.engine.export.JRPdfExporter的用法示例。


在下文中一共展示了JRPdfExporter.exportReport方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: 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

示例12: save

import net.sf.jasperreports.engine.export.JRPdfExporter; //导入方法依赖的package包/类
@Override
public void save(JasperPrint jasperPrint, File file) throws JRException
{
	if (!file.getName().toLowerCase().endsWith(EXTENSION_PDF))
	{
		file = new File(file.getAbsolutePath() + EXTENSION_PDF);
	}
	
	if (
		!file.exists() ||
		JOptionPane.OK_OPTION == 
			JOptionPane.showConfirmDialog(
				null, 
				MessageFormat.format(
					getBundleString("file.exists"),
					new Object[]{file.getName()}
					), 
				getBundleString("save"), 
				JOptionPane.OK_CANCEL_OPTION
				)
		)
	{
		JRPdfExporter exporter = new JRPdfExporter(getJasperReportsContext());
		exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); 
		exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(file));
		exporter.exportReport(); 
	}
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:29,代码来源:JRPdfSaveContributor.java

示例13: exportToPdfFile

import net.sf.jasperreports.engine.export.JRPdfExporter; //导入方法依赖的package包/类
/**
 * 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();
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:22,代码来源:JasperExportManager.java

示例14: exportToPdfStream

import net.sf.jasperreports.engine.export.JRPdfExporter; //导入方法依赖的package包/类
/**
 * 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();
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:21,代码来源:JasperExportManager.java

示例15: exportToPdf

import net.sf.jasperreports.engine.export.JRPdfExporter; //导入方法依赖的package包/类
/**
 * 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();
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:22,代码来源:JasperExportManager.java


注:本文中的net.sf.jasperreports.engine.export.JRPdfExporter.exportReport方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。