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

Free Support Forum - aspose.com

Issue : PDF encrypted with password using Aspose.pdf does not prompt for password in iOS

Hi Team,


We are using Aspose.pdf ver 6.5 in our .Net code.
We have encrypted the pdf file to prompt for a password before it opens. However, this does not seem to work in iOS and opens without password.
We are planning to upgrade to the latest version of Aspose.pdf. We downloaded and implemented the free trial version (17.2.0) from https://www.aspose.com/products/pdf/net to see if this issue has been addressed. However, it did not seem to work even with the latest version.
Could you please let us know if this issue has been addressed in any other encryption method in Aspose.pdf which we may not have known.

Posting below a sample code of how we generated the encrypted pdf.

Aspose.Pdf.Facades.DocumentPrivilege _previ = Aspose.Pdf.Facades.DocumentPrivilege.ForbidAll;
Aspose.Pdf.Facades.PdfFileSecurity _sec = new Aspose.Pdf.Facades.PdfFileSecurity(“D:\PoCPDF.pdf”, “D:\PoCPDFPassword.pdf”);
_sec.EncryptFile(“abc1234”, “”, _previ, Aspose.Pdf.Facades.KeySize.x256);

We also used another method as below. With this, the document prompts for the password only the first time it opens. Second time onwards, it opens without password.

Document doc = new Document(“D:\PoCPDF.pdf”);
doc.Encrypt(“userpwd”, “ownerpwd”, 0, CryptoAlgorithm.AESx128);
doc.Save(“D:\PassPoCPDF.pdf”);

Our clients use iBooks for opening the pdf documents. Acrobat Reader is not a preferred choice.

Hi There,


Thanks for using our API’s.

I have tested your code with little modification and manage to produce the correct output file. I opened the file in iBook iPhone and Mac and it does prompt for the password for the first time. I have highlighted the necessary modification required in your code. You need to set owner Password as well, this will not allow iBook to open the PDF document without password for the first time. I have attached the encrypted output PDF document as well.

Aspose.Pdf.Facades.DocumentPrivilege _previ = Aspose.Pdf.Facades.DocumentPrivilege.ForbidAll;

Aspose.Pdf.Facades.PdfFileSecurity _sec = new Aspose.Pdf.Facades.PdfFileSecurity(“D:\PoCPDF.pdf”, “D:\PoCPDFPassword.pdf”);

_sec.EncryptFile(“abc1234”, “abc1234”, _previ, Aspose.Pdf.Facades.KeySize.x256);

If you still face any issue, please feel free to contact us.

Best Regards,

Just a quick observation regarding this topic…

I am currently doing this with Aspose.PDF 19.11 - in this case we set both userpassword and ownerpassword to the same value and we don’t seem to be experiencing the issue described by mubst. The document prompts for a password every time the user tries to open it. Can I therefore make the assumption that this got fixed at some point between the “build 17” version that mubst was using and the current build 19.11?

@rozeboosje

We are afraid it was not logged in our issue management system because we were able to sort it out as per the response above. So any changes were not made in the API for this thread. However, it is also possible that some changes while working on some other problem might have affected the scenario somehow.

1 Like