Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Created October 20, 2023 15:02
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/22f2b49057a9ce5bef42069e22a0f994 to your computer and use it in GitHub Desktop.
Save bjoerntx/22f2b49057a9ce5bef42069e22a0f994 to your computer and use it in GitHub Desktop.
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