禁用 Adob​​e PDF 阅读器中的保存按钮并隐藏 IE 窗口中的菜单栏 [英] Disable save button in Adobe PDF reader and hide menu bar in IE window

查看:20
本文介绍了禁用 Adob​​e PDF 阅读器中的保存按钮并隐藏 IE 窗口中的菜单栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过 servlet 呈现 PDF,使用 Itext 获取 PDF 文件.
需要禁用 adobe pdf 阅读器菜单栏中的保存、打印选项,而其他选项(如滚动、查找)应该在那里,此外还需要禁用呈现它的浏览器窗口的文件菜单.

I am trying to render a PDF via servlet,using Itext for getting PDF file.
Need to disable save ,print option in adobe pdf reader menu bar while other options like scroll,find should be there and in addition need to disable the file menu of the browser window in which it is rendered.

我使用以下代码禁用了打印和文件菜单

I have disabled print and file menu using below code

stamper.setEncryption(null,null,
                 PdfWriter.HideWindowUI, PdfWriter.STRENGTH40BITS); 

stamper.setViewerPreferences(PdfWriter.HideToolbar);

问题是

  1. 禁用 Adob​​e PDF 阅读器菜单栏中的保存按钮(使用 **Adobe Reader 9**).

推荐答案

我们需要区分两个不同的方面:打印和保存.

We need to distinguish two different aspects: printing and saving.

您可以加密文件并以不允许打印的方式设置权限.但是:如果您只使用所有者密码加密文档,则很容易解密文档并取消限制.使用所有者密码加密文档仅在心理层面起作用:例如:您表明文档的原始制作人不希望打印文档.

You can encrypt a file and set the permissions in such a way that printing isn't allowed. However: if you only encrypt a document with an owner password, it is very easy to decrypt the document and to remove the restrictions. Encrypting a document with an owner password only works on a psychological level: for instance: you indicate that the original producer of the document doesn't want the document to be printed.

如果您想避免最终用户保存 PDF 文档,您就是在问一些不可能的事情.避免最终用户没有 PDF 副本的唯一方法是不向他发送 PDF.如果磁盘上没有实际字节,则无法在 Adob​​e Reader 中打开 PDF.即使您禁用保存(例如在 Web 应用程序的上下文中),您也总是会在临时文件中的某处找到 PDF,并且人们可以根据需要多次复制该文件.

If you want to avoid that an end users saves a PDF document, you are asking something that is impossible. The only way to avoid that an end user doesn't have a copy of the PDF is by not sending him the PDF. A PDF can't be opened in Adobe Reader without having the actual bytes on the disk. Even if you would disable saving (for instance in the context of a web application), you'd always find the PDF somewhere in the temp files and people would be able to copy that file as many times as they want.

在您的代码片段中,您尝试隐藏工具栏(查看器首选项),但这没有意义.是否遵守此查看器首选项完全取决于 PDF 查看器.例如:在 Adob​​e Reader X 和更高版本中,当您将鼠标悬停在文档上时,会出现一个特殊的小部件.此小部件允许用户保存文档.

In your code snippet, you try hiding the toolbar (a viewer preference), but that doesn't make sense. Whether or not this viewer preference will be respected entirely depends on the PDF viewer. For instance: in Adobe Reader X and later, you have a special widget that appears when you hover over the document. This widget allows users to save the document.

即使使用 Adob​​e Reader 9,隐藏工具栏也不够:如果用户选择适当的菜单项或点击适当的热键",工具栏就会出现,他们可以愉快地单击保存"按钮.此外,他们也可以右键单击并选择保存".

Even with Adobe Reader 9, hiding the toolbar isn't sufficient: if the user chooses the appropriate menu item or hits the appropriate "hot key", the toolbar would appear and they could happily click the Save button. In addition, they could have right-clicked and chosen "Save" as well.

简而言之,你问错了问题.

In short, you're asking the wrong question.

您需要做的不是阻止保存而是控制 PDF 的实际使用,这就是 DRM(数字版权管理)的用武之地.但是 DRM 通常非常昂贵,它需要一个自定义的 PDF 查看器,并且它不在iText 的范围.

What you need to do is NOT prevent saving BUT control the actual use of the PDF and that's where DRM (Digital Rights Management) comes in. DRM however is usually very expensive, it requires a custom PDF viewer and it's out of the scope of iText.

这篇关于禁用 Adob​​e PDF 阅读器中的保存按钮并隐藏 IE 窗口中的菜单栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆