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

Free Support Forum - aspose.com

Exception "User password can't be same as owner password"

Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Sample:

PdfFileSecurity sec = new PdfFileSecurity(stampedStream, securedStream);

documentPrivilege.AllowScreenReaders = true;

DocumentPrivilege documentPrivilege = DocumentPrivilege.ForbidAll; documentPrivilege.AllowPrint = true;

sec.EncryptFile(null, null, documentPrivilege, KeySize.x128);


We receive exception:

Aspose.Pdf.Exceptions.InvalidPasswordException was caught

Message=User password can't be same as owner password

Source=Aspose.Pdf

StackTrace:

at Aspose.Pdf.Facades.PdfFileSecurity.[1](String , String , String , Permissions , CryptoAlgorithm )

at Aspose.Pdf.Facades.PdfFileSecurity.EncryptFile(String userPassword, String ownerPassword, DocumentPrivilege privilege, KeySize keySize)



But summary for method
EncryptFile say:
Summary:

Encrypts Pdf file with userpassword and ownerpassword and sets the document's privileges to access. The user password and the owner password can be null or empty. The owner password will be replaced with a random string if the input owner password is null or empty.

Hello Igor,


Thanks for using our products. As far as I can understand, the issue might be occurring because you are using some password protected document as input and trying to apply security restrictions without first decrypting it. If so is the case, then please first decrypt the source file using DecryptFile method of PdfFileSecurity class. In case the problem still persists, please share the source PDF document so that we can test the scenario at our end. We apologize for your inconvenience.

Hi Igor,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

<o:p> </o:p>

Thank you for sharing the sample code and
details.<o:p></o:p>

<o:p> </o:p>

I am able to reproduce the issue at my end.
Your issue has been registered in our issue tracking system with issue id PDFNEWNET-32900

for rectification. Our development team will further look into the issue and
you will be notified via this forum thread regarding any updates against your
issue.<o:p></o:p>

<o:p> </o:p>

Sorry for the inconvenience,<o:p></o:p>

The issues you have found earlier (filed as PDFNEWNET-32900) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.