TPDFlibEntPubSec

Editions

Description

TPDFlibEntPubSec (unit PDFlibEntPubSec) descends from TPDFlibEntSignLTV and implements the Enterprise methods for certificate-based (public-key) encryption: it adds the recipient methods of TPDFlib and installs the recipient envelope builder that unit PDFlibPubSec calls when a document is saved with recipients.

It belongs to the Enterprise edition, which includes every Small Business class as well. It is the last Enterprise feature class: TPDFlibEnterprise descends from it.

Syntax

Delphi

TPDFlibEntPubSec = Class(TPDFlibEntSignLTV);

Key members

AddPublicKeyRecipientFromFileLoads the certificate from the file CertificateFileName and adds it to the selected document as a recipient with the permissions Permissions encodes
AddPublicKeyRecipientFromPFXLoads the certificate from the PKCS#12 file PFXFileName, opened with PFXPassword and with the machine key set when UseMachineKeyset is non-zero, and adds it as a recipient
AddPublicKeyRecipientFromStoreLoads the certificate CertificateName from the Windows certificate store StoreName, the machine store when UseMachineStore is non-zero, and adds it as a recipient
EncryptPublicKeyEncrypts the selected document for the registered recipients with the strength Strength selects: 2 AES-128, 3 AES-256, 4 SM4-128 or 5 AES-256-GCM

Remarks

EncryptPublicKey needs at least one recipient; without one it returns 0 and sets LastErrorCode to PDFLIB_ERROR_PUBSEC_RECIPIENT_INVALID. A Strength other than 2 to 5 sets LastErrorCode to 101.

A PDF MAC is allowed only with Strength 3 or 5. When the instance has the MAC enabled and the document not yet, EncryptPublicKey switches it on for the encryption and switches it back off when the encryption fails.

The unit also installs the envelope builder: it groups the recipients by permission word and builds one envelope per group over a 20-byte seed and the permission word, with the Windows CryptoAPI (AES-256) when every certificate of the group can be opened and with the library's own builder otherwise.

Applications normally create TPDFlibEnterprise and get the methods of this class through them. The same methods on a plain TPDFlib return 0, an empty string or False and set LastErrorCode to PDFLIB_ERROR_ENTERPRISE_REQUIRED. An Enterprise method called on TPDFlibSmallBusiness is rejected the same way, because that edition does not carry it.

See also

TPDFlibEntSignLTV, TPDFlibEnterprise, TPDFlibSmallBusiness