Name
doc:SetEncryptionMode -- set document encryption mode
Synopsis
status = doc:SetEncryptionMode(mode[, keylen])
Function
doc:SetEncryptionMode() set the encryption mode. As a side effect, it ups the version of PDF to 1.4 when the mode is set to #HPDF_ENCRYPT_R3.

The following encryption modes are currently supported:

#HPDF_ENCRYPT_R2:
Use "Revision 2" algorithm. keylen is automatically set to 5 (40 bits).

#HPDF_ENCRYPT_R3:
Use "Revision 3" algorithm. keylen can be 5 (40 bits) to 16 (128bits).

When doc:SetEncryptionMode() succeeds, it returns #HPDF_OK. Otherwise, it returns an error code and the error handler is called.

Inputs
mode
one of the encryption modes listed above
keylen
specify the byte length of encryption key; only needed for #HPDF_ENCRYPT_R3 (defaults to 5, i.e. 40 bits)
Results
status
status code
Errors
#HPDF_INVALID_DOCUMENT - An invalid document handle was set.

#HPDF_INVALID_ENCRYPT_KEY_LEN - An invalid key length was specified.

#HPDF_FAILED_TO_ALLOC_MEM - Memory allocation failed.


Show TOC