Posts

Showing posts with the label pdf export

Export Jasper Report As PDF And Content Disposition

public void createPdfInvoice(String inputFileName, String outputFileName, Collection dataCollection, Map inputParameters) throws Exception { FacesContext fc = FacesContext.getCurrentInstance(); ServletContext context = (ServletContext) FacesContext.getCurrentInstance().getExternalContext().getContext(); HttpServletResponse response = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext().getResponse(); ServletOutputStream servletOutputStream = response.getOutputStream(); String jrxmlReportPath = context.getRealPath("/WEB-INF/resources/report/" + inputFileName + ".jrxml"); response.setContentType("application/pdf"); try { JasperCompileManager.compileReportToFile(jrxmlReportPath); } catch (Exception e) { System.out.println("jrxml exception :::: createReportAsPdf"); e.printStackTrace(); } try { ...

Export Jasper Report As PDF And Save Into FileSystem

public void savePdfInvoice(String inputFileName, String outputFileName, Collection dataCollection, Map inputParameters) throws Exception { ServletContext context = (ServletContext) FacesContext.getCurrentInstance().getExternalContext().getContext(); String jrxmlReportPath = context.getRealPath("/WEB-INF/resources/report/" + inputFileName + ".jrxml"); try { JasperReport jasperReport = JasperCompileManager.compileReport(jrxmlReportPath); JRBeanCollectionDataSource jrbcds = new JRBeanCollectionDataSource(dataCollection); /*if (jrbcds == null) { System.out.println("....JRBCDS is null"); } if (inputParameters == null) { System.out.println("....inputParameters is null"); } */ JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, inputParameters, jrbcds); S...