Free Support Forum - aspose.com

Check PDFFileSecurity

Hi,

I try to convert pdf-files to tiff, unsing these statements:

PdfConverter converter = new PdfConverter();
converter.BindPdf(sInFile);
converter.DoConvert();
on some files, an exception is thrown here, because the pdf-file is encrypted.

The workaround in the catch-part is:

// wenn Encrption-Problem dann Passwort löschen
PdfFileSecurity sec = new PdfFileSecurity();
sec.InputFile = sInFile;
sec.OutputStream = ms;
sec.DecryptFile("");
converter.BindPdf(ms);
converter.DoConvert();

This all works fine.

My question: to avoid the exception, I would like to check the pdf-file before calling the DoConvert, to find out, if I have to do the decryption, or not.

Is there a way to find out, if the file is encryted and I have to remove the password?

Thanks.

best regards,

Oliver

Hi Oliver,

You may try using the BeEncrypted property of the PdfFileInfo class to check whether the PDF file is encrypted or not. If you still find any issue then please do let us know.

We’re sorry for the inconvenience.
Regards,

Hi Shahzad,

thank you for your advice, this is, what I missed.

It works fine now.

best regards,

Oliver