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

Free Support Forum - aspose.com

Unable to view bookmarks in pdf after converting word to pdf

I manually created a word document which contains a bookmark and a hyperlink to the bookmark. I then used aspose (java) to convert he word document to pdf. I am able to click on the link in the pdf and it correctly navigates to the bookmark. However I am not able to see the bookmark either with the aspose pdf api or manually using adobe acrobat dc. Does aspose preserve word bookmarks when converting to pdf?

Steps to reproduce:

  1. Manually created word document (.doc) which contains a bookmark
  2. Used aspose words (java) to convert word to pdf
  3. Verified bookmarks DO NOT exist in the pdf


Thanks for your inquiry. Please note you need to use DefaultBookmarksOutoutlineLevel property to export Bookmarks from Word document to PDF. Please check following code snippet, it will help you to accomplish the task.

However, if the issue persists then please share your sample input and output documents here, we will look into these and will guide you accordingly.

Document doc = new Document("input.docx");
PdfSaveOptions option = new PdfSaveOptions();

Best Regards,

Hi, thanks for the quick reply!

I used your example above and built on that in order to resolve the issue. The issue is I was NOT ABLE to read bookmarks using the outline classes: https://docs.aspose.com/display/pdfjava/Get+Bookmarks+from+PDF+Document

I WAS able to read the pdf bookmarks using the PdfBookmarkEditor class however. Not sure if theres a bug in the outline classes, but I verified the pdf bookmarks exist using adobe acrobat dc pro.

Fyi we are using the following aspose java versions:


Thanks for your feedback. Please share your sample code along with the input and output documents here. We will look into these and will guide you accordingly.

Best Regards,

Hi, this was totally user error (me).

I didn’t realize the document outlines were an iterator (I thought they were a simple collection).

If I convert the iterator to a list I can now see the bookmarks:

List<com.aspose.pdf.OutlineItemCollection> pdfBookmarks = IteratorUtils.toList(doc.outlines.iterator())

assert pdfBookmarks.size() == 1

Thanks very much for your help!


Thanks for the acknowledgement.

We are glad to hear that your problem is resolved. Please continue using our APIs and in the event of any further query, please feel free to contact.

Ok I realized that the reason I posted this issue in the first place was because I was not able to view pdf bookmarks using aspose, but I believe this is actually do to a bug in aspose pdf.

To reproduce:
result.pdf (13.1 KB)


// load a pdf that contains a bookmark
com.aspose.pdf.Document pdfDoc = new com.aspose.pdf.Document(“C:\temp\result.pdf”)

// load outlines
com.aspose.pdf.OutlineCollection outlineCollection = pdfDoc.getOutlines()

// try to retrieve a bookmark. this line throws an exception
com.aspose.pdf.OutlineItemCollection outlineItemCollection = outlineCollection.get_Item(1)

Exception thrown:

class com.aspose.pdf.internal.ms.System.z9: Invalid index: index should be in the range [1…n] where n equals to the outline items count.
com.aspose.pdf.OutlineCollection.get_Item(Unknown Source)
com.aspose.pdf.OutlineCollection$get_Item.call(Unknown Source)

aspose version:


Thanks for sharing the details and sorry for the delayed response.

I have tested the scenario and have observed that Aspose.Pdf for Java is having an issue while reading bookmark from input PDF file. However when viewing the file in Adobe Reader, the bookmark appears properly. For the sake of correction, I have logged it as PDFJAVA-36893 in our issue tracking system. We will further look into the details of this problem and will keep you updated on the status of correction. Please be patient and spare us little time. We are sorry for this inconvenience.

The issues you have found earlier (filed as PDFJAVA-36893) have been fixed in Aspose.PDF for Java 18.6.