Last active
March 19, 2021 17:36
-
-
Save GroupDocsGists/7aa7fe4f1a969e13339ace6ba8c51906 to your computer and use it in GitHub Desktop.
Generate PDF or Word Report from JSON data 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 JSON data using TXT template in Java with GroupDocs.Assembly API | |
// Define datasource, template, and output report files. | |
String jsonFilePath = "dataPath/ManagerData.json"; | |
String templateFilePath = "templatePath/template.txt"; | |
String reportFilePath = "reportsPath/reportFromJSON.pdf"; | |
// Instantiate JSON data source | |
JsonDataSource datasource= new JsonDataSource(jsonFilePath); | |
DataSourceInfo dataSourceInfo = new DataSourceInfo(datasource,"managers"); | |
// Generate Report | |
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 Word Report from JSON data using DOCX template in Java with GroupDocs.Assembly API | |
// Define datasource, template, and output report files. | |
String jsonFilePath = "dataPath/ManagerData.json"; | |
String templateFilePath = "templatePath/template.docx"; | |
String reportFilePath = "reportsPath/reportFromJSON.docx"; | |
// Instantiate JSON data source | |
JsonDataSource datasource= new JsonDataSource(jsonFilePath); | |
DataSourceInfo dataSourceInfo = new DataSourceInfo(datasource,"managers"); | |
// Generate Report | |
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