Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Created September 6, 2021 09:50
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/b7c8cceea32df29b6e2b92128a2d76c0 to your computer and use it in GitHub Desktop.
Save bjoerntx/b7c8cceea32df29b6e2b92128a2d76c0 to your computer and use it in GitHub Desktop.
private List<SmartFormField> GetFormFields(byte[] data) {
using (TXTextControl.ServerTextControl tx = new TXTextControl.ServerTextControl()) {
tx.Create();
tx.Load(data, BinaryStreamType.InternalUnicodeFormat);
List<SmartFormField> smartFormFields = new List<SmartFormField>();
foreach (FormField field in tx.FormFields) {
switch (field.GetType().Name) {
case "TextFormField":
smartFormFields.Add(new SmartTextFormField() {
Name = field.Name,
Text = field.Text
});
break;
case "CheckFormField":
smartFormFields.Add(new SmartCheckboxField() {
Name = field.Name,
Text = field.Text,
Checked = ((CheckFormField)field).Checked
});
break;
case "SelectionFormField":
smartFormFields.Add(new SmartDropdownField() {
Name = field.Name,
Text = field.Text,
Items = ((SelectionFormField)field).Items
});
break;
case "DateFormField":
SmartDateField smartDateField = new SmartDateField() {
Name = field.Name,
Text = field.Text,
Date = ""
};
if (((DateFormField)field).Date != null)
smartDateField.Date = ((DateFormField)field).Date.Value.ToString("yyyy-MM-dd");
smartFormFields.Add(smartDateField);
break;
}
}
return smartFormFields;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment