Last active
February 14, 2022 14:52
-
-
Save bjoerntx/d5567e638f50511287f0d9480e283ec7 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
// new non-UI ServerTextControl | |
using (TXTextControl.ServerTextControl tx = new TXTextControl.ServerTextControl()) { | |
tx.Create(); | |
// loda a template | |
tx.Load("App_Data/template.tx", TXTextControl.StreamType.InternalUnicodeFormat); | |
// load data from file | |
var sData = System.IO.File.ReadAllText("App_Data/data.json"); | |
// merge data | |
using (TXTextControl.DocumentServer.MailMerge mm = | |
new TXTextControl.DocumentServer.MailMerge()) { | |
mm.TextComponent = tx; | |
mm.MergeJsonData(sData); | |
} | |
// save the document into a byte array | |
byte[] document; | |
tx.Save(out document, TXTextControl.BinaryStreamType.AdobePDF); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment