Hi
Thanks for your inquiry. In your case you should move DocumentBuilder cursor before bookmark. You should just use another overload of MoveToBookmark method:
https://reference.aspose.com/words/net/aspose.words/documentbuilder/movetobookmark/
If you insert SectionBreak before bookmark, you will be able to identify section, which you need to remove by this bookmark. Here is sample code to insert section break right before bookmark:
Document doc = new Document(@"Test001\in.doc");
DocumentBuilder builder = new DocumentBuilder(doc);
// Move builder cursor before bookmark.
builder.MoveToBookmark("test", true, false);
// Insert section break.
builder.InsertBreak(BreakType.SectionBreakNewPage);
// Save output document
doc.Save(@"Test001\out.doc");
And here is code to remove section with bookmark.
Document doc = new Document(@"Test001\out.doc");
// Get bookmark
Bookmark bk = doc.Range.Bookmarks["test"];
if (bk != null)
{
// remove section where this bookmark is located.
bk.BookmarkStart.GetAncestor(NodeType.Section).Remove();
}
// Save output document.
doc.Save(@"Test001\out1.doc");
Hope this helps.
Best regards.