The encryption protects data and allows only authorized people to open the file. So, only those who have an encryption key (such as a password) can open and view a file.
If you want to check if a file is encrypted, use the GetFileInfo() method that returns the file type and flag that indicates if the file is encrypted. The following code snippet shows how to check if a file is encrypted. Also, you can find this example on GitHub.
using(Viewerviewer=newViewer("encrypted.pdf")){// Get file information.Results.FileInfofileInfo=viewer.GetFileInfo();// Display the file type and flag if the file is encrypted.Console.WriteLine("File type is: "+fileInfo.FileType);Console.WriteLine("File encrypted: "+fileInfo.Encrypted);}
The following image shows a sample console output: