Aspose::Words::Saving::PdfEncryptionDetails class

PdfEncryptionDetails class

Contains details for encrypting and access permissions for a PDF document. To learn more, visit the Protect or Encrypt a Document documentation article.

class PdfEncryptionDetails : public System::Object

Methods

MethodDescription
get_OwnerPassword() constSpecifies the owner password for the encrypted PDF document.
get_Permissions() constSpecifies the operations that are allowed to a user on an encrypted PDF document. The default value is DisallowAll.
get_UserPassword() constSpecifies the user password required for opening the encrypted PDF document.
GetType() const override
Is(const System::TypeInfo&) const override
PdfEncryptionDetails(const System::String&, const System::String&)Initializes an instance of this class.
PdfEncryptionDetails(const System::String&, const System::String&, Aspose::Words::Saving::PdfPermissions)Initializes an instance of this class.
set_OwnerPassword(const System::String&)Setter for Aspose::Words::Saving::PdfEncryptionDetails::get_OwnerPassword.
set_Permissions(Aspose::Words::Saving::PdfPermissions)Setter for Aspose::Words::Saving::PdfEncryptionDetails::get_Permissions.
set_UserPassword(const System::String&)Setter for Aspose::Words::Saving::PdfEncryptionDetails::get_UserPassword.
static Type()

Examples

Shows how to set permissions on a saved PDF document.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);

builder->Writeln(u"Hello world!");

auto encryptionDetails = MakeObject<PdfEncryptionDetails>(u"password", String::Empty);

// Start by disallowing all permissions.
encryptionDetails->set_Permissions(PdfPermissions::DisallowAll);

// Extend permissions to allow the editing of annotations.
encryptionDetails->set_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.
auto saveOptions = MakeObject<PdfSaveOptions>();

// Enable encryption via the "EncryptionDetails" property.
saveOptions->set_EncryptionDetails(encryptionDetails);

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

See Also