Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Created November 18, 2022 21:35
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/0286f6246513782f6e8b6195cf8b464a to your computer and use it in GitHub Desktop.
Save bjoerntx/0286f6246513782f6e8b6195cf8b464a to your computer and use it in GitHub Desktop.
using (TXTextControl.DocumentServer.MailMerge mm = new TXTextControl.DocumentServer.MailMerge()) {
mm.TextComponent = textControl1;
mm.IncludeTextMerging += Mm_IncludeTextMerging;
mm.MergeJsonData(sJsonData);
}
private void Mm_IncludeTextMerging(object sender, TXTextControl.DocumentServer.MailMerge.IncludeTextMergingEventArgs e) {
if (e.IncludeTextField.Filename == "subtemplate.docx") {
byte[] data;
using (TXTextControl.ServerTextControl tx = new TXTextControl.ServerTextControl()) {
tx.Create();
tx.Load("<span style=\"color: red\">This</span> is the content that should be <strong>merged into the IncludeText field</strong>.",
TXTextControl.StringStreamType.HTMLFormat);
tx.Save(out data, TXTextControl.BinaryStreamType.InternalUnicodeFormat);
}
e.IncludeTextDocument = data;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment