status = doc:SetEncryptionMode(mode[, keylen])
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:
keylen
is automatically set to 5 (40 bits).
#HPDF_ENCRYPT_R3:
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.
#HPDF_ENCRYPT_R3
(defaults to 5, i.e. 40 bits)#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.