Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // create a business object that is used
- // as the data source
- Invoice invoice = new Invoice() { Name = "Report" };
- using (ServerTextControl tx = new ServerTextControl())
- {
- tx.Create();
- LoadSettings ls = new LoadSettings() {
- ApplicationFieldFormat = ApplicationFieldFormat.MSWord
- };
- // load the created template
- tx.Load("template.docx", StreamType.WordprocessingML, ls);
- // create a new MailMerge engine
- using (MailMerge mailMerge = new MailMerge())
- {
- // connect to ServerTextControl
- mailMerge.TextComponent = tx;
- // merge the template that is loaded with
- // the business object
- mailMerge.MergeObject(invoice);
- }
- // export the document as PDF
- tx.Save("test.pdf", StreamType.AdobePDF);
- }
Add Comment
Please, Sign In to add comment