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

Free Support Forum - aspose.com

Pdf encryption


I am trying to encrypt a new pdf that is created from a stream.
Some how for some documents i would encounter an error thrown from the encryption

Here is a snippet of the code and the exception:

Aspose.Pdf.Document document = new Aspose.Pdf.Document(filestreamtest);
DocumentPrivilege documentPrivilege = DocumentPrivilege.ForbidAll;
document.Encrypt("", “”, documentPrivilege, CryptoAlgorithm.AESx128, false);

System.InvalidCastException: Unable to cast object of type ‘‡a.•’ to type ‘‡a.€’. at ‡a.•...’(”a , Š& , Œ ).

I am unable to see any pattern with the documents that is being encrypted.

Please advise. thank you.

Hi Nicholas,

Thanks for contacting support.

Can you please share the sample PDF files causing this issue so that we can test the scenario in our environment. We are sorry for this inconvenience.