Finding formFields inside given bookmark


#1

First of all I would like to thanks for all previous response to my queries and great support.I am using Aspose words for java evaluation version. I have to find all the formfield in side a given bookmak. There may be other formfields in document outside my bookmark but I am not interested in them.

Is there any way to addess this use case in Aspose?

If you can provide any sample code, it'll help a lot.


-Sunil

#2

Hi, Sunil,

here is sample code you asked for:



Bookmark bookmark = doc.getRange().getBookmarks().get(“bookmark1”);

ArrayList formFields = new ArrayList();



boolean inBookmark = false;

for (Node node : doc.getChildNodes(NodeType.ANY, true))

{

if (node == bookmark.getBookmarkStart())

inBookmark = true;

if (inBookmark && node.getNodeType() == NodeType.FORM_FIELD)

formFields.add(node);

if (node == bookmark.getBookmarkEnd())

break;

}



Best Regards,