
PDF tooling for Go and the command line.
View the Project on GitHub pdfcpu/pdfcpu
The PDF specification defines a set of permissions that may be set for encrypted documents. Permissions go into effect anytime an encrypted document is opened with the user password. Providing the owner password which is also known as the set permissions password or master password will give full access to the document.
You can set either none, all or permissions for print.
You can also set your permission bits in binary or hex mode.
Have a look at some examples.
pdfcpu permissions set [--perm n(one)|p(rint)|a(ll)|max4Hex|max12Bits] [--upw userpw] --opw ownerpw inFile [ outFile ]
| name | description | required | default |
|---|---|---|---|
| perm | permission bits | no | none |
| upw | user password | if set | |
| opw | owner password | yes |
| name | description | required |
|---|---|---|
| inFile | PDF input file, use - to read from stdin | yes |
| outFile | PDF output file, use - to write to stdout | no |
You have to provide any non-empty password in order to change permissions:
$ pdfcpu encrypt enc.pdf --opw opw
writing enc.pdf ...
$ pdfcpu permissions list enc.pdf
permission bits: 000000000000 (x000)
Bit 3: false (print(rev2), print quality(rev>=3))
Bit 4: false (modify other than controlled by bits 6,9,11)
Bit 5: false (extract(rev2), extract other than controlled by bit 10(rev>=3))
Bit 6: false (add or modify annotations)
Bit 9: false (fill in form fields(rev>=3)
Bit 10: false (extract(rev>=3))
Bit 11: false (modify(rev>=3))
Bit 12: false (print high-level(rev>=3))
pdfcpu permissions set enc.pdf --perm all
pdfcpu: please provide the owner password with -opw
$ pdfcpu permissions set enc.pdf --opw opw --perm all
adding permissions to enc.pdf ...
writing enc.pdf ...
$ pdfcpu permissions list enc.pdf
permission bits: 111100111100 (xF3C)
Bit 3: true (print(rev2), print quality(rev>=3))
Bit 4: true (modify other than controlled by bits 6,9,11)
Bit 5: true (extract(rev2), extract other than controlled by bit 10(rev>=3))
Bit 6: true (add or modify annotations)
Bit 9: true (fill in form fields(rev>=3)
Bit 10: true (extract(rev>=3))
Bit 11: true (modify(rev>=3))
Bit 12: true (print high-level(rev>=3))
Set permissions for a streamed PDF and upload the result:
$ aws s3 cp s3://acme-legal/protected.pdf - \
| pdfcpu permissions set --opw "$OPW" --perm print - - \
| aws s3 cp - s3://acme-legal/printable.pdf