Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Created March 15, 2023 16:54
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/b55b2405a4dead35d637ca00bfe20c4d to your computer and use it in GitHub Desktop.
Save bjoerntx/b55b2405a4dead35d637ca00bfe20c4d to your computer and use it in GitHub Desktop.
public IActionResult Create(FormData data) {
SignData signData = new SignData();
byte[] document;
using (TXTextControl.ServerTextControl tx = new TXTextControl.ServerTextControl()) {
tx.Create();
tx.Load("App_Data/vaccination_form.tx", TXTextControl.StreamType.InternalUnicodeFormat);
using (TXTextControl.DocumentServer.MailMerge mm = new TXTextControl.DocumentServer.MailMerge()) {
mm.TextComponent = tx;
mm.FormFieldMergeType = TXTextControl.DocumentServer.FormFieldMergeType.Preselect;
mm.RemoveEmptyFields = false;
// pre-select form fields with known data and merge
// data into merge fields
mm.MergeObject(data);
}
tx.Save(out document, TXTextControl.BinaryStreamType.InternalUnicodeFormat);
}
signData.document = document;
signData.formData = data;
return View(signData);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment