Extract Data from word form

Hi Aspose,

Is there any way to extract data from Word Form fields data by using Aspose.Word.

Thanks you
fujixeroxsg

Hi Su Hlaing,

Thanks for your inquiry. You can get the values of form fields by using following code snippet. The FormField.Result property allows you to gets or sets a string that represents the result of this form field.

For a text form field the result is the text that is in the field.

For a checkbox form field the result can be “1” or “0” to indicate checked or unchecked.

For a drop-down form field the result is the string selected in the drop-down.

//Open document
Document doc = new Document(MyDir + "in.docx");
// Loop through all Formfields
foreach (FormField field in doc.Range.FormFields)
{
    Console.WriteLine(field.Result);
}

Please read the following documentation links for your kind reference. Let us know if you have any more queries.
https://docs.aspose.com/words/net/working-with-form-fields/
https://reference.aspose.com/words/net/aspose.words.fields/formfield

Hi Aspose Word,

Thanks for the suggestion. However, I still couldn’t extract the data from the attachment file…Please advise…

Regards
fujixeroxsg

Hi Aspose ,

It’s work on legacy form control.
I found out that it is different control. If I would like to use content control, how can I extract the data from that content control?

Thanks for your support
Regards
fujixeroxsg

Hi Su Hlaing,

Thanks for sharing the details. Please use the following code snippet to get the contents of StructuredDocumentTag. StructuredDocumentTag represents a structured document tag (SDT or content control) in a document.

Document doc = new Document(MyDir + "form1.docx");
foreach (StructuredDocumentTag sdt in doc.GetChildNodes(NodeType.StructuredDocumentTag, true))
{
     Console.WriteLine(sdt.ToString(SaveFormat.Text));
}