Decrypt
This command decrypts inFile
and removes password protection. If provided the decrypted PDF will be written to outFile
and ìnFile
remains untouched. Have a look at some examples.
Usage
usage: pdfcpu decrypt [-v(erbose)|vv] [-upw userpw] [-opw ownerpw] inFile [outFile]
Flags
name | description | required |
---|---|---|
verbose | turn on logging | no |
vv | verbose logging | no |
upw | user password | no |
opw | owner password | no |
Arguments
name | description | required |
---|---|---|
inFile | encrypted PDF input file | yes |
outFile | PDF output file | no |
Matrix
The following matrix is a result of the intrinsics of how PDF encryption works:
encrypted using | needed for decryption | use case |
---|---|---|
opw | - | reset permissions |
upw | upw | remove open doc password & reset permissions |
opw and upw | opw or upw | remove open doc password & reset permissions |
Examples
Decrypt a file that has only the owner password set. This will also reset all permissions, providing full access. You don’t need to provide any password:
pdfcpu encrypt -opw opw test.pdf
writing test.pdf ...
pdfcpu decrypt test.pdf
writing test.pdf ...
Decrypt a file that has only the user password set. This will remove the open doc password and also reset all permissions, providing full access. You need to provide the user password:
pdfcpu encrypt -upw upw test.pdf
writing test.pdf ...
pdfcpu decrypt test.pdf
Please provide the correct password
pdfcpu decrypt -upw upw test.pdf
writing test.pdf ...
Decrypt a file that is protected by both the user password and the owner password. This also removes the open doc password and resets all permissions providing full access. You will need to provide either of the two passwords:
pdfcpu encrypt -opw opw -upw upw test.pdf
writing test.pdf ...
pdfcpu decrypt test.pdf
Please provide the correct password
pdfcpu decrypt -upw upw test.pdf
writing test.pdf ...
pdfcpu encrypt -opw opw -upw upw test.pdf
writing test.pdf ...
pdfcpu decrypt test.pdf
Please provide the correct password
pdfcpu decrypt -opw opw test.pdf
writing test.pdf ...