pdfcpu

Logo

A PDF processor written in Go.

View the Project on GitHub pdfcpu/pdfcpu


Changelog

Set Permissions

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.

Usage

pdfcpu permissions set [-perm n(one)|p(rint)|a(ll)|max4Hex|max12Bits] [-upw userpw] -opw ownerpw inFile


Flags

name description required default
perm permission bits no none
upw user password if set  
opw owner password yes  


Common Flags

name description required
verbose turn on logging no
vv verbose logging no
quiet quiet mode no
upw user password if set
opw owner password if set


Arguments

name description required
inFile PDF input file yes


Examples

You have to provide any non empty password in order to change permissions.

For a document encrypted with just the owner password you have to provide opw to change the permissions:

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

$ pdfcpu perm 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 perm set -perm all enc.pdf
Please provide all non-empty passwords

$ pdfcpu perm set -opw opw -perm all enc.pdf
adding permissions to enc.pdf ...
writing enc.pdf ...

$ pdfcpu perm 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))


For a document encrypted with just the user password you have to provide upw to change the permissions:

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

$ pdfcpu perm list -upw upw enc.pdf
permission bits:            0
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 perm set -perm print enc.pdf
Please provide all non-empty passwords#

$ pdfcpu perm set -upw upw -perm print enc.pdf
adding permissions to enc.pdf ...
writing enc.pdf ...

$ pdfcpu perm list enc.pdf
Please provide the correct password

$ pdfcpu perm list -upw upw enc.pdf
permission bits: 100000000100 (x804)
Bit  3: true (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: true (print high-level(rev>=3))


For an encrypted document that has both passwords set you have to provide both opw and upw to change the permissions:

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

$ pdfcpu perm list -opw opw enc.pdf
permission bits:            0
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 perm set -perm 111100001111 enc.pdf
Please provide all non-empty passwords

$ pdfcpu perm set -opw opw -perm 111100001111 enc.pdf
Please provide the correct password

$ pdfcpu perm set -upw upw -perm 111100001111 enc.pdf
Please provide all non-empty passwords

$ pdfcpu perm set -upw upw -opw opw -perm 111100001111 enc.pdf
adding permissions to enc.pdf ...
writing enc.pdf ...

$ pdfcpu perm list -upw upw enc.pdf
permission bits: 111100001100 (xF0C)
Bit  3: true (print(rev2), print quality(rev>=3))
Bit  4: true (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: 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))