为什么使用 itextsharp 没有隐藏 pdf 工具栏?

Why is the pdf toolbar not getting hidden using itextsharp?

我使用下面的代码隐藏了在浏览器中显示的工具栏小部件。

stamper.setViewerPreferences(PdfWriter.HideToolbar);

当我在 iframe 中打开任何 pdf 时,它仍然向我显示工具栏小部件。还有其他方法可以隐藏吗?

The Best iText Questions on Whosebug 中所述,您可能将常规工具栏与平视显示器 (HUD) 混淆了:

这不是您使用 HideToolbar 时所指的工具栏。

您要找的是不可能的。 阅读 iText 邮件列表上的 the answer by Leonard Rosenthol(Adobe 的 PDF 架构师),他说: "there is no way to hide the toolbar (or the HUD) in the browser."

将工具栏设置为 false 对工具栏有效,但您指的是 "Heads Up Display" (HUD)。 从 Adob​​e X 版本 Reader 开始,有一个名为 "Read Mode" 的新模式, 这是您在网络浏览器中打开 PDF 时的默认查看模式。 在 "Read Mode" 你可以找到一个半透明的浮动工具栏,其中包含 基本阅读控件,例如页面导航、打印和缩放:HUD。

根据 Adob​​e 的文档,无法自定义此功能,让我 quote Adobe:

the "Heads Up Display" (HUD) is not customizable. There are no APIs to HUD. You can’t use JavaScript to enter Read Mode, exit Read Mode or detect that the document is in Read Mode. Though it might seem like it, this wasn’t an oversight. There are some very sound engineering reasons why this is the case but I won’t go into those here.

总结:您要问的问题在 Adob​​e Acrobat / Reader 中不受支持。 取消选中 "Display in Read Mode by Default" 可以通过 编辑 > 首选项 > Internet 完成 在 Adob​​e Reader X 中,但无法以编程方式禁用 "read mode"。