ProtectionEnabled
IPDFDocument3 :: General document methods

See Also Example
Collapse All

This property gets or sets the value indicating whether encryption of the PDF document is enabled.

Syntax

VARIANT_BOOL ProtectionEnabled { get; set; }
Value
VARIANT_TRUE if encryption of the PDF document is enabled, VARIANT_FALSE if it is not.

Remarks

Setting ProtectionEnabled to VARIANT_TRUE encrypts the PDF document and protects it from unauthorized access.

Example

How to Protect a PDF Document

Delphi
[copy to clipboard]
{ PDF object is supposed to be created }
PDF.ProtectionEnabled := true;
PDF.ProtectionKeyLength := ckl128;
PDF.UserPassword = 'userpassword';
PDF.OwnerPassword = 'superpassword';
PDF.ProtectionOptions_coCopyInformation := false;
PDF.ProtectionOptions_coModifyAnnotation := false;
PDF.ProtectionOptions_coModifyStructure := false;
PDF.ProtectionOptions_coPrint := false;

PDF.BeginDoc;
{ some document generating code here... }
PDF.EndDoc;
C/C++
[copy to clipboard]
// PDF object is supposed to be created
PDF->ProtectionEnabled = TRUE;
PDF->ProtectionKeyLength = ckl128;
PDF->UserPassword = "userpassword";
PDF->OwnerPassword = "superpassword";
PDF->ProtectionOptions_coCopyInformation = FALSE;
PDF->ProtectionOptions_coModifyAnnotation = FALSE;
PDF->ProtectionOptions_coModifyStructure = FALSE;
PDF->ProtectionOptions_coPrint = false;

PDF.BeginDoc();
// some document generating code here...
PDF->EndDoc();
C#
[copy to clipboard]
// PDF object is supposed to be created
PDF.ProtectionEnabled = true;
PDF.ProtectionKeyLength = TxCryptoKeyLength.ckl128;
PDF.UserPassword = "userpassword";
PDF.OwnerPassword = "superpassword";
PDF.ProtectionOptions_coCopyInformation = false;
PDF.ProtectionOptions_coModifyAnnotation = false;
PDF.ProtectionOptions_coModifyStructure = false;
PDF.ProtectionOptions_coPrint = false;

PDF.BeginDoc();
// some document generating code here...
PDF.EndDoc();
Visual Basic
[copy to clipboard]
' PDF object is supposed to be created
PDF.ProtectionEnabled = True
PDF.ProtectionKeyLength = 1 'ckl128
PDF.UserPassword = "userpassword"
PDF.OwnerPassword = "superpassword"
PDF.ProtectionOptions_coCopyInformation = False
PDF.ProtectionOptions_coModifyAnnotation = False
PDF.ProtectionOptions_coModifyStructure = False
PDF.ProtectionOptions_coPrint = False

PDF.BeginDoc
' some document generating code here...
PDF.EndDoc

See Also

Reference