Thanks, Tilman, it works exactly as advertised.  My code:

            PDDocumentOutline outline =  new PDDocumentOutline();
            document.getDocumentCatalog().setDocumentOutline(outline);
            // The following line makes the PDF file open with the navigation 
pane open
            // and bookmarks displayed.
            
document.getDocumentCatalog().setPageMode(PDDocumentCatalog.PAGE_MODE_USE_OUTLINES);
            PDOutlineItem bookmarksOutline = new PDOutlineItem();
            bookmarksOutline.setTitle(bookmarkData.getTitle());
            outline.appendChild(bookmarksOutline);
            bookmarkData.addToOutline(bookmarksOutline);
            bookmarksOutline.openNode();
            outline.openNode();

I also took your suggestion and got PDFDebugger. Very nice application. I 
created a handy shortcut to run it:

C:\Windows\System32\cmd.exe /k java -jar 
C:\Users\gary.grosso\Downloads\PDFBox\pdfbox-app-2.0.0-RC1.jar PDFDebugger && 
exit

Best regards,
Gary


-----Original Message-----
From: Tilman Hausherr [mailto:thaush...@t-online.de] 
Sent: Wednesday, October 28, 2015 11:39 PM
To: users@pdfbox.apache.org
Subject: Re: How to make the PDF document open with the Navigation Pane open?


Am 29.10.2015 um 03:07 schrieb Gary Grosso:
> Hi everyone,
>
> I very much appreciate Maruan's reply (thanks Maruan), but our customer is 
> suggesting there should be some other way to do this.
>
> The reasoning is as follows:
>
> Using Acrobat, it is possible to go to File->Properties and then to the 
> Initial View tab; set the Navigation tab value to Bookmarks Panel and Page, 
> and save the file. After which this PDF file opens with the navigation pane 
> open, and the bookmarks displayed.
>
> It is possible to view a small PDF file before and after this procedure was 
> performed, at:
>
> http://aapro.net/bookmarktest/
>
> The end users will be opening PDF files in Internet Explorer, but the 
> experience is basically the same when I open them in Reader.
>
> I would be very interested in any insight anyone can provide. While I was 
> able to add bookmarks to a PDF file (with help from this forum), I don't have 
> any tools or expertise for examining the insides of a PDF file, to find out 
> what is different between these two files.

use PDFDebugger:
https://repository.apache.org/content/groups/snapshots/org/apache/pdfbox/pdfbox-debugger/2.0.0-SNAPSHOT/

that helped me find it - in 1.8 use

doc.getDocumentCatalog().setPageMode(PAGE_MODE_USE_OUTLINES);


(never heard of that one before, but PDF has a surprise every day)

Tilman

>
> Thanks,
> Gary
>
>
> -----Original Message-----
> From: Maruan Sahyoun [mailto:sahy...@fileaffairs.de]
> Sent: Wednesday, October 21, 2015 12:33 PM
> To: users@pdfbox.apache.org
> Subject: Re: How to make the PDF document open with the Navigation Pane open?
>
> Hi,
>
> it's not part of the Viewer Preferences so can not be set in the PDF 
> directly. You could inject a JavaScript which is executed when the document 
> opens. As short sample for such JavaScript is available in the examples 
> package for PDFBox 2.0.0 under 
> org.apache.pdfbox.examples.interactive.form.UpdateFieldOnDocumentOpen.
>
> The issue with executing menu items is that this is a restricted function so 
> it might be available if the PDF is not certified. Lookup the function 
> execMenuItem in the Acrobat SDK JavaScript Reference.
>
> BR
> Maruan
>
>
>
>> Am 21.10.2015 um 18:17 schrieb Gary Grosso <gary.gro...@oberontech.com>:
>>
>> I am looking for a way to say in a PDF document that it should open with the 
>> Navigation Pane open. Not sure if this is even possible; it may strictly be 
>> a user preference.
>>
>> Thanks,
>> Gary Grosso
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org
> For additional commands, e-mail: users-h...@pdfbox.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org
> For additional commands, e-mail: users-h...@pdfbox.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: users-h...@pdfbox.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: users-h...@pdfbox.apache.org

Reply via email to