Last active
May 24, 2022 14:07
-
-
Save bjoerntx/2e4e7f1584ed6b50f4866b7320d67e46 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