We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

PDFFileInfo properties not working for PDF files encrypted with 256bit AES

Hello, we are seeing an issue with Apose.PDF 18.1 where if we try to get info for PDF file encrypted with 256 AES encryption: Following properties are not working as expected:

Scenario 1: PDF File has only User password:

  • In this case, when we use the Aspose.Pdf.Facades.PdfFileInfo to check the properties of the file:
    • HasEditPassword : Returned true, whereas it does not have an Owner password.
    • PasswordType: Return ‘User’ correctly.

Scenario 2: PDF File has both User and Owner password: And owner password provided while opening the document:

  • In this case, when we use the Aspose.Pdf.Facades.PdfFileInfo to check the properties of the file:
    • HasEditPassword : Throws Invalid password exception.
    • PasswordType: Inaccessible
    • Does not open the document.

Scenario 3: PDF File has only Owner password: And owner password provided while opening the document:

  • In this case, when we use the Aspose.Pdf.Facades.PdfFileInfo to check the properties of the file:
    • HasEditPassword : Throws Invalid password exception.
    • PasswordType: Inaccessible
    • Does not open the document.test_open_change_pwd.pdf (27.5 KB)

Note: It is working correctly for pdf documents with 128 bit AES.

We would like to restrict document editing until the user provides correct ‘Owner’ password. This issue is a hindrance to achieve that goal. Please let us know if there is a workaround for that functionality.

Attaching sample pdf, the user password is: open and owner password is: change.
test_open_change_pwd.pdf (27.5 KB)

@dcdeveloper

Thank you for contacting support.

We appreciate your posting issues separately. Please share your feedback with us about following points:

How are you creating a file with a user password only? Please share the steps/code snippet as well as the generated PDF file.

Kindly share the PDF file along with the steps or code snippet that you are using to create such a file.

Is that ‘Note’ referring to 3rd scenario only, or all three scenarios work correctly with 128 bit AES encrypted documents?

I can find only one PDF document attached. Kindly upload all relevant files, including 128 bit AES encrypted files, while specifying the file names related to each scenario.

Kindly share requested data and information with us so that we may proceed to help you out.

We can create secured PDFs using Acrobat Pro, (see file below) From File->Properties:
Setting_Change_Password.png (31.2 KB)

Below is the file created using Acrobat Pro 10 using the above steps. This has only owner password.
PDF_256-bit AES Encryption (Acrobat X and later)_Permission password only.pdf (119.9 KB)

It looks like this problem is happening with documents created using Acrobat 10, documents created with Acrobat 9 does not have this issue. Below is a file created with Acrobat 9.

Secured PDF [256AES][Acro 9 ]_Open [Pwd = open].pdf (8.2 KB)

Yes, All 3 scenarios work fine with documents with 128 bit AES encryption.
Secured PDF (128 bit AES)_Permission_Password_Only.pdf (27.1 KB)

For all files, Open password is: open and Permission/Owner password is: change

@dcdeveloper

Thank you for sharing requested data.

I have worked over the scenarios shared by you and would like to share below findings:

While working with all the files, HasEditPassword is returned false when the file has only OpenPassword. Otherwise it is returned true for all the 3 files which have EditPassword.

About the PasswordType, it returns the type of password which was passed for creating PdfFileInfo instance. Since we need to specify OpenPassword while loading a file, so PasswordType always returns ‘user’.

Invalid password exception is thrown when you try to load it with EditPassword, load it without any password because that file does not contain OpenPassword. Moreover, EditPassword is apparently for the users who work with PDF files with some application, Foxit, Adobe Acrobat for instance.

I have attached a comparison for your kind reference Comparison.JPG. Please share with us if you notice any discrepancy in the table, so that we may investigate to help you out.

Hi Farhan, thank you for the update. The comparison report looks accurate. However, that is the issue we are trying to report as a bug.

Blockquote Invalid password exception is thrown when you try to load it with EditPassword, load it without any password because that file does not contain OpenPassword. Moreover, EditPassword is apparently for the users who work with PDF files with some application, Foxit, Adobe Acrobat for instance.

Looks like you have not tried to open the document using the Owner password. Document class constructor can take either of the passwords, However, it fails to open the document when we pass Owner password. We think this is an issue.

Below is an example it wrongly reports that the document has an Edit password, when it does not have one.
Secured PDF [256 AES][Acro 10 ][Open Pwd = open]_ForAspose.pdf (36.1 KB)

We need both the properties to work correctly. Can you pls check and update?

Let us know if any questions.

Hello Farhan,

Regarding Scenario 2: mentioned above (PDF File has both User and Owner password: And owner password provided while opening the document).
[256AES][Acro X ]_Open [Pwd = open].pdf (232.7 KB)

The attached document have both User and Owner password. When Owner password is passed to open the document using Aspose.PDF 18.1, exception is thrown as “Document must be opened with valid password in order to read this property”.

Following code snippet is added to explain it further:

// Open PDF file using Aspose.PDF 18.1
private void OpenPdfFile()
{
    // 256-bit AES (Acrobat X and later) (PDF 1.7 Extension Level 8) encrypted PDF
    string selectedPath = "C:\\OpenPdfWithAspose\\[256AES][Acro X+]_Open [Pwd = open].pdf";
    try
    {
        // 256-bit AES (Acrobat X and later) (PDF 1.7 Extension Level 8) encrypted PDF

        // "open" is user password
        //PdfFileInfo _pdfFileInfo = new PdfFileInfo(selectedPath, "open"); // Works fine

        // "change" is owner password
        PdfFileInfo _pdfFileInfo = new PdfFileInfo(selectedPath, "change"); // Throws Exception, fails to open document

        if (_pdfFileInfo.HasEditPassword)
        {
            // Do something...
        }
    }
    catch (Exception ex)
    {
        //Exception thrown is: Document must be opened with valid password in order to read this property.
        throw ex;
    }
}

Could you please check this on your end and let us know your findings?

@dcdeveloper

Thank you for elaborating the problem.

I have worked with the data shared by you and have been able to reproduce following issues in our environment. Below ticket IDs have been logged in our issue management system for further investigation and resolution.

  • PDFNET-44193: Issue with HasEditPassword property
  • PDFNET-44194: Exception while opening a file with Owner password

This thread has been linked with the issue IDs so that you will receive notifications as soon as the issues are resolved.

We are sorry for the inconvenience.