Created
October 20, 2023 15:02
-
-
Save bjoerntx/22f2b49057a9ce5bef42069e22a0f994 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
using TXTextControl.DocumentServer.Fields; | |
using (TXTextControl.ServerTextControl tx = new TXTextControl.ServerTextControl()) | |
{ | |
tx.Create(); | |
TXTextControl.LoadSettings ls = new TXTextControl.LoadSettings() | |
{ | |
ApplicationFieldFormat = TXTextControl.ApplicationFieldFormat.MSWord, | |
LoadSubTextParts = true | |
}; | |
tx.Load("template.docx", TXTextControl.StreamType.WordprocessingML, ls); | |
using (TXTextControl.DocumentServer.MailMerge mailMerge = | |
new TXTextControl.DocumentServer.MailMerge()) | |
{ | |
var jsonData = System.IO.File.ReadAllText("data.json"); | |
mailMerge.TextComponent = tx; | |
mailMerge.MergeJsonData(jsonData); | |
} | |
tx.Save("output.pdf", TXTextControl.StreamType.AdobePDF); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment