setEncryption

Enable encryption on an output PDF file.
setEncryption([in] LONG outputHandle, [in] int mode, [in] BSTR ownerPassword, [in] BSTR userPassword, [in] int permissions)
This function enables encryption on the output PDF file

This function must be called immediately after openOutput, 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:

Note that all of the encryption mode constants are read-only properties on the COM component, so you'll need to use pdf.encrypt128BitRC4, etc.

The permission bits should start with xpdfSplicePermBase (which sets reserved bits according to the PDF spec). By itself, permBase disables all permissions. You can then add bits from the following list:

For more information, see Table 3.20 in the PDF 1.7 spec.

Note that all of the permission bit constants are read-only properties on the COM component, so you'll need to use pdf.permBase, pdf.permPrint, etc.

VB6:
Dim out as Long out = pdf.openOutput("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 pdf.setEncryption out, pdf.encrypt128BitRC4, "Secret", "", pdf.permBase + pdf.permPrint
VB.net:
Dim out as Long out = pdf.openOutput("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 pdf.setEncryption(out, pdf.encrypt128BitRC4, "Secret", "", pdf.permBase + pdf.permPrint)