PdfEncryptionDetails Class

Contains details for encrypting and access permissions for a PDF document.

ExpandedInheritance Hierarchy

SystemObject
  Aspose.Words.SavingPdfEncryptionDetails

Namespace:  Aspose.Words.Saving
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 21.5.0

ExpandedSyntax

public class PdfEncryptionDetails

The PdfEncryptionDetails type exposes the following members.

ExpandedConstructors

  NameDescription
Public methodCode examplePdfEncryptionDetails
Initializes an instance of this class.

ExpandedProperties

  NameDescription
Public propertyCode exampleEncryptionAlgorithm
Specifies the encryption algorithm to use.
Public propertyCode exampleOwnerPassword
Specifies the owner password for the encrypted PDF document.
Public propertyCode examplePermissions
Specifies the operations that are allowed to a user on an encrypted PDF document. The default value is DisallowAll.
Public propertyCode exampleUserPassword
Specifies the user password required for opening the encrypted PDF document.

ExpandedMethods

  NameDescription
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)

ExpandedExamples

Shows how to set permissions on a saved PDF document.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

builder.Writeln("Hello world!");

PdfEncryptionDetails encryptionDetails =
    new PdfEncryptionDetails("password", string.Empty, PdfEncryptionAlgorithm.RC4_128);

// Start by disallowing all permissions.
encryptionDetails.Permissions = PdfPermissions.DisallowAll;

// Extend permissions to allow the editing of annotations.
encryptionDetails.Permissions = PdfPermissions.ModifyAnnotations | PdfPermissions.DocumentAssembly;

// Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
// to modify how that method converts the document to .PDF.
PdfSaveOptions saveOptions = new PdfSaveOptions();

// Enable encryption via the "EncryptionDetails" property.
saveOptions.EncryptionDetails = encryptionDetails;

// When we open this document, we will need to provide the password before accessing its contents.
doc.Save(ArtifactsDir + "PdfSaveOptions.EncryptionPermissions.pdf", saveOptions);

ExpandedSee Also