Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Created November 12, 2024 17:49
Show Gist options
  • Save bjoerntx/74d0e9c53a783a95895f010511dfd733 to your computer and use it in GitHub Desktop.
Save bjoerntx/74d0e9c53a783a95895f010511dfd733 to your computer and use it in GitHub Desktop.
using (ServerTextControl tx = new ServerTextControl()) {
tx.Create();
tx.Load("patient_history.tx", StreamType.InternalUnicodeFormat);
using (MailMerge mailMerge = new MailMerge()) {
mailMerge.TextComponent = tx;
if (flatten == false)
mailMerge.FormFieldMergeType = FormFieldMergeType.Preselect;
else
mailMerge.FormFieldMergeType = FormFieldMergeType.Replace;
mailMerge.RemoveEmptyBlocks = false;
string jsonData = System.IO.File.ReadAllText("patient-data.json");
mailMerge.MergeJsonData(jsonData);
}
// export to PDF
tx.Save("results.pdf", StreamType.InternalUnicodeFormat);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment