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


Java JRPdfExporter.setParameter方法代码示例

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


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

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

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

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

示例6: exportPDF

import net.sf.jasperreports.engine.export.JRPdfExporter; //导入方法依赖的package包/类
private static void exportPDF(JasperPrint jasperPrint) throws Exception
{
	File file = new File("D:/test.pdf");
	System.out.println("Exporting PDF to " + file);
	{
		JRPdfExporter exporter = new JRPdfExporter();
		ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
		exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
		exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, outputStream);
		exporter.setParameter(JRExporterParameter.CHARACTER_ENCODING, "UTF8");
		// JRProperties.setProperty(JRFont.DEFAULT_PDF_FONT_NAME, "arial.ttf");
		exporter.exportReport();
		writeBytes(file, outputStream.toByteArray());
	}
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:16,代码来源:TestJasperPrint.java

示例7: logExportedFiles

import net.sf.jasperreports.engine.export.JRPdfExporter; //导入方法依赖的package包/类
/**
 * @param pdfBytes
 * @param xmlBytes
 * @param pdfName
 * @param xmlName
 * @throws JazzOMRException
 * @throws FileNotFoundException
 * @throws IOException
 */
protected void logExportedFiles(byte[] pdfBytes, byte[] xmlBytes, String pdfName, String xmlName) {
	
	if(!log.isDebugEnabled())
		return;
	
	byte[] pdfFromXML;
	try {
		ByteArrayInputStream bais = new ByteArrayInputStream(xmlBytes);
		JasperPrint jasperPrint = JRPrintXmlLoader.load(bais);
		JRPdfExporter pdfExporter = new JRPdfExporter();
		
		ByteArrayOutputStream baosPDF = new ByteArrayOutputStream();
		pdfExporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
		pdfExporter.setParameter(JRExporterParameter.OUTPUT_STREAM, baosPDF);
		pdfExporter.exportReport();
		
		pdfFromXML = baosPDF.toByteArray();
		
	} catch (JRException e) {
		throw new JazzRuntimeException("erro ao tentar montar relatorio resultado do XML!", e);
	}

	writeToFile(pdfFromXML, "fromXML_"+pdfName);

	writeToFile(pdfBytes, pdfName);

	writeToFile(xmlBytes, xmlName);
}
 
开发者ID:darciopacifico,项目名称:omr,代码行数:38,代码来源:ParticipationHelper.java

示例8: exportToDataHandlerPDF

import net.sf.jasperreports.engine.export.JRPdfExporter; //导入方法依赖的package包/类
/**
 * 
 * @param jp
 * @return
 */
private DataHandler exportToDataHandlerPDF(JasperPrint jp) {
	ByteArrayOutputStream baosPDF = new ByteArrayOutputStream();

	JRPdfExporter exporter = new JRPdfExporter();
	exporter.setParameter(JRExporterParameter.JASPER_PRINT, jp);
	exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, baosPDF);
			
	try {
		exporter.exportReport();
	} catch (JRException e1) {
		throw new JazzOMRRuntimeException("Erro ao tentar exportar relatorio", e1);
	}

	byte[] xmlBytes = null;
	try {
		baosPDF.flush();
		xmlBytes = baosPDF.toByteArray();
		baosPDF.close();
	} catch (IOException e) {
		throw new JazzOMRRuntimeException("Erro ao tentar exportar relatorio", e);
	}

	DataSource source = new ByteArrayDataSource(xmlBytes, "application/pdf");
	DataHandler dataHandler = new DataHandler(source);
	
	return dataHandler;
}
 
开发者ID:darciopacifico,项目名称:omr,代码行数:33,代码来源:ParticipationHelperWS.java

示例9: exportToDataHandlerPDF

import net.sf.jasperreports.engine.export.JRPdfExporter; //导入方法依赖的package包/类
/**
 * 
 * @param jp
 * @return
 */
private DataHandler exportToDataHandlerPDF(JasperPrint jp) {
	ByteArrayOutputStream baosPDF = new ByteArrayOutputStream();

	JRPdfExporter exporter = new JRPdfExporter();
	exporter.setParameter(JRExporterParameter.JASPER_PRINT, jp);
	exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, baosPDF);
			
	try {
		exporter.exportReport();
	} catch (JRException e1) {
		throw new JazzRuntimeException("Erro ao tentar exportar relatorio", e1);
	}

	byte[] xmlBytes = null;
	try {
		baosPDF.flush();
		xmlBytes = baosPDF.toByteArray();
		baosPDF.close();
	} catch (IOException e) {
		throw new JazzRuntimeException("Erro ao tentar exportar relatorio", e);
	}

	DataSource source = new ByteArrayDataSource(xmlBytes, "application/pdf");
	DataHandler dataHandler = new DataHandler(source);
	
	return dataHandler;
}
 
开发者ID:darciopacifico,项目名称:omr,代码行数:33,代码来源:ParticipationHelperWS.java

示例10: getData

import net.sf.jasperreports.engine.export.JRPdfExporter; //导入方法依赖的package包/类
public static byte[] getData(JasperPrint print) {
	JRPdfExporter exporter = new JRPdfExporter();
	exporter.setParameter(JRExporterParameter.CHARACTER_ENCODING, "UTF-8");

	ByteArrayOutputStream os = new ByteArrayOutputStream();
	exporter.setParameter(JRExporterParameter.JASPER_PRINT, print);
	exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, os);
	try {
		exporter.exportReport();

	} catch (JRException e) {

		e.printStackTrace();

	}

	return os.toByteArray();

}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:20,代码来源:JasperReports.java

示例11: createPDF

import net.sf.jasperreports.engine.export.JRPdfExporter; //导入方法依赖的package包/类
public static void createPDF() throws FileNotFoundException, JRException, IOException {
	// TODO Auto-generated method stub

	InputStream jrxmlStream = new FileInputStream("/home/darcio/workspace/modules/JazzAV/bsn/src/main/resources/modeloAdes1.jrxml");

	JasperReport compiled = JasperCompileManager.compileReport(jrxmlStream);

	
	Map rootMap = new HashMap();
	JasperPrint jasperPrint = JasperFillManager.fillReport(compiled, rootMap, new JREmptyDataSource());

	int pageIndex = 0;

	JRPdfExporter exporter = new JRPdfExporter();
	
	
	exporter.setParameter(JRPdfExporterParameter.JASPER_PRINT, jasperPrint);

	exporter.setParameter(JRPdfExporterParameter.OUTPUT_FILE, new File("/home/darcio/workspace/modules/JazzAV/bsn/src/main/resources/modeloAdes1.pdf"));
	
	
	
	exporter.exportReport();


}
 
开发者ID:darciopacifico,项目名称:omr,代码行数:27,代码来源:JasperTeste.java

示例12: logExportedFiles

import net.sf.jasperreports.engine.export.JRPdfExporter; //导入方法依赖的package包/类
/**
 * @param pdfBytes
 * @param xmlBytes
 * @param pdfName
 * @param xmlName
 * @throws JazzOMRException
 * @throws FileNotFoundException
 * @throws IOException
 */
protected void logExportedFiles(byte[] pdfBytes, byte[] xmlBytes, String pdfName, String xmlName) throws JazzOMRException {
	
	
	
	byte[] pdfFromXML;
	try {
		ByteArrayInputStream bais = new ByteArrayInputStream(xmlBytes);
		JasperPrint jasperPrint = JRPrintXmlLoader.load(bais);
		JRPdfExporter pdfExporter = new JRPdfExporter();
		
		ByteArrayOutputStream baosPDF = new ByteArrayOutputStream();
		pdfExporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
		pdfExporter.setParameter(JRExporterParameter.OUTPUT_STREAM, baosPDF);
		pdfExporter.exportReport();
		
		pdfFromXML = baosPDF.toByteArray();
		
	} catch (JRException e) {
		throw new JazzOMRException("erro ao tentar montar relatorio resultado do XML!", e);
	}

	writeToFile(pdfFromXML, "fromXML_"+pdfName);

	writeToFile(pdfBytes, pdfName);

	writeToFile(xmlBytes, xmlName);
}
 
开发者ID:darciopacifico,项目名称:omr,代码行数:37,代码来源:OMRModelTest.java


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