Created
May 5, 2022 14:42
-
-
Save bjoerntx/1007f59eb564dc446fcfd4fea9098f62 to your computer and use it in GitHub Desktop.
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
TXTextControl.LoadSettings ls = new TXTextControl.LoadSettings() { | |
ApplicationFieldFormat = TXTextControl.ApplicationFieldFormat.MSWord }; | |
string jsonData = System.IO.File.ReadAllText("data.json"); | |
using (TXTextControl.ServerTextControl serverTextControl = | |
new TXTextControl.ServerTextControl()) { | |
serverTextControl.Create(); | |
serverTextControl.Load("template.docx", TXTextControl.StreamType.WordprocessingML, ls); | |
using (MailMerge mailMerge = new MailMerge()) { | |
mailMerge.TextComponent = serverTextControl; | |
mailMerge.MergeJsonData(jsonData); | |
} | |
// export document as PDF | |
serverTextControl.Save("results.pdf", TXTextControl.StreamType.AdobePDF); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment