Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Created May 5, 2022 14:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bjoerntx/1007f59eb564dc446fcfd4fea9098f62 to your computer and use it in GitHub Desktop.
Save bjoerntx/1007f59eb564dc446fcfd4fea9098f62 to your computer and use it in GitHub Desktop.
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