Add 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.

pdfcpu provides minimal support for setting permissions. You can set either all or none permissions. Have a look at some examples.

Usage

  1. pdfcpu permissions add [-v(erbose)|vv] [-perm none|all] [-upw userpw] -opw ownerpw inFile

Flags

namedescriptionrequiredvaluesdefault
verboseturn on loggingno
vvverbose loggingno
permpermissionsnonone, allnone
upwuser passwordif set
opwowner passwordif set

Arguments

namedescriptionrequired
inFilePDF input fileyes

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:

  1. pdfcpu encrypt -opw opw enc.pdf
  2. writing enc.pdf ...
  3. pdfcpu perm list enc.pdf
  4. permission bits: 0
  5. Bit 3: false (print(rev2), print quality(rev>=3))
  6. Bit 4: false (modify other than controlled by bits 6,9,11)
  7. Bit 5: false (extract(rev2), extract other than controlled by bit 10(rev>=3))
  8. Bit 6: false (add or modify annotations)
  9. Bit 9: false (fill in form fields(rev>=3)
  10. Bit 10: false (extract(rev>=3))
  11. Bit 11: false (modify(rev>=3))
  12. Bit 12: false (print high-level(rev>=3))
  13. pdfcpu perm add -perm all enc.pdf
  14. Please provide all non-empty passwords
  15. pdfcpu perm add -opw opw -perm all enc.pdf
  16. adding permissions to enc.pdf ...
  17. writing enc.pdf ...
  18. pdfcpu perm list enc.pdf
  19. permission bits: 111100111100
  20. Bit 3: true (print(rev2), print quality(rev>=3))
  21. Bit 4: true (modify other than controlled by bits 6,9,11)
  22. Bit 5: true (extract(rev2), extract other than controlled by bit 10(rev>=3))
  23. Bit 6: true (add or modify annotations)
  24. Bit 9: true (fill in form fields(rev>=3)
  25. Bit 10: true (extract(rev>=3))
  26. Bit 11: true (modify(rev>=3))
  27. 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:

  1. pdfcpu encrypt -upw upw enc.pdf
  2. writing enc.pdf ...
  3. pdfcpu perm list -upw upw enc.pdf
  4. permission bits: 0
  5. Bit 3: false (print(rev2), print quality(rev>=3))
  6. Bit 4: false (modify other than controlled by bits 6,9,11)
  7. Bit 5: false (extract(rev2), extract other than controlled by bit 10(rev>=3))
  8. Bit 6: false (add or modify annotations)
  9. Bit 9: false (fill in form fields(rev>=3)
  10. Bit 10: false (extract(rev>=3))
  11. Bit 11: false (modify(rev>=3))
  12. Bit 12: false (print high-level(rev>=3))
  13. pdfcpu perm add -perm all enc.pdf
  14. Please provide all non-empty passwords#
  15. pdfcpu perm add -upw upw -perm all enc.pdf
  16. adding permissions to enc.pdf ...
  17. writing enc.pdf ...
  18. pdfcpu perm list enc.pdf
  19. Please provide the correct password
  20. pdfcpu perm list -upw upw enc.pdf
  21. permission bits: 111100111100
  22. Bit 3: true (print(rev2), print quality(rev>=3))
  23. Bit 4: true (modify other than controlled by bits 6,9,11)
  24. Bit 5: true (extract(rev2), extract other than controlled by bit 10(rev>=3))
  25. Bit 6: true (add or modify annotations)
  26. Bit 9: true (fill in form fields(rev>=3)
  27. Bit 10: true (extract(rev>=3))
  28. Bit 11: true (modify(rev>=3))
  29. 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:

  1. pdfcpu encrypt -opw opw -upw upw enc.pdf
  2. writing enc.pdf ...
  3. pdfcpu perm list -opw opw enc.pdf
  4. permission bits: 0
  5. Bit 3: false (print(rev2), print quality(rev>=3))
  6. Bit 4: false (modify other than controlled by bits 6,9,11)
  7. Bit 5: false (extract(rev2), extract other than controlled by bit 10(rev>=3))
  8. Bit 6: false (add or modify annotations)
  9. Bit 9: false (fill in form fields(rev>=3)
  10. Bit 10: false (extract(rev>=3))
  11. Bit 11: false (modify(rev>=3))
  12. Bit 12: false (print high-level(rev>=3))
  13. pdfcpu perm add -perm all enc.pdf
  14. Please provide all non-empty passwords
  15. pdfcpu perm add -opw opw -perm all enc.pdf
  16. Please provide the correct password
  17. pdfcpu perm add -upw upw -perm all enc.pdf
  18. Please provide all non-empty passwords
  19. pdfcpu perm add -upw upw -opw opw -perm all enc.pdf
  20. adding permissions to enc.pdf ...
  21. writing enc.pdf ...
  22. pdfcpu perm list -upw upw enc.pdf
  23. permission bits: 111100111100
  24. Bit 3: true (print(rev2), print quality(rev>=3))
  25. Bit 4: true (modify other than controlled by bits 6,9,11)
  26. Bit 5: true (extract(rev2), extract other than controlled by bit 10(rev>=3))
  27. Bit 6: true (add or modify annotations)
  28. Bit 9: true (fill in form fields(rev>=3)
  29. Bit 10: true (extract(rev>=3))
  30. Bit 11: true (modify(rev>=3))
  31. Bit 12: true (print high-level(rev>=3))