Created
November 1, 2022 22:03
-
-
Save bjoerntx/c36aa92e21a50430dd00e84b35bd72f1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
public IActionResult Index() { | |
// load the JSON data | |
string jsonData = System.IO.File.ReadAllText("App_Data/data.json"); | |
using (TXTextControl.ServerTextControl tx = new TXTextControl.ServerTextControl()) { | |
tx.Create(); | |
// load the template | |
tx.Load("App_Data/template.tx", TXTextControl.StreamType.InternalUnicodeFormat); | |
// use MailMerge to merge data | |
using (TXTextControl.DocumentServer.MailMerge mm = | |
new TXTextControl.DocumentServer.MailMerge()) { | |
mm.TextComponent = tx; | |
mm.MergeJsonData(jsonData); | |
} | |
// return result as HTML | |
string result = ""; | |
tx.Save(out result, TXTextControl.StringStreamType.HTMLFormat); | |
ViewBag.Document = result; | |
} | |
return View(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment