xpdfSpliceSetEncryption
Enable encryption on an output PDF file.
void xpdfSpliceSetEncryption(XpdfSpliceOutputHandle out, int mode,
const char *ownerPassword, const char *userPassword,
int permissions)
This function enables encryption on the output PDF file
This function must be called immediately after
xpdfSpliceOpenOutput
, before calling any other functions on this
output handle. Encryption is performed on the fly, i.e., objects are
encrypted as they are written to the output file.
The arguments are:
mode
= encryption mode - one of the following values:xpdfSpliceEncrypt128BitRC4
: 128-bit RC4 encryption (PDF 1.4 and higher)xpdfSpliceEncrypt128BitAES
: 128-bit AES encryption (PDF 1.5 and higher)
ownerPassword
= the password which will be required to change the PDF fileuserPassword
= the password which will be required to open the file for viewing; to allow anyone to open the file (subject to the permissions), setuserPassword
to an empty stringpermissions
= the permission bits - see below
xpdfSplicePermBase
(which sets reserved bits according to the PDF spec). By itself,
xpdfSplicePermBase
disables all permissions. You can
then add bits from the following list:
xpdfSplicePermPrint
: printingxpdfSplicePermModify
: general modificationxpdfSplicePermCopy
: copy/extract text and graphicsxpdfSplicePermAnnotate
: add annotationsxpdfSplicePermFormFill
: fill form fieldsxpdfSplicePermAccessibility
: extract text and graphics for accessibilityxpdfSplicePermAssemble
: assemble the documentxpdfSplicePermPrintHQ
: high-quality printing
C:
XpdfSpliceInputHandle out;
out = xpdfSpliceOpenOutput("c:/test/newfile.pdf", 1.4);
/* set user password to an empty string, so anyone can open the file */
/* set permissions to allow printing and nothing else */
xpdfSpliceSetEncryption(out, xpdfSpliceEncrypt128BitRC4,
"Secret", "",
xpdfSplicePermBase | xpdfSplicePermPrint);