3

I'm trying to add restriction to a pdf file, but don't need a user password. I fail to get this right for some reason.

qpdf.exe --encrypt 40 -modify=y -extract=y -annotate=y -- in.pdf out.pdf

The help states that:

Either or both of the user password and the owner password may be empty strings.

How should I specify the empty password strings?

Hamid Rouhani
  • 2,309
  • 2
  • 31
  • 45
xcskilab
  • 189
  • 1
  • 9

1 Answers1

3

You should use quotation marks to specify empty strings as password:

qpdf.exe --encrypt "" "" 40 -modify=y -extract=y -annotate=y -- in.pdf out.pdf
Hamid Rouhani
  • 2,309
  • 2
  • 31
  • 45
  • That is the obvious answer but running that command line fails in my case . I get the error description _qpdf: encryption key length must be 40, 128, or 256_ I guess that 40 has to be the third argument in the encryption and it is not. – xcskilab May 03 '17 at 14:00
  • 2
    I was using powershell, so had to use a command like this: qpdf --encrypt '""' '""' 256 --modify=none -- .\myfile.pdf outfile.pdf (note they are double quotes inside single quotes) – Rob Bird Feb 26 '19 at 14:01