即使我可以打开文件,PDFBox 也返回 isEncrypted true [英] PDFBox returns isEncrypted true even if i can open file

查看:68
本文介绍了即使我可以打开文件,PDFBox 也返回 isEncrypted true的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 PDFBox 来确定 pdf 文件是否受密码保护.这是我的代码:

I am using PDFBox to determine pdf file is password protected or not. this is my code:

boolean isProtected = pdfDocument.isEncrypted();

我的文件属性在 sceenshot 中.在这里我得到 isProtected= true 即使我可以在没有密码的情况下打开它.

My file properties is in sceenshot. Here i am getting isProtected= true even i can open it without password.

注意:此文件有文档打开密码:否和权限密码:是.

Note: this file has Document Open password : No and permission password : Yes.

推荐答案

您的 PDF 有一个空的用户密码和一个非空的所有者密码.是的,它是加密的.这样做是为了防止人们做某些事情,例如内容复制.

Your PDF has an empty user password and a non empty owner password. And yes, it is encrypted. This is being done to prevent people to do certain things, e.g. content copying.

这不是真正的证券;查看器软件有责任注意不允许禁止"的操作.

It isn't a real security; it is the responsibility of the viewer software to take care that the "forbidden" operations aren't allowed.

你可以找到更长(有点有趣)的解释 此处.

You can find a longer (and a bit amusing) explanation here.

要查看文档访问权限,请使用PDDocument.getCurrentAccessPermission().

To see the document access permissions, use PDDocument.getCurrentAccessPermission().

在 2.0.* 中,如果此调用成功,用户将能够查看文件:

In 2.0.*, a user will be able to view a file if this call succeeds:

PDDocument doc = PDDocument.load(file);

如果抛出InvalidPasswordException,则表示需要非空密码.

If a InvalidPasswordException is thrown, then it means a non empty password is required.

这篇关于即使我可以打开文件,PDFBox 也返回 isEncrypted true的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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