PdfEncryptionDetailsUserPassword Property

Specifies the user password required for opening the encrypted PDF document.

Namespace:  Aspose.Words.Saving
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.3
Syntax
public string UserPassword { get; set; }

Property Value

Type: String
Remarks

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.

Examples
Demonstrates how to set permissions on a PDF document generated by Aspose.Words.
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);
See Also