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

Free Support Forum - aspose.com

Extract Content between Bookmark does not Work using .NET


The method works fine in most documents but not for mergefields inside a table cell.

I am trying to get all the mergefields inside the bookmarks by creating a new document out of the extracted contents. The contents of the bookmarks dont contain any nodes after the exceution of the ExtractContent-Method you provided.

Code Example:

ArrayList extractedNodesInclusive = ExtractContent(bookmarkStart, bookmarkEnd, true);
Document tmpDoc = GenerateDocument(doc, extractedNodesInclusive);|

Example document is attached here
EAnlageBlatt.zip (29.8 KB)

Do you have a solution for this?



Could you please share the bookmark name that you used in ExtractContent method here for testing? We will investigate the issue and provide you information on it.


In this example i looped through all the available bookmarks. It does not work for either of them. Examples are:

  • EGeschichte
  • ELeistungen
  • ETarifApparate
  • EUeberwachungen
  • EVerbraucher


We have logged this problem in our issue tracking system. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.


Please use the following code example to get the correct output.

Document doc = new Document(MyDir + "EAnlageBlatt.dot");
int i = 1;
foreach (Bookmark bookmark in doc.Range.Bookmarks)
    List<Node> extractedNodesInclusive = ExtractContentHelper.ExtractContent(bookmark.BookmarkStart, bookmark.BookmarkEnd, true);

    Document dstDoc = ExtractContentHelper.GenerateDocument(doc, extractedNodesInclusive);
    dstDoc.Save(MyDir + "ExtractContent.ExtractContentBetweenBookmark.IncludingBookmark_" + bookmark.Name + ".docx");

Please get the code of ExtractContentHelper class from here: