开发者

Is this byte array a password-protected PDF document?

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 ther开发者_开发知识库e'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.


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 library can be used to perform such check.

The library provides group of methods that can be used to check if bytes, stream or file contain a password protected PDF document.

Please take a look at the sample that shows how to check if an existing PDF document is password protected.

Disclaimer: I work for the company.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜