Created
January 27, 2022 11:14
-
-
Save bjoerntx/4388124e3457b0a02f8f67f5cb6e55bd 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
[HttpGet] | |
public IActionResult MergeDocument() | |
{ | |
byte[] bDocument; | |
// create a ServerTextControl | |
using (TXTextControl.ServerTextControl tx = new TXTextControl.ServerTextControl()) { | |
tx.Create(); | |
// load the template | |
tx.Load("App_Data/template.tx", TXTextControl.StreamType.InternalUnicodeFormat); | |
// create the mail merge engine | |
using (TXTextControl.DocumentServer.MailMerge mm = new TXTextControl.DocumentServer.MailMerge()) | |
{ | |
// connect to ServerTextControl instance | |
mm.TextComponent = tx; | |
// merge data | |
var jsonData = System.IO.File.ReadAllText("App_Data/data.json"); | |
mm.MergeJsonData(jsonData); | |
} | |
// save in the internal format | |
tx.Save(out bDocument, TXTextControl.BinaryStreamType.InternalUnicodeFormat); | |
} | |
return Ok(bDocument); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment