Hi,
Please give me a sample code to determine the PDF documents is password protected before loading the document into Aspose.PDF object.
Thanks,
Dhivya
Hi,
Please give me a sample code to determine the PDF documents is password protected before loading the document into Aspose.PDF object.
Thanks,
Dhivya
Hi Dhivya,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
You may try Aspose.Pdf.Facades.PdfFileInfo class to get the information regarding a particular PDF file. You can use PdfFileInfo.IsEncrypted property to get your desired results. Please see the following link for more details and sample code regarding PdfFileInfo class.
Thank You & Best Regards,
Hi,
I am using Aspose.PDF.dll for .net version 6.3.0.0. I am getting System.NullReferenceException for below code.
PdfFileInfo fileInfo = new PdfFileInfo(fileName);
//Check if the document protected by password
if (fileInfo.IsEncrypted) // getting exception in this line code
{}
Thanks,
Dhivya
Hi Dhivya,
Please share your template PDF file with us. This will help us figure out the issue soon.
Thank You & Best Regards,
Hi,
I have attached sample PDF document for your reference.
Thanks,
Dhivya
Hi Dhivya,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
Thank you for sharing the template file.
We have found your mentioned issue after an initial test. Your issue has been registered in our issue tracking system with issue id: PDFNEWNET-31695. You will be notified via this forum thread regarding any update against your issue.
Sorry for the inconvenience,
Hi Dhivya,
you may simply try using the following code snippet to get the information regarding PDF that either its encrypted or not. I have tested the scenario with upcoming release version of Aspose.Pdf for .NET 6.4.0 and the code seems to be working as expected. We are planning to release the new version in a day or two. Please be patient and wait for the new release.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
[C#]
PdfFileInfo fileInfo = new PdfFileInfo(@"D:\pdftest\Arabic12.pdf");
//Check if the document protected by password
if (fileInfo.IsEncrypted)
{
MessageBox.Show(fileInfo.IsEncrypted+"");
}
The issues you have found earlier (filed as 31695) have been fixed in this update.
Hi
Aspose.Pdf.Facades.PdfFileInfo info = new Aspose.Pdf.Facades.PdfFileInfo();
info.BindPdf("input.pdf");
var privilege = info.GetDocumentPrivilege();
In case of any further assistance please feel free to contact us.
Best Regards,
Hi Surendra,Andy.A.Kuan@wellsfargo.com:HiI have used isEncrypted property but it returns true even if there is no password in the PDF document.