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


Java JasperExportManager.exportReportToPdfStream方法代碼示例

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


在下文中一共展示了JasperExportManager.exportReportToPdfStream方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: savePDFReportToOutputStream

import net.sf.jasperreports.engine.JasperExportManager; //導入方法依賴的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

示例2: showJasperManagerPDF

import net.sf.jasperreports.engine.JasperExportManager; //導入方法依賴的package包/類
@RequestMapping(value = "/hrms/showJasperManagerPDF", method = RequestMethod.GET)
public String showJasperManagerPDF(ModelMap model,
		HttpServletRequest request, HttpServletResponse response)
		throws ServletException, IOException, JRException, NamingException {

	usersList = loginService.getUserList();

	AdminJasperBase dsUsers = new AdminJasperBase(usersList);
	Map<String, Object> params = new HashMap<>();
	params.put("users", usersList);
	JasperReport jasperReport = getCompiledFile("JRUsers", request);
	JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport,
			params, dsUsers);

	response.setContentType("application/x-pdf");
	response.setHeader("Content-disposition",
			"inline; filename=userList.pdf");

	final OutputStream outStream = response.getOutputStream();
	JasperExportManager.exportReportToPdfStream(jasperPrint, outStream);

	return null;
}
 
開發者ID:PacktPublishing,項目名稱:Spring-MVC-Blueprints,代碼行數:24,代碼來源:AdminJasperReport.java

示例3: emitir

import net.sf.jasperreports.engine.JasperExportManager; //導入方法依賴的package包/類
@Override
public void emitir() throws JRException {
	try (InputStream relatorioArquivoStream = this.getClass().getResourceAsStream(relatorio.getArquivo().getCaminho())) {
		JasperPrint print = JasperFillManager.fillReport(relatorioArquivoStream, relatorio.getParametros(), connection);
		this.relatorioGerado = print.getPages().size() > 0;
		
		if(this.isRelatorioGerado()) {
			String attachment = String.format("attachment; filename=\"%s.pdf\"", relatorio.getArquivo().getNome());
			servletResponse.setHeader("Content-Disposition", attachment);
			JasperExportManager.exportReportToPdfStream(print, servletResponse.getOutputStream());		
		}
	} catch (IOException e) {
		throw new RelatorioNaoExisteException(relatorio, e);
	}
}
 
開發者ID:marcelothebuilder,項目名稱:webpedidos,代碼行數:16,代碼來源:EmissorRelatorioServlet.java

示例4: generatePdf

import net.sf.jasperreports.engine.JasperExportManager; //導入方法依賴的package包/類
@RequestMapping("/pdf")
@ResponseBody
public void generatePdf(HttpServletResponse response) throws JRException, IOException{
    JasperPrint materiReport = generateMateriJasperReport();
    response.setContentType("application/x-pdf");
    response.setHeader("Content-disposition", "attachment; filename=daftar-materi.pdf");
    JasperExportManager.exportReportToPdfStream(materiReport, response.getOutputStream());
}
 
開發者ID:endymuhardin,項目名稱:training-brainmatics-2016-01,代碼行數:9,代碼來源:MateriController.java


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