You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Gary Grosso <ga...@oberontech.com> on 2015/10/21 18:17:34 UTC

How to make the PDF document open with the Navigation Pane open?

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



RE: How to make the PDF document open with the Navigation Pane open?

Posted by Gary Grosso <ga...@oberontech.com>.
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:THausherr@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:sahyoun@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 <ga...@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-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>


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


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


Re: How to make the PDF document open with the Navigation Pane open?

Posted by Gilad Denneboom <gi...@gmail.com>.
Another thing one can try is to embed this JS code as a doc-level script:

this.pane="B";

On Thu, Oct 29, 2015 at 4:39 AM, Tilman Hausherr <TH...@t-online.de>
wrote:

>
> 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:sahyoun@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 <ga...@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-unsubscribe@pdfbox.apache.org
>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>
>

Re: How to make the PDF document open with the Navigation Pane open?

Posted by Tilman Hausherr <TH...@t-online.de>.
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:sahyoun@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 <ga...@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-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>


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


RE: How to make the PDF document open with the Navigation Pane open?

Posted by Gary Grosso <ga...@oberontech.com>.
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.

Thanks,
Gary


-----Original Message-----
From: Maruan Sahyoun [mailto:sahyoun@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 <ga...@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-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


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


Re: How to make the PDF document open with the Navigation Pane open?

Posted by Maruan Sahyoun <sa...@fileaffairs.de>.
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 <ga...@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-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org