Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Created March 15, 2024 15:44
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/f4415638fed2e4f6c433c232bbee25dd to your computer and use it in GitHub Desktop.
Save bjoerntx/f4415638fed2e4f6c433c232bbee25dd to your computer and use it in GitHub Desktop.
[HttpPost]
[Route("MergeTemplate")]
public MailMergeData MergeTemplate([FromBody] MailMergeData mailMergeData)
{
using (var tx = new TXTextControl.ServerTextControl())
{
tx.Create();
byte[] templateData = Convert.FromBase64String(mailMergeData.Template);
tx.Load(templateData, TXTextControl.BinaryStreamType.InternalUnicodeFormat);
var merge = new MailMerge
{
TextComponent = tx
};
merge.MergeJsonData(mailMergeData.Json);
byte[] documentData;
tx.Save(out documentData, TXTextControl.BinaryStreamType.InternalUnicodeFormat);
mailMergeData.Document = Convert.ToBase64String(documentData);
return mailMergeData;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment