Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @RequestMapping(value = "/detail/reportPDF", method = RequestMethod.GET)
- public @ResponseBody void reportPDF(HttpServletResponse response) {
- {
- logger.debug("########################### getValidationErrorLogPDF controller is called.");
- try
- {
- InputStream jasperStream = (InputStream) this.getClass().getResourceAsStream("/report/ValidationErrorLog.jrxml");
- JasperDesign design = JRXmlLoader.load(jasperStream);
- JasperReport report = JasperCompileManager.compileReport(design);
- Map<String, Object> parameterMap = new HashedMap();
- List<ValidationErrorLogDetail> errorLogDetails = (List<ValidationErrorLogDetail>) validationErrorLogDetailRepository.findAll();
- JRDataSource jrDataSource = new JRBeanCollectionDataSource(errorLogDetails);
- parameterMap.put("datasource", jrDataSource);
- JasperPrint jasperPrint = JasperFillManager.fillReport(report, parameterMap, jrDataSource);
- response.setContentType("application/x-pdf");
- response.setHeader("Content-Disposition", "inline: filename=report.pdf");
- final OutputStream outputStream = response.getOutputStream();
- JasperExportManager.exportReportToPdfStream(jasperPrint, outputStream);
- } catch (JRException ex) {
- Log.info("tidak membaca file");
- } catch (IOException ex) {
- Log.info("tidak bisa mengambil output dari response");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement