PDF-Perm
Change the permissions of a PDF file.
Usage
The usage is quite similar to chmod command:
pdf-perm +c no-copy.pdf
This will overwrite no-copy.pdf and make it copiable. Bugs may arise, so make sure to have a backup if it matters.
By specifying another path, it will write to there instead of overwriting the original file:
pdf-perm +c no-copy.pdf can-copy.pdf
To remove a permission, use -:
pdf-perm -c can-copy.pdf no-copy.pdf
To set exactly the permissions you want, use =:
pdf-perm =pma my.pdf
This will set the permissions to PRINTABLE, MODIFIABLE, and ANNOTABLE and remove all other permissions. For a complete list of permissions, see the table below.
If multiple permission modifiers are used, they will be combined in the order they are specified.
Permissions
Here's a list of permissions this crate is capable of handling:
| # | Short Flag | Long Flag |
|---|---|---|
| 2 | p |
[P]RINTABLE |
| 3 | m |
[M]ODIFIABLE |
| 4 | c |
[C]OPYABLE |
| 5 | a |
[A]NNOTABLE |
| 8 | f |
[F]ILLABLE |
| 9 | x |
COPYABLE_FOR_ACCESSIBILITY |
| 10 | s |
A[S]SEMBLABLE |
| 11 | q |
PRINTABLE_IN_HIGH_[Q]UALITY |
See the PDF 1.4 ref, TABLE 3.15 for more details. Note that the index in the table is 1-based, while the index in the table above is 0-based.
Caveats
- This crate does NOT handle password protected PDFs. Consider decrypting them first, or using pdfrip to break the password.
- Currently, only PDF 1.4 is supported.
Credits
- abatsakidis/PDFDeSecure, for the example PDF file under
tests/directory.
TODO
- Implement
chmodlike syntax-
-,+,= -
-Rfor recursive -
--referencefor reference file
-
- Extended syntax
-
!for negation
-
- Handle filenames starting with
-,+,= - Set to
Noneif permissions are default - Preserve
EncryptionVersion - Allow specifying
EncryptionVersionif not present