You can password protect and restrict a PDF inside the payload of InterFormNG2, that is later saved. The PDF should normally first be created with the component: Create PDF document. When you open a protected PDF file, you will be prompted for a password.
To do this, you need to use the advanced utilities workflow component: PDF Protect/restrict. From version 4.2.0 AES-128 encryption is used (previously it was 40-bit RC4).
Prerequisites:
- In order to password protect a PDF, you need a license code for InterFormNG2, that includes the Advanced PDF module.
- After adding the passwords you need to output the PDF file e.g. with the To filesystem workflow component.
The PDF Protect/restrict component has these parameters:
- User password
The user password for the PDF file. If you use this password, the PDF actions might be restricted as specified below. - Owner password
The owner password ignores any restrictions setup for the PDF file. - Restrict copy
When this option you can prevent the user from copying text from the PDF file. - Restrict edit
With this you can prevent the user from editing the PDF file. - Restrict print
Prevents the user from printing the PDF file. - Encryption algorithm
The algorithm used to encrypt the PDF file. Choose AES-256 for the strongest encryption, or AES-128 if the PDF needs to be opened in older PDF viewers that do not support AES-256. This parameter is available from version 4.4.0.
All of the restrictions can be set to a fixed value enabled or disabled on by clicking this icon on the left:

- but you can also set a dynamic value, if you click this icon on the right:

Then you can set a dynamic Xpath expression to set a dynamic value of either yes or no.
If you want to set the user or owner password to a dynamic value via an XPath expression, then you need to update the matching
predefined variable before this component and leave the fields empty. The matching variables are:
pdfProtection.ownerPassword
pdfProtection.userPassword