Can't open pdf file which encrypted with adobe acrobat with Encryption Level:256-bit AES

Hi, Aspose team:
We met one problem which is when I encrypt my pdf with adobe acrobat 2019 (add a permissions password), which encryption level is 256-bit AES, I can’t open this document with the permission password, here5pages.pdf (177.0 KB)
is my sample pdf (it haven’t open password, just only have a permission:123)
This is my sample code:openDoc.png (11.7 KB)
when I encrypt my pdf using 128-bit AES or 128-bit RC4 in adobe acrobat, everything will be ok.
can you help me? thanks very much!

@Glority_Developer

We tested the scenario in our environment while using Aspose.PDF for .NET 21.4 and did not notice any issue. Please check the following code snippet and respective console output for your kind reference:

Aspose.Pdf.Facades.PdfFileInfo pdfFileInfo = new Aspose.Pdf.Facades.PdfFileInfo(dataDir + "5pages.pdf");
Console.WriteLine("Is Password protected: " + pdfFileInfo.HasOpenPassword);
Console.WriteLine("Is Valid PDF file: " + pdfFileInfo.IsPdfFile);

Console Output

Is Password protected: False
Is Valid PDF file: True

Would you please make sure to use the latest version of the API and let us know in case you still notice any issue.

Thanks for your replay,
yeah, you are right,I don’t set open Password in this pdf, but I had set Edit Passwordset.png (7.8 KB)
you can see this in PdfFileInfo.HasEditPassword and I want to use the edit password to open this document, it failed. Please check it. thanks

@Glority_Developer

Do you want to edit this PDF file using the API and are you facing some issue while doing so? Please share the code snippet that you have tried to open and edit this PDF and you faced some error. We need complete details of the scenario in order to investigate it.

Hello,
my code is in the main content (openDoc.png), you can download and see it. thanks.
There is c# code

try
{
const string password = “123”//the pdf permission password.
var document = new Document(dataDir + “5pages.pdf”, password);
}
catch(Exception e)
{
}

it will throw an exception with message is ‘invalid password’.
thanks, let’s me know if you have any problem!
you also can try with a new pdf file. and encrypted by adobe acrobat. remembering the encryption level is 256-bit AES, it can’t open from aspose.Pdf.Document with permission password.

@Glority_Developer

We have already viewed the code snippet shared in the screenshot by you. However, please note that the password in Document constructor is specified when PDF has any open password. In your case, the PDF has only Edit Password and which is why the Exception is being thrown by the API as it is taking the second argument as an open password that is not present.

Furthermore, the edit password is required when you edit or modify the existing PDF document. So, you can try modifying the PDF document as per your requirements by simply initializing the Document without any password and if you face any issue or exception, please let us know. We will further proceed to assist you accordingly.

sorry, I had a holiday so that replay you too later.
now I upload two files, they all have two password, open password(the password is open), and permission password(the password is edit)5pages_128-bit_AES.pdf (176.1 KB)
5pages_256-bit_AES.pdf (177.0 KB)
they are no different but except the encryption level, one is 128-bit AES, others is 256-bit AES,
the 128-bit AES protected file can work well, but the 128-bit AES protected file not.
Furthermore. I see the annotation of the aspose.pdf.document (public Document(string filename, string password) function. either user or owner password can open document. is it means I can open the document with a permission password? when I try this with the 128-bit AES protected pdf file. it’s ok.
so I think the problem is not the pdf file have not an open password. please try the pdf file I support. I need your help, thanks.

@Glority_Developer

Thanks for further elaborating on the issue.

We were able to replicate the issue at our end with 21.4 version of the API. Therefore, it has been logged as PDFNET-49876 in our issue management system for the sake of correction. We will further look into its details and keep you posted with the status of its correction. Please be patient and spare us some time.

We are sorry for the inconvenience.

I am sincerely grateful for your help!thanks.

In case you can’t fix this issue, we plan to add a message to users like :This PDF is encrypted with an encryption method not supported. Unable to unlock this PDF.

However, we can’t distinguish if Aspose can’t unlock the PDF by this reason, or due to that the user has inputted a wrong change permission password. Do you know how to distinguish the two case?

@Glority_Developer

We will surely investigate and resolve this case of yours. However, you can implement exception handling by catching the Aspose.Pdf.InvalidPasswordException Exception in the code if such a scenario occurs. Furthermore, we will be able to comment more on the situation once the ticket is investigated. Please be patient and spare us some time.

We are sorry for the inconvenience.

The issues you have found earlier (filed as PDFNET-49876) have been fixed in Aspose.PDF for .NET 24.11.