Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Thu Jan 05, 2023 2:10 am

Hi,

We face an issue that client couldn't open the 256-AES password protected PDF with Adobe product in their Android phone, below are our test result :-
- ABLE to open via Adobe in PC
- ABLE to open via Adobe in iPhone
- ABLE to open via GDrive, Microsoft Office, OneDrive in Android
- NOT ABLE to open via Adobe reader (or any Adobe related product) in Android

**With Adobe Android, We do able to open with Permission Password but not Open Password.

Here's the code we use (Spire.PDF 8.12.7):-
Code: Select all
    var result = new Spire.Pdf.PdfDocument();
    Spire.Pdf.Security.PdfEncryptionKeySize keySize = Spire.Pdf.Security.PdfEncryptionKeySize.Key256Bit;
    Spire.Pdf.Security.PdfPermissionsFlags allowPrint = Spire.Pdf.Security.PdfPermissionsFlags.Print;
    result.Security.Encrypt("123456789", "M123456789", allowPrint, keySize);

    Spire.Pdf.Graphics.PdfMargins pdfMargin = new Spire.Pdf.Graphics.PdfMargins();
    Spire.Pdf.Graphics.PdfUnitConvertor unitCvtr = new Spire.Pdf.Graphics.PdfUnitConvertor();
    pdfMargin.Left = unitCvtr.ConvertUnits(0, Spire.Pdf.Graphics.PdfGraphicsUnit.Pixel, Spire.Pdf.Graphics.PdfGraphicsUnit.Point);
    pdfMargin.Right = unitCvtr.ConvertUnits(0, Spire.Pdf.Graphics.PdfGraphicsUnit.Pixel, Spire.Pdf.Graphics.PdfGraphicsUnit.Point);
    pdfMargin.Top = unitCvtr.ConvertUnits(0, Spire.Pdf.Graphics.PdfGraphicsUnit.Pixel, Spire.Pdf.Graphics.PdfGraphicsUnit.Point);
    pdfMargin.Bottom = unitCvtr.ConvertUnits(0, Spire.Pdf.Graphics.PdfGraphicsUnit.Pixel, Spire.Pdf.Graphics.PdfGraphicsUnit.Point);
    var pageSize = Spire.Pdf.PdfPageSize.A4;

    Spire.Pdf.PdfPageBase spirePage = result.Pages.Add(pageSize, pdfMargin);
    result.SaveToFile($"{rootDir}/result/testing.pdf", Spire.Pdf.FileFormat.PDF);


**In this case, we able to open in Adobe Android using "M123456789" but not "123456789"

As attached is the sample protected PDF

cgscimbspire
 
Posts: 3
Joined: Wed Jan 04, 2023 8:34 am

Thu Jan 05, 2023 6:24 am

Hi,

Thanks for your feedback.
I have reproduced your issue and logged it in our issue tracking system with SPIREPDF-5702. We are sorry for any inconvenience caused.
We will do our best to fix it ASAP. Once it is fixed, we will inform you and provide you with a new version.


Sincerely,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Tue Jan 17, 2023 3:43 am

amy.zhao wrote:Hi,

Thanks for your feedback.
I have reproduced your issue and logged it in our issue tracking system with SPIREPDF-5702. We are sorry for any inconvenience caused.
We will do our best to fix it ASAP. Once it is fixed, we will inform you and provide you with a new version.


Sincerely,
Amy
E-iceblue support team



Hi,

Just to follow up, any update on this issue?

by the way when we generate with Key128Bit, its default to RC4 instead of AES, and we noticed that there is a enum PdfEncryptionAlgorithm.AES, however there is no overload method Encrypt() taking it as param (as attached), how do we use this enum or how to we protect PDF with 128-AES instead?

cgscimbspire
 
Posts: 3
Joined: Wed Jan 04, 2023 8:34 am

Tue Jan 17, 2023 9:24 am

Hi,

Thanks for your inquiry.
For SPIREPDF-5702, our developer has investigated the reason that the length of the password is inconsistent due to the inconsistency of the encryption algorithm of different versions. Our developer is trying to find a way to make compatibility.
For setting AES for Key128Bit, I have added it as new feature in our upgrading system with SPIREPDF-5734. Once it is finished, I will inform you.

Sincerely,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Tue Feb 28, 2023 1:51 am

Hi,

Hope you are doing well.
I am glad to inform you that our developer has solved SPIREPDF-5702. I will inform you when the new version is released.
SPIREPDF-5734 function is being implemented.

Sincerely,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Wed Mar 15, 2023 10:18 am

Hello,

Thank you for your patience.
Glad to inform that we just released Spire.PDF Pack(Hot Fix) Version:9.3.4 which fixed the issue of SPIREPDF-5702, welcome to test it.
Website link: https://www.e-iceblue.com/Download/download-pdf-for-net-now.html
Nuget link: https://www.nuget.org/packages/Spire.PDF/9.3.4

Sincerely,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Tue Mar 28, 2023 2:20 am

Hi,

Noted, we tested internally and its seem resolved.
Thanks!

cgscimbspire
 
Posts: 3
Joined: Wed Jan 04, 2023 8:34 am

Tue Mar 28, 2023 3:02 am

Hi,

Thank you for your update.

We are glad to hear that the issue has been resolved. If you have any further concerns, please don't hesitate to reach out to us. We are always happy to assist you.

Sincerely,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Fri Jul 21, 2023 3:46 am

Hi,

We hope this email finds you well.
Glad to inform you that we just released Spire.Pdf 9.7.14 hotfix, which has implemented the new feature SPIREPDF-5734 you suggested. Please refer to the following code for detailed usage.
Code: Select all
// encrypt
var result = new PdfDocument();
PdfSecurityPolicy securityPolicy = new PdfPasswordSecurityPolicy("123456789", "M123456789");  //Create password security policy
securityPolicy.EncryptionAlgorithm = PdfEncryptionAlgorithm.AES_128;  //Set encryption algorithm
securityPolicy.DocumentPrivilege = PdfDocumentPrivilege.AllowAll;    //Set document permissions (ownership), default: ForbidAll
securityPolicy.DocumentPrivilege.AllowPrint = false;
result.Encrypt(securityPolicy);
Spire.Pdf.Graphics.PdfMargins pdfMargin = new Spire.Pdf.Graphics.PdfMargins();
Spire.Pdf.Graphics.PdfUnitConvertor unitCvtr = new Spire.Pdf.Graphics.PdfUnitConvertor();
pdfMargin.Left = unitCvtr.ConvertUnits(0, Spire.Pdf.Graphics.PdfGraphicsUnit.Pixel, Spire.Pdf.Graphics.PdfGraphicsUnit.Point);
pdfMargin.Right = unitCvtr.ConvertUnits(0, Spire.Pdf.Graphics.PdfGraphicsUnit.Pixel, Spire.Pdf.Graphics.PdfGraphicsUnit.Point);
pdfMargin.Top = unitCvtr.ConvertUnits(0, Spire.Pdf.Graphics.PdfGraphicsUnit.Pixel, Spire.Pdf.Graphics.PdfGraphicsUnit.Point);
pdfMargin.Bottom = unitCvtr.ConvertUnits(0, Spire.Pdf.Graphics.PdfGraphicsUnit.Pixel, Spire.Pdf.Graphics.PdfGraphicsUnit.Point);
var pageSize = PdfPageSize.A4;            PdfPageBase spirePage = result.Pages.Add(pageSize, pdfMargin);
result.SaveToFile(outputFile, FileFormat.PDF);

Code: Select all
// decrypt
PdfDocument pdf = new PdfDocument();
pdf.LoadFromFile(inputFile, "1234");
pdf.Decrypt();
pdf.SaveToFile(outputFile, FileFormat.PDF);
pdf.Dispose();


Website link: https://www.e-iceblue.com/Download/download-pdf-for-net-now.html
Nuget: https://www.nuget.org/packages/Spire.PDF/9.7.14

In addition, starting from version 9.6.0 of Spire.PDF, we have made changes to the licensing method. Please update your application's applying licensing key method accordingly.
Code: Select all
Spire.Pdf.License.LicenseProvider.SetLicenseKey("your license key");


Best regards,
Triste
E-iceblue support team
User avatar

Triste.Dai
 
Posts: 1000
Joined: Tue Nov 15, 2022 3:59 am

Return to Spire.PDF

cron