本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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);
}
}