Hi Venkat,
Thanks for your feedback.
We recommend upgrading to our latest version, as we have made adjustments to the encryption method. The newer version includes improvements and enhancements that may resolve the issue you are facing. Please update your installation to the latest version and retest the encryption feature.
To assist you further, we suggest referring to the following code snippet as a guide for encrypting your PDF documents:
- Code: Select all
//Load a pdf document.
PdfDocument doc = new PdfDocument();
doc.LoadFromFile(@"Encryption.pdf");
//Set the userPassword
string userPassword = "user";
//Set the ownerPassword
string ownerPassword = "owner";
//Create a PdfSecurityPolicy
PdfSecurityPolicy securityPolicy = new PdfPasswordSecurityPolicy(userPassword, ownerPassword);
// Gets the sets encryption algorithm.
securityPolicy.EncryptMetadata = false;
// Set encryption algorithm.
securityPolicy.EncryptionAlgorithm = PdfEncryptionAlgorithm.AES_128;
//Set the document's permission flags
securityPolicy.DocumentPrivilege = PdfDocumentPrivilege.AllowAll;
// Set permissions that do not allow printing.
securityPolicy.DocumentPrivilege.AllowPrint = false;
//Encrypt
doc.Encrypt(securityPolicy);
//Save pdf file.
doc.SaveToFile("Encryption-result.pdf");
doc.Close();
After testing the new version and following the updated encryption approach, if you encounter same issue, please provide us with the specific PDF documents and details about your project type. This information will help us investigate the problem more effectively and provide you with appropriate solutions.
Best regards,
Triste
E-iceblue support team