PdfEncryptionDetailsUserPassword Property |
Namespace: Aspose.Words.Saving
The user password will be required to open an encrypted PDF document for viewing. The permissions specified in Permissions will be enforced by the reader software.
The user password can be null or empty string, in this case no password will be required from the user when opening the PDF document. The user password cannot be the same as the owner password.
Document doc = new Document(MyDir + "Rendering.docx"); PdfSaveOptions saveOptions = new PdfSaveOptions(); // Create encryption details and set owner password PdfEncryptionDetails encryptionDetails = new PdfEncryptionDetails("password", string.Empty, PdfEncryptionAlgorithm.RC4_128); // Start by disallowing all permissions encryptionDetails.Permissions = PdfPermissions.DisallowAll; // Extend permissions to allow editing or modifying annotations encryptionDetails.Permissions = PdfPermissions.ModifyAnnotations | PdfPermissions.DocumentAssembly; saveOptions.EncryptionDetails = encryptionDetails; // Render the document to PDF format with the specified permissions doc.Save(ArtifactsDir + "Rendering.EncryptionPermissions.pdf", saveOptions);