This script allows to protect the PDF, that is to say prevent people from copying its content, print it or modify it.

SetProtection([array permissions [, string user_pass [, string owner_pass]]])

permissions: the set of permissions. Empty by default (only viewing is allowed).
user_pass: user password. Empty by default.
owner_pass: owner password. If not specified, a random value is used.

The permission array is composed of values taken from the following ones:

    * copy: copy text and images to the clipboard
    * print: print the document
    * modify: modify it (except for annotations and forms)
    * annot-forms: add annotations and forms 

Remark: the protection against modification is for people who have the full Acrobat product.

If you don't set any password, the document will open as usual.
If you set a user password, the PDF viewer will ask for it before displaying the document.
The master password, if different from the user one, can be used to get full access.

Note: protecting a document requires to encrypt it, which increases the processing time a lot.
This can cause a PHP time-out in some cases, especially if the document contains images or fonts.