Free Support Forum - aspose.com

Remove all Bookmarks

After I finish building my document, I'd like to remove all the bookmarks. How do I go about doing that?

It can be done using Document.Range.Bookmarks collection:

ArrayList bookmarks = new ArrayList();

foreach (Bookmark bookmark in doc.Range.Bookmarks)

{

bookmarks.Add(bookmark);

}

foreach (Bookmark bookmark in bookmarks)

{

bookmark.Remove();

}

Range.Bookmarks.Clear() and Range.FormFields.Clear() methods were added in Aspose.Words 4.0 to simplify clearing bookmarks and formfields from the specified range.