A PDF document can be encrypted to protect its contents from unauthorized access. PD4ML supports PDF access permissions concept and allows a password to be specified for a document.

If any passwords or access restrictions are specified with PD4ML.setPermissions(), the document is encrypted, and the permissions and information required to validate the passwords are stored to the resulting document.

If a user attempts to open an encrypted document that has a password, the viewer application should prompt for a password. Correctly supplying either password allows the user to open the document, decrypt it, and display it on the screen.

If the document is encrypted with a password set to “empty”, no password is requested; the viewer application can simply open, decrypt, and display the document. Whether additional operations are allowed on a decrypted document depends on any access restrictions that were specified when the document was created.

The possible restrictions:

Modifying the document�s contents
Copying or otherwise extracting text and graphics from the document
Adding or modifying text annotations
Printing the document

See PD4ML API reference (PD4Constants.Allow*) for others.
The PDF document produced by PD4ML can be protected with 40-bit or 128-bit encryption.

...
String password = "empty";
boolean strongEncryption = true;
int permissions = PD4Constants.AllowPrint | PD4Constants.AllowCopy;
 
pd4ml.setPermissions( password, permissions, strongEncryption );
...