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

Free Support Forum - aspose.com

By using string data can we retreive bookmark Present in it

i have word document which contains bookmark in it.
i need a code for ,by giving input as string data(table of contents heading) and need to get bookmark ,if presents for given data(table of contents heading).

input as word which is present in word documnent ,and retrive bookmark is presented to the perticular word or not.

Thank u


Thanks for your inquiry. Please check following documentation link for obtaining a bookmark. You can iterate through the document bookmarks and compare the string with bookmark text. Hopefully it will help you to accomplish the task. However, if you face any issue then please share your sample input Word document and sample string to compare. You can ZIP and attach sample Word document to the post.

Obtaining Bookmarks

thank u for reply,

the above link work for bookmark given.
but my requirment is,by giving word ,it should check whether word contains bookmark or not.


As suggested above, you can iterate through the document bookmarks, compare your word with the bookmark text and proceed accordingly. Anyhow, please share your sample document and text. It will help us to guide you exactly.

actual i donot no what the bookmark present,where above code is help only if bookmark known to me.

with out knowing bookmark can we retrive bookmark by text or word.


Please check following sample code snippet to get bookmarks from a word document and compare text to get bookmark and its text. Please also check Aspose.Words DOM, it will help you to work with Word documents using Aspose.Words.

Document document = new Document("TOC.docx");
String bookmarktext = "Heading 1.1";
BookmarkCollection bookmarks = document.getRange().getBookmarks();
for (Bookmark bookmark : bookmarks)
    if (bookmark.getText().matches(bookmarktext))