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

发布于 2024-10-09 05:13:06 字数 460 浏览 0 评论 0原文

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

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

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

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

我希望隐藏的 Adob​​e Reader 工具栏

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

╰沐子 2024-10-16 05:13:06

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

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

    Adobe Reader 首选项对话框

您还可以通过单击顶部工具栏右侧的按钮来暂时关闭工具栏,该按钮描绘了指向对角的箭头:

   Adobe Reader 阅读模式工具栏按钮

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

#toolbar=0&navpanes=0

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

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

您可以阅读有关可用于自定义 PDF 文件打开方式的参数的更多信息 Adobe 开发者网站上的此处

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文