We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Reading checkbox

I am struggling with inspecting a checkbox placed in the document through Word 2016. Should the code below work? It is not finding the checkbox as a form field. Nothing comes back from the getChildNodes() call.

NodeCollection formFields = paragraph.getChildNodes(NodeType.FORM_FIELD, true);
for (FormField ff: formFields)
    if (ff.getType() == FieldType.FIELD_FORM_CHECK_BOX)
        System.out.println("checked = " + ff.getChecked());

When iterating through all the child nodes in that paragraph the checkbox appears to be NodeType = 29 (Glossary Document).

Content Control seems to find the checkbox. Need to be on version 15+ for the getChecked() method to show up.

StructuredDocumentTag SdtCheckBox = (StructuredDocumentTag)doc.getChild(NodeType.STRUCTURED_DOCUMENT_TAG, 0, true);
// StructuredDocumentTag.Checked property gets/sets current state of the Checkbox SDT
if (SdtCheckBox.getSdtType() == SdtType.CHECKBOX)

Hi Steve,

Thanks for your inquiry. FormField class represents legacy form controls. However, StructuredDocumentTag class represents a structured document tag (SDT or content control) in a document. In your case, you need to use StructuredDocumentTag. Please let us know if you have any more queries.