Aspose::Words::Saving::PdfSaveOptions::get_EncryptionDetails method
PdfSaveOptions::get_EncryptionDetails method
Gets or sets the details for encrypting the output PDF document.
System::SharedPtr<Aspose::Words::Saving::PdfEncryptionDetails> Aspose::Words::Saving::PdfSaveOptions::get_EncryptionDetails() const
Remarks
The default value is null and the output document will not be encrypted. When this property is set to a valid PdfEncryptionDetails object, then the output PDF document will be encrypted.
AES-128 encryption algorithm is used when saving to PDF 1.7 based compliance (including PDF/UA-1). AES-256 encryption algorithm is used when saving to PDF 2.0 based compliance.
Encryption is prohibited by PDF/A compliance. This option will be ignored when saving to PDF/A.
ContentCopyForAccessibility permission is required by PDF/UA compliance if the output document is encrypted. This permission will automatically used when saving to PDF/UA.
ContentCopyForAccessibility permission is deprecated in PDF 2.0 format. This permission will be ignored when saving to PDF 2.0.
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
- Class PdfEncryptionDetails
- Class PdfSaveOptions
- Namespace Aspose::Words::Saving
- Library Aspose.Words for C++