pdfcpu

Logo

PDF tooling for Go and the command line.

View the Project on GitHub pdfcpu/pdfcpu


Changelog
Future Directions
Contributing
Security

Change Owner Password

This command changes the password which is also known as the set permissions password or the master password. Have a look at some examples .

Usage

pdfcpu changeopw inFile opwOld opwNew [ outFile ] [flags]
pdfcpu changeopw inFile --opwold-file oldFile --opwnew-file newFile [ outFile ] [flags]

Common Flags


Arguments

namedescriptionrequired
inFilePDF input file, use - to read from stdinyes
opwOldcurrent owner passwordyes
opwNewnew owner passwordyes, must not be empty!
outFilePDF output file, use - to write to stdoutno

Both current passwords are authenticated before the change. Supply the current user password with --upw or --upw-file; omitting it tries an empty password. The old positional password (or its file alternative) is the current owner password being changed.

Password files

Use both --opwold-file and --opwnew-file together, omitting the positional old and new passwords. Use --upw-file to supply the other password from a file. Literal password strings remain supported. See Password files for newline handling, empty passwords and conflicts.

pdfcpu changeopw input.pdf --upw-file /run/secrets/upw \
  --opwold-file /run/secrets/old-password --opwnew-file /run/secrets/new-password output.pdf

The argument table above describes the literal-password form. The new owner-password file must contain a non-empty password. One trailing line ending (LF or CRLF) is allowed and ignored.

Examples

You have to set the owner password when you encrypt a file and you can change it anytime later with changeopw.

Change the owner password:

$ pdfcpu encrypt enc.pdf --opw opw
writing enc.pdf ...

$ pdfcpu changeopw enc.pdf opw opwNew
writing enc.pdf ...

Change the owner password for a streamed PDF and upload the result:

$ aws s3 cp s3://acme-legal/client.pdf - \
   | pdfcpu changeopw - --upw "$UPW" "$OLD_OPW" "$NEW_OPW" - \
   | aws s3 cp - s3://acme-legal/client-rotated-opw.pdf