Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Last active October 8, 2020 11:55
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/4ec70c69a485df6d58b44c188cbbfbae to your computer and use it in GitHub Desktop.
Save bjoerntx/4ec70c69a485df6d58b44c188cbbfbae to your computer and use it in GitHub Desktop.
[HttpPost]
public string MergeDocument(string Document)
{
using (TXTextControl.ServerTextControl tx = new TXTextControl.ServerTextControl())
{
tx.Create();
tx.Load(Convert.FromBase64String(Document),
TXTextControl.BinaryStreamType.InternalUnicodeFormat);
using (TXTextControl.DocumentServer.MailMerge mailMerge =
new TXTextControl.DocumentServer.MailMerge())
{
mailMerge.TextComponent = tx;
mailMerge.FieldMerged += MailMerge_FieldMerged;
string data = System.IO.File.ReadAllText(Server.MapPath("~/App_Data/data.json"));
mailMerge.MergeJsonData(data, false);
}
byte[] results;
tx.Save(out results, TXTextControl.BinaryStreamType.InternalUnicodeFormat);
return Convert.ToBase64String(results);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment