This is AWESOME! I just switched back to using a Mac and had scanned a ton of PDF's with my Scansnap. Unfortunately Fujitsu seems to have removed the possibility to encrypt at scan time in their latest Mac version. It still works fine on my PC which is what I've been using since my original post. So I was trying to figure out how I encrypted after the fact in the past. I also found my old post but without the screenshots it's pretty useless and I can't remember that far back. So thanks @DTLow for reminding me how I did it 😄
@JMichaelTX I completely agree and that's what I've been doing for years. My workaround was more for the case where I had bulk scanned pretty much my entire life into Evernote and then afterwards went: "I do kind of trust Evernote but that PDF probably should be encrypted with a password only I know".
The step in Automator uses AES128 encryption. If you wanted AES256 here are a few options that actually make this whole thing much easier:
Use QPDF (free)
Install Homebrew and QPDF
Add the Run AppleScript step (This is all that is required)
on run {input, parameters}
set pw to "some super secure password"
repeat with this_file in input
do shell script "/opt/homebrew/opt/qpdf/bin/qpdf --encrypt '" & pw & "' '" & pw & "' 256 -- --replace-input " & quoted form of POSIX path of this_file
end repeat
return input
end run
or if you want it to prompt you each time you could do:
on run {input, parameters}
set mypassword to display dialog "Please enter password for encryption." default answer "" with icon stop buttons {"Cancel", "Continue"} default button "Continue" with hidden answer
--> {button returned:"Continue", text returned:"mypassword"}
set pw to text returned of mypassword
repeat with this_file in input
do shell script "/opt/homebrew/opt/qpdf/bin/qpdf --encrypt '" & pw & "' '" & pw & "' 256 -- --replace-input " & quoted form of POSIX path of this_file
end repeat
return input
end run
Use PDFPenPro ($$) to encrypt (from Redacted and Encrypted PDF's with Hazel and PDFpenPro (macdrifter.com))
Replace the Encrypt PDF Documents step with this AppleScript:
on run {input, parameters}
set pw to "some super secure password"
repeat with this_file in input
tell application "PDFpenPro"
open this_file
save document 1 encrypt using AES256 password pw
quit
end tell
end repeat
return input
end run
You can adapt this as well to prompt for a password like in the QPDF example.
Either example will expect an unencrypted PDF as input. If you try and run this on an already encrypted PDF it will simply fail with an invalid password error (unless the password is the same one you are currently using).
This post comes with no warranties whatsoever - the usual common sense applies for the use of passwords. If you decide to save your password in an automator action you are accepting that it will not be safe. Follow @PinkElephants advice and use a password manager and just use the prompt version of the above script to stay on the safe side.