Skip to content

Instantly share code, notes, and snippets.

@quchie
Created November 18, 2016 07:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save quchie/5c745682c032bc638c299ee3775c0cb1 to your computer and use it in GitHub Desktop.
Save quchie/5c745682c032bc638c299ee3775c0cb1 to your computer and use it in GitHub Desktop.
Jasper print with XML datasource (API 6.x.x)
//Forget about XML datasource, somehow it wont work... :( just need to pass xml in parameters to make it work..
//Lets say we have strings of XML or XML file or whatever in xml
String xmlDoc = '''<tag>PMHGK5860HD301330</tag>'''
Map parameters = new HashMap();
parameters.put(JRXPathQueryExecuterFactory.PARAMETER_XML_DATA_DOCUMENT, xmlDoc);
parameters.put("chasisno", chassisno);
parameters.put("imgFolderPath", path);
JasperPrint jasperPrint = JasperFillManager.fillReport("REPORT_FILE.jasper", parameters, connection);
//Go ahead and print how ever you want (This is windows path) :)
JasperExportManager.exportReportToPdfFile(jasperPrint, "C:\\REPORTS\\REPORT_FILE.pdf");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment