Exception from PdfFileInfo

I am using a temporary licence evaluation copy of Aspose with .NET C#.


Tried to open a valid PDF file using below source code. fileInfo.IsPdfFile value was showing as false and fileInfo.IsEncrypted as true. See the attached image for exception details from watch window.

using (PdfFileInfo fileInfo = new PdfFileInfo(pdfFile))
{
boolIsValidFile = fileInfo.IsPdfFile;
boolIsSecuredFile = fileInfo.IsEncrypted;
}

Hi there,


Thanks for your inquriy. Please note if an encrypted PDF file is not loaded with valid password then API returns false value for IsPdfFile property. Please pass password parameter to PdfFileInfo constructor as following. It will resolve the issue.

using (PdfFileInfo fileInfo = new PdfFileInfo(pdfFile,“password”))

We are sorry for the inconvenience caused.

Best Regards,




Before using the below source code, Is there a way from Aspose to check a valid PDF file (even though its secured).

using (PdfFileInfo fileInfo = new PdfFileInfo(pdfFile,"password"))

Hi Nishal,


Thanks for contacting support.

In order to identify the input file type, the API need to read its header information but the encrypted PDF documents do not allow reading file contents, unless proper decoding password has been provided. So in order to determine the file type, we need to first decrypt the file through valid password and then we can identify its type.