PDF Encryption and PDF Password Protection for FormDocs and Electronic Forms
In order to enable PDF Encryption using FormDocs and WinSpool/400 Electronic Forms, the form must be modified to enable PDF passwords. This is done through the VB Scripting in each form.
NOTE: This article does not include information on Password Protecting Template Designs or Password Protection during the Conversion Process. Those topics are found in the following articles:
- Password Protection for FormDocs Form Templates
- Password Protection During Print Server Report Conversion
You will need to decide on two passwords for each form:
- Owner Password: Think of this as an Administrative Password that can be used within your staff so that you do not need to remember multiple passwords. Another way to think of this password is as a God Password. This password must be set to enable PDF encryption.
- User Password: This password should be a little more obvious. If you are sending this document to a user or a customer with his/her/their own unique password, this is where that will need to be entered. The User Password is not needed to enable PDF encryption. If you are wanting an Encrypted PDF without a password, simply set the User Password to an empty string.
Scripting the Passwords
Scripting the passwords is very simple and will require little to no experience with Visual Basic. Use these simple steps to add encryption and, if desired, passwords to your PDFs:
Step 1: Open Template
Open your FormDocs Form Template.
Step 2: Open VB Editor
Select Tools > Forms Automation Basic Editor from the menu bar. This will open up a new window:
Step 3: Automate Form
In this new window, locate the drop-down menu labeled "Automate this Object:" in the upper- left region and select "Form" from the drop-down menu (2nd option).
Step 4: Choose Event
Now locate the drop-down menu labeled "Program this event:" in the upper- right region and select Open from the drop-down menu.
Step 5: Insert Code
In the main window (no label), you will need to insert the following command before the line that reads "End Sub". This will be your Owner password and must contain a value in order to enable either PDF encryption or password protection.
ThisForm.PDFOptions.ownerpassword = "<insert password>"
NOTE: Do not worry about text color as script editor will automatically format the text.
Step 6: Change Event
Now locate the drop-down menu labeled "Program this event:" once again in the upper- right region and select BeforePrint from the drop-down menu.
Step 7: Insert Code
In the main window (no label), you will need to insert the following command before the line that reads "End Sub". This will be your User password.
- If you want to enable PDF Encryption without a password, then you need to insert the following command:
ThisForm.PDFOptions.UserPassword = "" 'The blank password will enable PDF encryption, but disable the password prompting when viewing the PDF
- If you want to enable PDF Encryption AND PDF password protection, then you need to insert the following command:
ThisForm.PDFOptions.UserPassword = "<insert password>" 'This enables BOTH PDF Encryption and PDF password protection for this form.
Step 8: Check Syntax
Select File > Check Syntax from the menu bar and verify that you receive a message that the script was "Parsed Successfully"
NOTE: If you get an error message, please check your code for mistakes or contact Technical Support.
Step 9: Save & Close
Close the FormDocs Forms Automation Basic Editor window and save your form.