Created
July 10, 2021 09:53
-
-
Save GroupDocsGists/836ca189a2cb4d2a7e5283c47a5a70ce to your computer and use it in GitHub Desktop.
Convert XML data to Generate PDF and Word Reports using Template in Java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Generate PDF Report from XML data using TXT template in Java | |
// Define datasource, template, and output report files. | |
String xmlDataSource = "dataPath/Managers.xml"; | |
String templateFilePath = "templatePath/template.txt"; | |
String reportFilePath = "reportsPath/PDFreportFromXML.pdf"; | |
// Load XML data source | |
XmlDataSource datasource = new XmlDataSource(xmlDataSource); | |
DataSourceInfo dataSourceInfo = new DataSourceInfo(datasource,"managers"); | |
// Assemble document to generate PDF | |
DocumentAssembler assembler = new DocumentAssembler(); | |
assembler.assembleDocument(templateFilePath, reportFilePath,dataSourceInfo); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Generate MS Word Report from XML data using text template in Java | |
// Define datasource, template, and output report files. | |
String xmlDataSource = "dataPath/Managers.xml"; | |
String templateFilePath = "templatePath/template.docx"; | |
String reportFilePath = "reportsPath/WordReportFromXML.docx"; | |
//Instantiate XML data source | |
XmlDataSource datasource = new XmlDataSource(xmlDataSource); | |
DataSourceInfo dataSourceInfo = new DataSourceInfo(datasource,"managers"); | |
//Assemble document | |
DocumentAssembler assembler = new DocumentAssembler(); | |
assembler.assembleDocument(templateFilePath, reportFilePath,dataSourceInfo); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment