简体   繁体   English

Websupergoo ABCPDF.NET - 在调用 doc.Read() 之前检查 pdf 是否加密/密码保护

[英]Websupergoo ABCPDF.NET - check if the pdf is encrypted/password protected before calling doc.Read()

doc.Read(filePath) will error out if the pdf file is encrypted and a password is not passed.如果 pdf 文件已加密且未传递密码,doc.Read(filePath) 将出错。 I haven't been able to find a way to check to see if the pdf document is encrypted before calling doc.Read() so I can better handle this occurrence.在调用 doc.Read() 之前,我一直无法找到一种方法来检查 pdf 文档是否已加密,因此我可以更好地处理这种情况。 Anyone know of a way?有人知道办法吗?

check the doc encrption type to be 2?检查文档加密类型为 2?

bool encrypted = false;
using (Doc theDoc = new Doc())
{
    XReadOptions options = new XReadOptions { ReadModule = MyPDF.Pdf };
    theDoc.Read(inputbytearray, options);
    if (theDoc.Encryption.Type == 2)
      encrypted = true;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM