Created
October 17, 2017 12:20
-
-
Save bjoerntx/332b0f7cf60b2ee5d3b63156f4b165e9 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// 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); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment