Last active
November 24, 2020 12:52
-
-
Save DATADEER/9963fdc948dc6e4145a5e24bc0fe0690 to your computer and use it in GitHub Desktop.
Locks a pdf with a custom (owner) password via pdftk. ONLY LOCKS EDITING.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Locks a pdf with a custom password via pdftk. | |
# ONLY LOCKS EDITING. CAN STILL BE OPENEND WITHOUT PASSWORD | |
# HOW TO: | |
# pdftk has to be globally accessible. https://www.pdflabs.com/ | |
# run sh lock.sh [filename_without_filetype] [password] | |
filename=$1 | |
password=$2 | |
echo locking "$filename".pdf && | |
pdftk ./"$filename".pdf output ./"$filename"_locked.pdf owner_pw $password && | |
echo deleting ./"$filename".pdf && | |
rm ./"$filename".pdf && | |
echo renaming ./"$filename"_locked.pdf && | |
mv ./"$filename"_locked.pdf ./"$filename".pdf && | |
echo succesfully locked "$filename".pdf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment