Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Created February 21, 2022 21:26
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/c91680d370a5904739a775b4276087a0 to your computer and use it in GitHub Desktop.
Save bjoerntx/c91680d370a5904739a775b4276087a0 to your computer and use it in GitHub Desktop.
// create the pre-populate data object
HealthcareForm data = new HealthcareForm() {
insurance_date = DateTime.Now,
insurance_name = "Global Health",
insurance_check = true,
insurance_state = "North Carolina",
notes = "Thanks for your business."
};
using (TXTextControl.ServerTextControl tx = new TXTextControl.ServerTextControl()) {
tx.Create();
// load the template
tx.Load("App_Data/health_form.tx", TXTextControl.StreamType.InternalUnicodeFormat);
using (MailMerge mm = new MailMerge()) {
mm.TextComponent = tx;
// pre-populate the form fields
mm.FormFieldMergeType = FormFieldMergeType.Preselect;
mm.MergeObject(data);
}
// save document as PDF
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