How to set security options for a PDF using pdflatex

This answer, taken partially verbatim from Digital signature on TeX.SX:

Using the PDF Toolkit you can specify a separate owner and user password. Owner passwords are required when changing document properties, while user passwords may be required for performing certain actions, like printing. However, only specifying an owner password and allowing printing by default, would allow users of the document to view/read/print without authentication. You would need the following command line execution:

pdftk input.pdf output output.pdf owner_pw foo allow printing

The above commands takes as input input.pdf, sets the owner password to foo and would allow printing by any user. Modification of document settings require the owner password. See the documentation/man page and examples for more information.


As pdftk is no longer easily available for certain Linux distributions (or no longer easy to keep track of what is going on), another option is qpdf. Password protection is possible. The basic syntax is:

qpdf infile.pdf --encrypt <userpwd> <ownerpwd> <key length> [ restrictions ] outfile.pdf

Where,

  • one or both of <userpassword> and <ownerpassword> may be empty strings
  • key length may be 40, 128, or 256 and the higher the value the more restrictions one can impose on the use of the pdf.

For example,

  qpdf infile.pdf --encrypt usr own 128 --print=none -- outfile.pdf

should prevent unauthorized printing.

Tags:

Pdf

Pdftex

Drm