How can I hide the Adobe Reader toolbar when displaying a PDF in the .NET WebBrowser control?
Asked Answered
A

1

22

I am trying to load a PDF document inside a .NET web browser control. In versions of Adobe Reader prior to v10 (aka "X"), the PDF loaded without the toolbar displayed—you would just see the PDF document. In the newly-released Reader v10, there is a toolbar that I do not wish to see. I am wondering if anyone knows how to hide this toolbar.

I'm thinking that the answer may lie in the Registry, as there is no direct code that I am using to access Reader. Everything is handled by mime types through the WebBrowser control.

My code to load the PDF file is as follows:

string url = @"http://www.domain.com/file.pdf";
this._WebBrowser.Navigate(url);

Adobe Reader toolbar that I wish to hide

Agra answered 23/12, 2010 at 1:52 Comment(0)
P
48

It appears the default setting for Adobe Reader X is for the toolbars not to be shown by default unless they are explicitly turned on by the user. And even when I turn them back on during a session, they don't show up automatically next time. As such, I suspect you have a preference set contrary to the default.

The state you desire, with the top and left toolbars not shown, is called "Read Mode". If you right-click on the document itself, and then click "Page Display Preferences" in the context menu that is shown, you'll be presented with the Adobe Reader Preferences dialog. (This is the same dialog you can access by opening the Adobe Reader application, and selecting "Preferences" from the "Edit" menu.) In the list shown in the left-hand column of the Preferences dialog, select "Internet". Finally, on the right, ensure that you have the "Display in Read Mode by default" box checked:

   Adobe Reader Preferences dialog

You can also turn off the toolbars temporarily by clicking the button at the right of the top toolbar that depicts arrows pointing to opposing corners:

   Adobe Reader Read Mode toolbar button

Finally, if you have "Display in Read Mode by default" turned off, but want to instruct the page you're loading not to display the toolbars (i.e., override the user's current preferences), you can append the following to the URL:

#toolbar=0&navpanes=0

So, for example, the following code will disable both the top toolbar (called "toolbar") and the left-hand toolbar (called "navpane"). However, if the user knows the keyboard combination (F8, and perhaps other methods as well), they will still be able to turn them back on.

string url = @"http://www.domain.com/file.pdf#toolbar=0&navpanes=0";
this._WebBrowser.Navigate(url);

You can read more about the parameters that are available for customizing the way PDF files open here on Adobe's developer website.

Protium answered 23/12, 2010 at 5:36 Comment(7)
Thanks for the detailed responce Cody. I have checked my settings and the Display in Read mode by default checkbox has always been in the checked state. furthermore, when i append the snippet above to the URL it still does not remove the bars. so far the only way i can change is the click the arrow or press F8..Agra
@Grant: It works fine on my computer... I actually tested this extensively before posting, since the last time I tried to harness Adobe Reader programmatically was back in version 7 or 8. I'm not sure what else could be interfering in your case. Does it work with other PDFs? Perhaps the one you've tried has some kind of embedded parameters that cause it to show the toolbars regardless?Protium
I have found if i remove the navpanes argument and only set toolbar=0 then the top bar is not shown. not sure about the right hand nave pane though... when i combine both arguments then both bars are displayed.Agra
** update - it must hav been the pdf. i tried another document and the combination worked perfectly. thanks Cody!Agra
@Grant: Glad to be of help. The documentation does mention "Note: The creator of the PDF can control the contents of some navigation panels and may make them empty" but it doesn't explain how exactly to achieve that. I'm pretty sure that you can do it under "Document Properties" for that individual PDF file, but I'm not sure exactly where or what you'd specify. First place I'd check would be the "Custom" tab, though.Protium
some more information my be found here: acrobatninja.blogspot.com/2011/01/…Cyclops
This works fine when I append #toolbar=0&navpanes=0"; But once when i right click on the document and click on show navigation option and close the doc and again click on the document then navigation is visible. I am not getting the option "Display in read Only Mode" in my Adobe reader and also please give me the best way to permanently hide that from my code instead of explicitly changing the options.Franek

© 2022 - 2024 — McMap. All rights reserved.