这个字节数组是受密码保护的 PDF 文档吗?

发布于 2024-11-28 15:10:30 字数 292 浏览 4 评论 0原文

我有一个 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 技术交流群。

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

发布评论

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

评论(2

你的他你的她 2024-12-05 15:10:30

密码保护 PDF 有多种可能性,其中一些由 Adob​​e 定义(“标准”),并且作为标准的一部分,可以有所谓的“备用安全处理程序”。

无论如何,基本上可以通过检查 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

拥抱没勇气 2024-12-05 15:10:30

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.

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