I tried to open a PDF file not secured with a password with a password. I was surprised that it was open without throwing an exception. So my question is if there's any risk side effect with writing such code, I mean opening a non encrpted PDF with any password? Thank you
@Khalil,
There is not any problem with opening such a file with password because the constructor internally uses the password only when encryption of file is certain. So you may keep the code as it is or better update it as under, for more clarity:
PdfFileInfo info = new PdfFileInfo(dataDir + "Aspose.pdf");
if (info.IsEncrypted)
{
//Source document is password protected
//TODO Code Here
}
else
{
//Source document is not password protected
//TODO Code Here
}
PS: I work with Aspose as Developer Evangelist.