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

Free Support Forum - aspose.com

PDF doc with expanded bookmarks (outlines)

I’ve created a PDF doc using com.aspose.pdf for Java with bookmarks. When I open the document, bookmarks are not expanded (on the left). If it possible to create the doc and when it is opened, the bookmarks are expanded on the left?

Hi Alex,


Thanks for your inquiry. You may use PdfContentEditor class for the purpose. Please create a PDF document using com.aspose.pdf and pass the object to PdfContentEditor and set viewer preference according to your requirement. Please check following code snippet hopefully it will help you to accomplish the requirements.

Document pdfDoc = new Document();<o:p></o:p>

....

....

....

//pass your pdfDoc to PdfContentEdiot object to set preview preference

PdfContentEditor contentEditor = new PdfContentEditor(pdfDoc);

//change Viewer Preferences

contentEditor.changeViewerPreference(ViewerPreference.PAGE_MODE_USE_OUTLINES);

contentEditor.changeViewerPreference(ViewerPreference.HIDE_MENUBAR);

contentEditor.save("output.pdf");

Please feel free to contact us for any further assistance.


Best Regards,

Hi Alex,


Adding more to Tilal’s comments, you may consider using following code lines to show Bookmarks area when viewing the document.

[Java]
//open document
com.aspose.pdf.Document pdfDocument = new com.aspose.pdf.Document(“e:/pdftest/pcs_doc_with_bookmarks.pdf”);
//following value indicates to show bookmarks when viewing PDF
pdfDocument.setPageMode(com.aspose.pdf.PageMode.UseOutlines);
//save updated PDF file
pdfDocument.save(“c:/pdftest/BookmarksOpen_output.pdf”);