CurrentNode returns incorrect Node after calling MoveToBookmark using .NET

  • netcoreapp3.1 project

  • Include=“Aspose.Words” Version=“20.6.0”

  • builder.MoveToBookmark(bookmark.Name, false, false); not setting the current node to bookmark.

  • returns true

  • same code works with 16.1.0 version for net461 project

image.png (32.3 KB)


Please ZIP and attach your input Word document along with bookmark name here for testing. We will investigate this issue and provide you more information on it.

@tahir.manzoor Please find the attachment files to (60.2 KB)


You are facing this issue because you are using Aspose.Words for .NET 20.6 in evaluation mode. Please get the temporary license and apply it before importing document into Aspose.Words’ DOM.

Moreover, the shared documents are generated by Aspose.Words. To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input Word document.
  • Please share the bookmark name for which you are facing this issue.
  • Please create a standalone console application ( source code without compilation errors ) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we will start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.

@tahir.manzoor As mentioned, in version 20.6.0 even after setting the currentnode to BookMarkEnd, the node has not been changed. But same code works with version 16.1.0.

  1. Sample files are also in zip file
  2. Bookmark name is ‘Innstilling’
  3. Please find the sample standalone application for this issue in the below link. Issue is highlighted in Screenshot as well.

image.png (60.7 KB)


We have tested the scenario and have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-20665 . You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

@tahir.manzoor Is there any workaround for this issue or when we can expect this issue to be fixed?


You can get the BookmarkEnd node as shown below. Hope this helps you.

var builder = new DocumentBuilder(document);
builder.MoveToBookmark(bookmark.Name, false, true);

var bookmarkEnd = document.Range.Bookmarks[bookmark.Name].BookmarkEnd;

if (bookmarkEnd?.NextSibling != null)
    builder.MoveToBookmark(bookmark.Name, false, true);

@tahir.manzoor There are more logic based on Node. I have attached the node differences, please have a look and help with suggestions for Node shift.Aspose word node (149.9 KB)


You are facing the expected behavior of Aspose.Words 20.6. The behavior of old version of Aspose.Words is incorrect.

We added feature in Aspose.Words 18.9 to allow bookmark at block level nodes. Please read the detail from here:
Bookmarks are Allowed on Block, Cell, Row Levels

This was controlled by LoadOptions.AnnotationsAtBlockLevel and LoadOptions.AnnotationsAtBlockLevelAsDefault properties. These property was removed from the API in Aspose.Words 20.4.

Please use the BookmarkEnd and BookmarkStart nodes according to latest API.


It is to inform you that the issue which you are facing is actually not a bug in Aspose.Words. So, we have closed this issue (WORDSNET-20665) as ‘Not a Bug’.

You are facing the expected behavior of Aspose.Words In the example the cursor is moved to be after the bookmark node:

builder.MoveToBookmark(bookmark.Name, false, true); // isAfter == true
var bookmarkEnd = builder.CurrentNode as BookmarkEnd;

So builder.CurrentNode returns the node after the bookmark end.

The end of bookmark is a block level node but DocumentBuilder allows moving cursor to inline nodes or paragraph ends only, and its methods expect that a cursor is on an inline node or a paragraph end. So, when cursor is being moved to a block level bookmark node, it is moved to the next inline node or a paragraph end.