Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Generate PDF Report from JSON data using Template in Java
// 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);
// Generate PDF 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