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

Grant picture Grant · Dec 23, 2010 · Viewed 107.2k times · Source

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

Answer

Cody Gray picture Cody Gray · Dec 23, 2010

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.