Skip to content

Instantly share code, notes, and snippets.

@GroupDocsGists
Created September 4, 2021 16:33
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 GroupDocsGists/ea7405ab3694830098c08589057c385c to your computer and use it in GitHub Desktop.
Save GroupDocsGists/ea7405ab3694830098c08589057c385c to your computer and use it in GitHub Desktop.
Convert XML data to Generate PDF and Word Reports using Template in CSharp
// Generate PDF Report from XML data using TXT template in CSharp
// Define datasource, template, and output report files.
string xmlDataSource = @"dataPath/Managers.xml";
string templateFilePath = @"templatePath/xml-template.txt";
string reportFilePath = @"reportsPath/xml-to-pdf-report.pdf";
// Load XML data source
XmlDataSource dataSource = new XmlDataSource(xmlDataSource);
// Assemble document to generate PDF
DocumentAssembler assembler = new DocumentAssembler();
assembler.AssembleDocument(templateFilePath, reportFilePath, new DataSourceInfo(dataSource, "managers"));
// Generate MS Word Report from XML data using text template in CSharp
// Define datasource, template, and output report files.
string xmlDataSource = @"dataPath/Managers.xml";
string templateFilePath = @"templatePath/xml-template.txt";
string reportFilePath = @"reportsPath/xml-to-word-report.docx";
// Load XML data source
XmlDataSource dataSource = new XmlDataSource(xmlDataSource);
// Assemble document to generate Word Report
DocumentAssembler assembler = new DocumentAssembler();
assembler.AssembleDocument(templateFilePath, reportFilePath, new DataSourceInfo(dataSource, "managers"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment