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


Java JasperRunManager.runReportToPdfStream方法代码示例

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


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

示例1: generateHsfoRxPDF

import net.sf.jasperreports.engine.JasperRunManager; //导入方法依赖的package包/类
private ByteArrayOutputStream generateHsfoRxPDF(HttpServletRequest req){
    HsfoRxDataHolder rx = (HsfoRxDataHolder) req.getSession()
    .getAttribute(HSFO_RX_DATA_KEY);

    JRBeanCollectionDataSource ds = new JRBeanCollectionDataSource(rx.getOutlines());
    InputStream is = Thread.currentThread().getContextClassLoader()
    .getResourceAsStream("/oscar/form/prop/Hsfo_Rx.jasper");

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    try {
        JasperRunManager.runReportToPdfStream(is, baos, rx.getParams(), ds);
    } catch (JRException e) {
        throw new RuntimeException(e);
    }
    return baos;
}
 
开发者ID:oscarservice,项目名称:oscar-old,代码行数:17,代码来源:FrmPDFServlet.java

示例2: generateHsfoRxPDF

import net.sf.jasperreports.engine.JasperRunManager; //导入方法依赖的package包/类
private ByteArrayOutputStream generateHsfoRxPDF(HttpServletRequest req) {

		HsfoRxDataHolder rx = (HsfoRxDataHolder) req.getSession().getAttribute(HSFO_RX_DATA_KEY);

		JRBeanCollectionDataSource ds = new JRBeanCollectionDataSource(rx.getOutlines());
		InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("/oscar/form/prop/Hsfo_Rx.jasper");

		ByteArrayOutputStream baos = new ByteArrayOutputStream();
		try {
			JasperRunManager.runReportToPdfStream(is, baos, rx.getParams(), ds);
		} catch (JRException e) {
			throw new RuntimeException(e);
		}
		return baos;
	}
 
开发者ID:williamgrosset,项目名称:OSCAR-ConCert,代码行数:16,代码来源:FrmCustomedPDFServlet.java

示例3: generateHsfoRxPDF

import net.sf.jasperreports.engine.JasperRunManager; //导入方法依赖的package包/类
private ByteArrayOutputStream generateHsfoRxPDF(HttpServletRequest req){
    HsfoRxDataHolder rx = (HsfoRxDataHolder) req.getSession()
    .getAttribute(HSFO_RX_DATA_KEY);

    JRBeanCollectionDataSource ds = new JRBeanCollectionDataSource(rx.getOutlines());
    ByteArrayOutputStream baos = new ByteArrayOutputStream();

    InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("/oscar/form/prop/Hsfo_Rx.jasper");
   
    try {
        JasperRunManager.runReportToPdfStream(is, baos, rx.getParams(), ds);
    } catch (JRException e) {
        throw new RuntimeException(e);
    }
    finally {
    	IOUtils.closeQuietly(is);
    }
    
    return baos;
}
 
开发者ID:williamgrosset,项目名称:OSCAR-ConCert,代码行数:21,代码来源:FrmPDFServlet.java

示例4: generateReportToOutputStream

import net.sf.jasperreports.engine.JasperRunManager; //导入方法依赖的package包/类
/**
 * @see org.kuali.kfs.sys.batch.service.ReportGenerationService#generateReportToOutputStream(java.util.Map, java.lang.Object,
 *      java.lang.String, java.io.ByteArrayOutputStream)
 */
public void generateReportToOutputStream(Map<String, Object> reportData, Object dataSource, String template, ByteArrayOutputStream baos) {
    ClassPathResource resource = getReportTemplateClassPathResource(template.concat(ReportGeneration.DESIGN_FILE_EXTENSION));
    if (resource == null || !resource.exists()) {
        throw new IllegalArgumentException("Cannot find the template file: " + template.concat(ReportGeneration.DESIGN_FILE_EXTENSION));
    }

    try {
        if (reportData != null && reportData.containsKey(ReportGeneration.PARAMETER_NAME_SUBREPORT_TEMPLATE_NAME)) {
            Map<String, String> subReports = (Map<String, String>) reportData.get(ReportGeneration.PARAMETER_NAME_SUBREPORT_TEMPLATE_NAME);
            String subReportDirectory = (String) reportData.get(ReportGeneration.PARAMETER_NAME_SUBREPORT_DIR);
            compileSubReports(subReports, subReportDirectory);
        }

        String designTemplateName = template.concat(ReportGeneration.DESIGN_FILE_EXTENSION);
        InputStream jasperReport = new FileInputStream(compileReportTemplate(designTemplateName));

        JRDataSource jrDataSource = JasperReportsUtils.convertReportData(dataSource);

         JasperRunManager.runReportToPdfStream(jasperReport, baos, decorateReportData(reportData), jrDataSource);
    }
    catch (Exception e) {
        LOG.error(e);
        throw new RuntimeException("Fail to generate report.", e);
    }
}
 
开发者ID:kuali,项目名称:kfs,代码行数:30,代码来源:ReportGenerationServiceImpl.java

示例5: generateReportToOutputStream

import net.sf.jasperreports.engine.JasperRunManager; //导入方法依赖的package包/类
/**
 * @see org.kuali.ole.sys.batch.service.ReportGenerationService#generateReportToOutputStream(java.util.Map, java.lang.Object,
 *      java.lang.String, java.io.ByteArrayOutputStream)
 */
public void generateReportToOutputStream(Map<String, Object> reportData, Object dataSource, String template, ByteArrayOutputStream baos) {
    ClassPathResource resource = getReportTemplateClassPathResource(template);
    if (resource == null || !resource.exists()) {
        throw new IllegalArgumentException("Cannot find the template file: " + template);
    }

    try {
        if (reportData != null && reportData.containsKey(PARAMETER_NAME_SUBREPORT_TEMPLATE_NAME)) {
            Map<String, String> subReports = (Map<String, String>) reportData.get(PARAMETER_NAME_SUBREPORT_TEMPLATE_NAME);
            String subReportDirectory = (String) reportData.get(PARAMETER_NAME_SUBREPORT_DIR);
            compileSubReports(subReports, subReportDirectory);
        }

        String realTemplateNameWithoutExtension = removeTemplateExtension(resource);
        String designTemplateName = realTemplateNameWithoutExtension.concat(DESIGN_FILE_EXTENSION);
        String jasperReportName = realTemplateNameWithoutExtension.concat(JASPER_REPORT_EXTENSION);
        compileReportTemplate(designTemplateName, jasperReportName);

        JRDataSource jrDataSource = JasperReportsUtils.convertReportData(dataSource);

        InputStream inputStream = new FileInputStream(jasperReportName);

        JasperRunManager.runReportToPdfStream(inputStream, (OutputStream) baos, reportData, jrDataSource);
    }
    catch (Exception e) {
        LOG.error(e);
        throw new RuntimeException("Fail to generate report.", e);
    }
}
 
开发者ID:VU-libtech,项目名称:OLE-INST,代码行数:34,代码来源:ReportGenerationServiceImpl.java

示例6: generateReportToPdfFile

import net.sf.jasperreports.engine.JasperRunManager; //导入方法依赖的package包/类
/**
 * The dataSource can be an instance of JRDataSource, java.util.Collection or object array.
 * 
 * @see org.kuali.kfs.sys.batch.service.ReportGenerationService#generateReportToPdfFile(java.util.Map, java.lang.Object, java.lang.String,
 *      java.lang.String)
 */
public void generateReportToPdfFile(Map<String, Object> reportData, Object dataSource, String template, String reportFileName) {
    ClassPathResource resource = getReportTemplateClassPathResource(template.concat(ReportGeneration.DESIGN_FILE_EXTENSION));
    if (resource == null || !resource.exists()) {
        throw new IllegalArgumentException("Cannot find the template file: " + template.concat(ReportGeneration.DESIGN_FILE_EXTENSION));
    }

    try {
        if (reportData != null && reportData.containsKey(ReportGeneration.PARAMETER_NAME_SUBREPORT_TEMPLATE_NAME)) {
            Map<String, String> subReports = (Map<String, String>) reportData.get(ReportGeneration.PARAMETER_NAME_SUBREPORT_TEMPLATE_NAME);
            String subReportDirectory = (String) reportData.get(ReportGeneration.PARAMETER_NAME_SUBREPORT_DIR);
            compileSubReports(subReports, subReportDirectory);
        }

        String designTemplateName = template.concat(ReportGeneration.DESIGN_FILE_EXTENSION);
        InputStream jasperReport = new FileInputStream(compileReportTemplate(designTemplateName));

        JRDataSource jrDataSource = JasperReportsUtils.convertReportData(dataSource);

        reportFileName = reportFileName + ReportGeneration.PDF_FILE_EXTENSION;
        File reportDirectory = new File(StringUtils.substringBeforeLast(reportFileName, File.separator));
        if(!reportDirectory.exists()) {
            reportDirectory.mkdir();
        }

        JasperRunManager.runReportToPdfStream(jasperReport, new FileOutputStream(reportFileName), decorateReportData(reportData), jrDataSource);
    }
    catch (Exception e) {
        LOG.error(e);
        throw new RuntimeException("Fail to generate report.", e);
    }
}
 
开发者ID:kuali,项目名称:kfs,代码行数:38,代码来源:ReportGenerationServiceImpl.java


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