简体   繁体   中英

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. 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. Anyone know of a way?

check the doc encrption type to be 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;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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