lgameror Posted February 6 Share Posted February 6 Hi, I have public ResponseObjectVO generatePDFReport(HttpServletResponse response, @RequestBody RequestReportVO requestReportVO) where RequestReportVO have two attributes private Object data; //JSON private String reportName; // Template String filePath = reportPath; filePath = filePath + File.separatorChar + reportName; JasperReport report; report = JasperCompileManager.compileReport(filePath.concat(JRXML_EXT)); //Data Source List<Object> listData = new LinkedList<>(); Object data = requestReportVO.getData(); listData.add(data); JRDataSource dataSource = new JsonDataCollection<>(listData); // How to pass a JSON???????? // Print JasperPrint jPrint = JasperFillManager.fillReport(report, null, dataSource); String filename = reportName; filename = filename.concat(PDF_EXT); String target = "D:" + File.separatorChar; JasperExportManager.exportReportToPdfFile(jPrint, target + filename); Link to comment Share on other sites More sharing options...
lgameror Posted February 7 Author Share Posted February 7 For example, this is the object that is received by the service: { "data":[ { "id": 25, "name": "Pepito" } ], "reportName": "HelloWorld" } Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now