在 .NET WebBrowser 控件中显示 PDF 时如何隐藏 Adob​​e Reader 工具栏?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4515248/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 15:03:48  来源:igfitidea点击:

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

.netpdfwebbrowser-controlacrobatadobe-reader

提问by Grant

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.

我正在尝试在 .NET Web 浏览器控件中加载 PDF 文档。在 v10 之前的 Adob​​e Reader 版本(又名“X”)中,加载的 PDF 不显示工具栏——您只会看到 PDF 文档。在新发布的 Reader v10 中,有一个我不想看到的工具栏。我想知道是否有人知道如何隐藏此工具栏。

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 WebBrowsercontrol.

我认为答案可能在注册表中,因为我没有用于访问 Reader 的直接代码。一切都由 mime 类型通过WebBrowser控件处理。

My code to load the PDF file is as follows:

我加载PDF文件的代码如下:

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

Adobe Reader toolbar that I wish to hide

我想隐藏的 Adob​​e Reader 工具栏

回答by Cody Gray

It appears the default setting for Adobe Reader X is for the toolbars notto 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.

Adobe Reader X 的默认设置似乎是默认情况下显示工具栏,除非用户明确打开它们。即使我在会话期间重新打开它们,它们也不会在下次自动出现。因此,我怀疑您的偏好设置与默认设置相反。

The state you desire, with the top and left toolbars notshown, 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:

您想要的状态(显示顶部和左侧的工具栏)称为“阅读模式”。如果您右键单击文档本身,然后在显示的上下文菜单中单击“页面显示首选项”,您将看到 Adob​​e Reader 首选项对话框。(这与打开 Adob​​e Reader 应用程序并从“编辑”菜单中选择“首选项”可以访问的对话框相同。)在“首选项”对话框左侧列中显示的列表中,选择“Internet”。最后,在右侧,确保选中“默认以阅读模式显示”框:

   Adobe Reader Preferences dialog

   Adobe Reader 首选项对话框

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

   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 notto display the toolbars (i.e., override the user's current preferences), you can append the following to the URL:

最后,如果您关闭了“默认以阅读模式显示”,但想要指示您正在加载的页面显示工具栏(即覆盖用户当前的首选项),您可以将以下内容附加到 URL:

#toolbar=0&navpanes=0

#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.

因此,例如,以下代码将禁用顶部工具栏(称为“工具栏”)和左侧工具栏(称为“导航窗格”)。但是,如果用户知道键盘组合(F8,也许还有其他方法),他们仍然可以重新打开它们。

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.

您可以在 Adob​​e 的开发人员网站 上阅读有关可用于自定义 PDF 文件打开方式的参数的更多信息。