public MergedDocument MergeDocument([FromBody] MergedDocument Document) { byte[] data; Customer customer = new Customer() { Firstname = "Klaus", Name = "Klaasen" }; using (TXTextControl.ServerTextControl tx = new TXTextControl.ServerTextControl()) { tx.Create(); tx.Load(Convert.FromBase64String(Document.Document), TXTextControl.BinaryStreamType.InternalUnicodeFormat); TXTextControl.DocumentServer.MailMerge mm = new TXTextControl.DocumentServer.MailMerge(); mm.TextComponent = tx; mm.MergeObject(customer); tx.Save(out data, TXTextControl.BinaryStreamType.InternalUnicodeFormat); return(new MergedDocument() { Document = Convert.ToBase64String(data) }); } }
private void RbPreview_Click(object sender, EventArgs e) { // create a MailMerge instance TXTextControl.DocumentServer.MailMerge mailMerge = new TXTextControl.DocumentServer.MailMerge() { TextComponent = textControl1 }; // attach the IncludeTextMerging event mailMerge.IncludeTextMerging += MailMerge_IncludeTextMerging; // merge template with dummy data mailMerge.MergeObject(report); }