BCL easyPDF SDK
easyPDF SDK Usermanual
PDF Creator Programming API  |  Download Free Trial  |  Contact Us to Purchase

Encrypt Method

Encrypts a PDF file.

Sub Encrypt(InputFileName As String,
            OutputFileName As String,
            UserPassword As String,
            OwnerPassword As String,
            Encryption As prcSecEncryption,
            AnnotationPerm As prcSecAnnotationPerm,
            ExtractionPerm As prcSecExtractionPerm,
            ModificationPerm As prcSecModificationPerm,
            PrintingPerm As prcSecPrintingPerm)

void Encrypt(string InputFileName,
             string OutputFileName,
             string UserPassword,
             string OwnerPassword,
             prcSecEncryption Encryption,
             prcSecAnnotationPerm AnnotationPerm,
             prcSecExtractionPerm ExtractionPerm,
             prcSecModificationPerm ModificationPerm,
             prcSecPrintingPerm PrintingPerm)

void Encrypt(String InputFileName,
             String OutputFileName,
             String UserPassword,
             String OwnerPassword,
             prcSecEncryption Encryption,
             prcSecAnnotationPerm AnnotationPerm,
             prcSecExtractionPerm ExtractionPerm,
             prcSecModificationPerm ModificationPerm,
             prcSecPrintingPerm PrintingPerm) throws PDFProcessorException

Parameters

Return Values

N/A.

Remarks

If you enable any security feature, be sure to set the owner password or the user password. If you set both passwords, they should be different.

Also bear in mind that if the user password is set but no owner password is specified, the permission flags are ignored and full permissions are granted for all operations. In other words, the permission flags are only respected when there is an owner password.

The security features can be combined in any way, but be aware that out of the possible combinations, only five are offered by Adobe Acrobat. The five configurations available in Acrobat (when using 128-bit encryption) can be achieved as follows:

Acrobat "Changes Allowed" easyPDF SDK Flag Combination
None

PRN_SEC_MODIFY_PERM_NONE | PRN_SEC_ANNOT_PERM_NONE

Inserting, deleting, and rotating pages

PRN_SEC_MODIFY_PERM_ASSEMBLY | PRN_SEC_ANNOT_PERM_NONE

Filling in form fields and signing existing signature fields
PRN_SEC_MODIFY_PERM_NONE | PRN_SEC_ANNOT_PERM_FORM
Commenting, filling in form fields, and signing existing signature fields PRN_SEC_MODIFY_PERM_NONE | PRN_SEC_ANNOT_PERM_FULL
Any except extracting pages
PRN_SEC_MODIFY_PERM_FULL | PRN_SEC_ANNOT_PERM_FULL

Example Usage

Set oProcessor = CreateObject("easyPDF.PDFProcessor.8")
oProcessor.Encrypt "C:\test\input.pdf", _
                   "C:\test\encrypted.pdf", _
                   "my_user_password", _
                   "my_owner_password", _
                   PRC_SEC_ENCRYPT_128BITS, _
                   PRC_SEC_ANNOT_PERM_NONE, _
                   PRC_SEC_EXTR_PERM_NONE, _
                   PRC_SEC_MODIFY_PERM_NONE, _
                   PRC_SEC_PRINT_PERM_NONE