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

Free Support Forum - aspose.com

Updating the destination page of existing bookmark using Aspose.pdf for java


I am trying to update the destination page in an existing pdf document using the following code.

Bookmarks bookmarks = bookmarkEditor.extractBookmarks();
int ii=0;
for(Bookmark bookmark : (Iterable)bookmarks)
com.aspose.pdf.OutlineItemCollection pdfOutline = new com.aspose.pdf.OutlineItemCollection(doc.getOutlines());
pdfOutline.setDestination(new com.aspose.pdf.GoToAction(8));

The above code does not work. I need to reset the page for existing bookmark since I added a new page in the pdf document and this has changed the page number.

Is there any solution or a workaround.

Best Regards

Hi Rajeev,

Thanks for contacting support.

In order to reset/update the bookmark destination page, please try using the following code snippet. The following code snippet demonstrates the steps to update the destination page number for first bookmark.


//open document

Document pdfDocument = new Document("c:/pdftest/BookmarkInheritZoom.pdf");

//get a bookmark object

com.aspose.pdf.OutlineItemCollection pdfOutline = pdfDocument.getOutlines().get_Item(1);

// set the target page as 10

pdfOutline.setDestination(new com.aspose.pdf.GoToAction(10));

//save output