I have a document which has huge number of bookmarks, it fails to read bookmarks at some point. It reads like 120 bookmarks but fails to get a bookmark at 150. I am using very simple code to get these bookmarks
Document doc = new Document(FileName);
foreach (Aspose.Words.Bookmark bm in doc.Range.Bookmarks)
{
Console.WriteLine("Bookmark Name : ", bm.Name);
}
I can provide the document as well but cannot find the attachment option here
@irfanb12
It seems that you are encountering an issue with retrieving bookmarks from a Word document that contains a large number of bookmarks. While Microsoft Word can theoretically support a vast number of bookmarks (up to 2,147,483,647), there are practical limitations when using Aspose.Words.
From previous discussions, it has been noted that users have successfully added and retrieved a significant number of bookmarks (e.g., over 1000) using Aspose.Words. However, some users reported that they could only retrieve a portion of the bookmarks they had added, which suggests there may be a limit or a specific issue with the document structure or the way bookmarks are being handled.
Here are a few suggestions to troubleshoot and potentially resolve your issue:
-
Check for Evaluation Mode Limitations: Ensure that you are using Aspose.Words in licensed mode. The evaluation version may impose limitations that could affect the number of bookmarks you can retrieve.
-
Document Structure: Review the structure of your Word document. If bookmarks are nested or if there are complex elements (like tables or sections), it might affect how they are accessed.
-
Simplified Code for Testing: You can use a simplified version of your code to test if the issue persists. Here’s an example of how to retrieve bookmarks:
Document doc = new Document("YourDocument.docx");
foreach (Bookmark bm in doc.Range.Bookmarks)
{
Console.WriteLine("Bookmark Name: " + bm.Name);
}
-
Testing with a New Document: Create a new document with a smaller number of bookmarks to see if the issue is related to the specific document you are using.
-
Contact Support: If the problem continues, consider reaching out to Aspose support with your document for further assistance.
By following these steps, you should be able to identify the cause of the issue and retrieve all bookmarks as expected.
If you have any further questions or need additional assistance, feel free to ask!
I am using the same simplified code to get the bookmarks but somehow it fails to get certain bookmark at some pages. If you add a new bookmark in the start of page 1 (e.g document with 4 pages) it will get this bookmark but not at the end of page 4
@irfanb12 Most likely you are using Aspose.Words in evaluation mode. In evaluation mode Aspose.Words has only two limitations: it limits the maximum size of the processed document to several hundred of paragraphs and injects an evaluation watermark into the document. So the document is truncated and not all bookmarks are returned. If you would like to test Aspose.Words without evaluation version limitations, you can request a free 30-days temporary license . Please see our documentation to learn more about licensing:
https://docs.aspose.com/words/java/licensing/