这个字节数组是受密码保护的 PDF 文档吗?
我有一个 C# 字节数组,我需要知道它是否是受密码保护的 PDF 文档。我怎样才能做出这个决定?
我正在检查文档中的 PDF magic cookie 以确定它是否是 PDF 文档,但我不知道在确定它是否受密码保护时最好做什么。
我不需要打开该文档(不过,只要不需要 UI——这是一个后台进程,如果有帮助的话我可以这样做)。
我只需要知道这个 PDF 文档是否有密码。
编辑:如果您引用 iTextSharp,如果您引用该 API 中解决此问题的特定资源,我将非常感激。
I have a C# byte array, and I need to know if it's a password-protected PDF document. How can I make this determination?
I'm inspecting the document for the PDF magic cookie to determine if it's a PDF document, but I don't know what's best when determining if it's password protected.
I don't need to open the document (though, as long as there's no UI required -- this is a background process, I'm OK with doing that if it helps).
I just need to know if there's a password on this PDF document.
EDIT: If you cite iTextSharp, I'd be very grateful if you'd cite a specific resource within that API that addresses this concern.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
密码保护 PDF 有多种可能性,其中一些由 Adobe 定义(“标准”),并且作为标准的一部分,可以有所谓的“备用安全处理程序”。
无论如何,基本上可以通过检查 PDF 规范第 115 - 136 页中描述的相应“字典”来检测所有内容 - 请参阅 http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/pdf_reference_1-7.pdf
There are several possibilities for password-protecting PDF, some defined by Adobe ("standard") and as part of the standard it is possible to have so-called "alternate security handlers".
Anyway all can be detected basically by checking for the respective "dictionaries" as described on pages 115 - 136 of the PDF spec - see http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/pdf_reference_1-7.pdf
Docotic.Pdf 库 可用于执行此类检查。
该库提供了不同的方法来检查字节、流或文件是否包含受密码保护的 PDF 文档。
请查看如何检查现有 PDF 是否存在的文章文档受密码保护。
免责声明:我在公司工作。
Docotic.Pdf library can be used to perform such check.
The library provides different methods to check if bytes, stream or file contain a password protected PDF document.
Please take a look at the article that shows how to check if an existing PDF document is password protected.
Disclaimer: I work for the company.