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

Free Support Forum - aspose.com

Auto expand the bookmarks in pdf

I am adding bookmarks to a pdf using Aspose. However when I open the pdf the bookmarks are collapsed and I have to manually expand it to see all the bookmarks.


Is there a way of setting this in the pdf itself so that the Bookmarks show Auto expanded.

Thanks
Rjain

Hi Rjain,


Thanks for contacting support.

In order to accomplish your requirements, please try using following code snippet.

[Java]

//create Document instance<o:p></o:p>

com.aspose.pdf.Document doc = new com.aspose.pdf.Document("c:/pdftest/BookmarkIssue_8_1_0.pdf");

//set page view mode i.e. show thumbnails, full-screen, show attachment panel

doc.setPageMode(com.aspose.pdf.PageMode.UseOutlines);

//traverse through each Outline item in outlines collection of PDF file

for(int counter = 1; counter <= doc.getOutlines().size();counter++)

{

// set open status for outline item

doc.getOutlines().get_Item(counter).setOpen(true);

}

//save the PDF file

doc.save(“c:/pdftest/Bookmarks_Expanded.pdf”);