本文整理匯總了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);
}
}
示例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;
}
示例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);
}
}
示例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());
}