Last active
October 8, 2020 11:55
-
-
Save bjoerntx/4ec70c69a485df6d58b44c188cbbfbae 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
[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