
PDF tooling for Go and the command line.
View the Project on GitHub pdfcpu/pdfcpu
This command changes the password which is also known as the set permissions password or the master password. Have a look at some examples .
pdfcpu changeopw inFile opwOld opwNew [ outFile ] [flags]
pdfcpu changeopw inFile --opwold-file oldFile --opwnew-file newFile [ outFile ] [flags]
| name | description | required |
|---|---|---|
| inFile | PDF input file, use - to read from stdin | yes |
| opwOld | current owner password | yes |
| opwNew | new owner password | yes, must not be empty! |
| outFile | PDF output file, use - to write to stdout | no |
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.
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.
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