iTextSharp.text.pdf.PdfReader.IsEncrypted C# (CSharp) Метод

IsEncrypted() публичный метод

public IsEncrypted ( ) : bool
Результат bool
        public bool IsEncrypted() {
            return encrypted;
        }
        

Usage Example

Пример #1
0
        /// <summary>
        /// 根据文件名进行分类
        /// </summary>
        /// <param name="fileName"></param>
        /// <returns>0:正常,1:加密,2:异常</returns>
        public static int ClassifyByWjm(string fileDir, string fileName)
        {
            if (fileName == null || "".Equals(fileName)) return 2; //文件名为空,不存在全文

            //文件原来所在目录
            string fullFileName = fileDir;

            fullFileName += ConstructFilePath(fileName, 1);
            fullFileName += fileName;

            if (!File.Exists(fullFileName)) return 2; //有文件名,但是文件不存在

            if (File.ReadAllBytes(fullFileName).Length == 0) return 2; //文件大小为0

            try
            {
                PdfReader reader = new PdfReader(fullFileName);
                if (reader.IsEncrypted()) return 1; //文件加密
            }
            catch
            {
                return 2;//PDF文件损坏
            }

            //正常
            return 0;
        }
All Usage Examples Of iTextSharp.text.pdf.PdfReader::IsEncrypted