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) }); } }
public string DocumentToString(MergedDocument document) { var person = _personFormatter.PersonToString(document.Person); var address = _addressFormatter.AddressToString(document.Person.Address); var tokenizedDocument = document.Document.TokenizedDocument; tokenizedDocument = tokenizedDocument.Replace(document.Document.GreetingToken, person); tokenizedDocument = tokenizedDocument.Replace(document.Document.AdressToken, address); return tokenizedDocument; }
private async void OkButton_Click(object sender, EventArgs e) { Hide(); parentForm.ShowStatus("处理中..."); parentForm.ShowProgress(true); MergedDocument mergedDocument = new MergedDocument(withBookmark, filePaths); string target = await mergedDocument.Run(); parentForm.ShowStatus("完成"); parentForm.ShowProgress(false); parentForm.ShowContent(@"目标文件: " + target); }
public string DocumentToString(MergedDocument document) { // TODO read the document and replace any tokens using their respective formatter string address = _addressFormatter.AddressToString(document.Person); string greeting = _greetingFormatter.PersonToGreeting(document.Person); string documentString = document.Document.TokenizedDocument; // TODO replace tokens documentString = TokenReplacer.Replace(documentString, document.Document.AddressToken, address); documentString = TokenReplacer.Replace(documentString, document.Document.GreetingToken, greeting); return documentString; }
public void Print(MergedDocument document) { var formatted = _documentFormatter.DocumentToString(document); _printer.Print(formatted); }