Automate unlocking a password-protected PDF

Well, here’s what I’d do: Remove the password.

There’s a guide here that gives several ways of doing it:

https://www.cyberciti.biz/faq/removing-password-from-pdf-on-linux/

Most of those tools are easily accessible on the Mac, such pdftk

https://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/pdftk_server-2.02-mac_osx-10.6-setup.pkg

qpdf can be installed via brew install qpdf

Same with xpdf

Set Hazel to remove the password, do what you need to do, and then delete the unprotected PDF (assuming that you’re not supposed to keep a bare copy around forever).