Support of forms in Word document

Guys,

I have created a word document in MS Word 2010 (see attachment). The document contains various form fields.
I have found out that not only legacy form fields are supported (populated in Document.Range.FormFields collection).

Is it possible to access non-legacy form fields from current version of Aspose (e.g. by Tag)?

Here is a code snippet I am using for accessing fields:

foreach(var field in doc.Range.FormFields)
{
    if (((FormField) field).Type.Equals(FieldType.FieldFormCheckBox))
        ((FormField) field).Checked = true;
    else
        ((FormField) field).SetTextInputValue("Test");

}

Best regards,
Alex.

Hi Alex,

Thanks for your inquiry. You document contains structured document tag (SDT or content control). You can interact with content controls by using StructuredDocumentTag class. Here is the code to insert plain text and select the Drop Down List item from the content control:

Document doc = new Document(@"c:\test\SDTs.docx");
foreach(StructuredDocumentTag sdt in doc.GetChildNodes(NodeType.StructuredDocumentTag, true, true))
{
    if (sdt.SdtType == SdtType.PlainText)
    {
        sdt.RemoveAllChildren();
        Paragraph para = sdt.AppendChild(new Paragraph(doc)) as Paragraph;
        Run run = new Run(doc, "new text goes here");
        para.AppendChild(run);
    }
    else if (sdt.SdtType == SdtType.DropDownList)
    {
        SdtListItem secondItem = sdt.ListItems[2];
        sdt.ListItems.SelectedValue = secondItem;
    }
}
doc.Save(@"c:\test\out.docx");

I am afraid, currently there is no way you can change the state of CheckBox control to checked/unchecked. We had already logged a new feature request in our bug tracking system. The issue ID is WORDSNET-6502. Your request has also been linked to this issue and you will be notified as soon as it is supported. Sorry for the inconvenience.

The issues you have found earlier (filed as WORDSNET-6502) have been fixed in this .NET update and this Java update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.
(17)