Aspose::Words::Saving::PdfEncryptionDetails::PdfEncryptionDetails constructor

PdfEncryptionDetails::PdfEncryptionDetails(const System::String&, const System::String&) constructor

Initializes an instance of this class.

Aspose::Words::Saving::PdfEncryptionDetails::PdfEncryptionDetails(const System::String &userPassword, const System::String &ownerPassword)

See Also

PdfEncryptionDetails::PdfEncryptionDetails(const System::String&, const System::String&, Aspose::Words::Saving::PdfPermissions) constructor

Initializes an instance of this class.

Aspose::Words::Saving::PdfEncryptionDetails::PdfEncryptionDetails(const System::String &userPassword, const System::String &ownerPassword, Aspose::Words::Saving::PdfPermissions permissions)

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