Last active
March 19, 2021 17:37
-
-
Save GroupDocsGists/25951e2128f390c6ba1980c1bdaaa9c9 to your computer and use it in GitHub Desktop.
Generate PDF or Word Reports from JSON data using Template in C#
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 C# with GroupDocs.Assembly API | |
// Define datasource, template, and output report files. | |
const string strDataSource = "dataPath/ManagerData.json"; | |
const string strDocumentTemplate = "templatePath/template.txt"; | |
const string strDocumentReport = "reportsPath/reportFromJSON.pdf"; | |
// Instantiate JSON data source | |
JsonDataSource dataSource = new JsonDataSource(CommonUtilities.GetDataSourceDocument(strDataSource)); | |
// Generate Report | |
DocumentAssembler assembler = new DocumentAssembler(); | |
assembler.AssembleDocument(CommonUtilities.GetSourceDocument(strDocumentTemplate), | |
CommonUtilities.SetDestinationDocument(strDocumentReport), | |
new DataSourceInfo(dataSource, "managers")); |
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 C# with GroupDocs.Assembly API | |
// Define datasource, template, and output report files. | |
const string strDataSource = "dataPath/ManagerData.json"; | |
const string strDocumentTemplate = "templatePath/template.docx"; | |
const string strDocumentReport = "reportsPath/reportFromJSON.docx"; | |
// Instantiate JSON data source | |
JsonDataSource dataSource = new JsonDataSource(CommonUtilities.GetDataSourceDocument(strDataSource)); | |
// Generate Report | |
DocumentAssembler assembler = new DocumentAssembler(); | |
assembler.AssembleDocument(CommonUtilities.GetSourceDocument(strDocumentTemplate), | |
CommonUtilities.SetDestinationDocument(strDocumentReport), | |
new DataSourceInfo(dataSource, "managers")); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment