Is there a package and command that can secure rendered pdf with a password?

  • 1
    You mean to encrypt it with a password? See Is it possible to produce a PDF with un-copyable text? and Protect text in PDF from being copied. I thought there is an exact duplicate for this but I can't find it. Anyway, PDF encryption support got dropped from pdftex a while ago and I don't think xetex has it as well. You need to use an external tool on the compiled PDF afterwards to add this. Commented Jul 27, 2011 at 9:37
  • 1
    This is not really a TeX question, maybe superuser would be a better place for it.
    – raphink
    Commented Jul 27, 2011 at 9:38
  • Un-copyable text sounds like a good idea also but not necessary. Basically, when you open the PDF file, it should present you with a password dialog. If you pass, you can open the PDF, otherwise you can't read it. Commented Jul 27, 2011 at 9:42
  • 1
    @Level1Coder: See my updated comment above. I don't think any TeX supports this. You need to use external tools like pdftk or Adobe Acrobat (full version, not just the Reader). Commented Jul 27, 2011 at 9:44

2 Answers 2


There used to be a package achieving PDF encryption, but it relied on obsolete pdfTeX patches: pdfcrypt

Nowadays, you need an external tool to encrypt your PDF. Here is an example to encrypt a PDF with pdftk:

pdftk inputfile.pdf output outputfile.pdf encrypt_128bit owner_pw yourownerpw user_pw youruserpw

That said, I guess a LaTeX package could be done to make use of pdftk at compile time.

Just please remember that no PDF encryption is really bullet-proof. Once the user can see the PDF, then he can print it and edit it. It can just require the use of other tools than the Adobe thingies.

  • 4
    Note that it is really recommended to use 128bit encryption (as shown here). The "normal" 40bit encryption is do to US export restrictions and is not very safe (3 days of computation power of a normal PC, I heard a ca. 8 years ago, should be done to .5 day by now). Commented Jul 27, 2011 at 9:46
  • 5
    Yes, although in some countries it is illegal to use high-level encryption altogether. Here in France, I believe you have to give a copy of the private key to the police when you do so (although when you go to the police with your fingerprint, they think you're totally crazy to tell the truth ;-))
    – raphink
    Commented Jul 27, 2011 at 9:50
  • It looks like you need the commercial version for $3,99 to add a password?
    – doncherry
    Commented Jan 16, 2014 at 10:11
  • @doncherry: Just tested it with Debian's pdftk package. It works great. I'm guessing you need the Pro version if you want to use the GUI for that maybe.
    – raphink
    Commented Jan 16, 2014 at 20:26

In the case of pdfTeX, an external tool, such as pdftk or qpdf, is necessary to encrypt. In the case of XeTeX, we can use a \special supported by xdvipdfmx, for example:

\special{pdf:encrypt ownerpw (abc) userpw (xyz) length 128 perm 2052}
This is a test.
  • This is awesome, solved my problem in the easiest way. (was using ShareLatex.com which has a XeLaTeX engine)
    – Paul H
    Commented Jan 5, 2016 at 19:48
  • Can you explain the used options, in particular the perm setting?
    – bonanza
    Commented Apr 27, 2016 at 17:58
  • 1
    @bonanza: You may find useful data in texmf-dist/dvipdfmx/dvipdfmx.cfg. Commented Apr 27, 2016 at 23:44
  • Is there an equivalent for lualatex?
    – bonanza
    Commented May 8, 2019 at 9:29
  • @bonanza: I don't know. Probably there is not. Commented May 8, 2019 at 23:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .