EncryptPublicKey
Security and signatures
Requires the Enterprise edition — in Delphi, C++Builder and Lazarus code create the library as TPDFlibEnterprise (unit PDFlibEnterprise); the Enterprise DLL and ActiveX builds provide it unchanged; other editions keep the method, which returns 0, an empty string or False and sets LastErrorCode to 900 (PDFLIB_ERROR_ENTERPRISE_REQUIRED)
Description
Configures Adobe.PubSec public-key encryption for the selected document using its pending recipient certificates and permission groups
Syntax
Delphi
Function TPDFlib.EncryptPublicKey(Strength: Integer): Integer; Virtual;
ActiveX
Function PDFlib::EncryptPublicKey(Strength As Long) As Long
DLL
int DLEncryptPublicKey(int InstanceID, int Strength);
Parameters
| Strength | Use 2 for AES-128 with AESV2 or 3 for AES-256 with AESV3 |
|---|
Return values
| 1 | Public-key encryption was configured |
|---|---|
| 0 | No recipient is configured, the strength is unsupported, or the document state is incompatible |
Remarks
The output uses /Filter /Adobe.PubSec, /SubFilter /adbe.pkcs7.s5, CMS EnvelopedData, and per-group permission payloads
PDF MAC and embedded-files-only encryption cannot be combined with this operation
See also
AddPublicKeyRecipientFromFile, SetPublicKeyDecryptionPFX, GetPubSecStatus