I have a *.pdf file that is password protected. I have the password and I can view the pdf with mupdf. However, printing with CUPS via lpr -P PRINTERNAME *.pdf does not work. All my printing is done via the command line and cups lpr command and I don’t want to change that. Is there a way to have CUPS print password protected pdfs?

  • you can try and save the file to a temp file w/o the password. – Rabin Jul 17 '14 at 12:01
  • Yes, but I’m also interested in a direct solution. – lord.garbage Jul 17 '14 at 12:18

Why not remove the password temporary and print the resulting unsecure pdf with lpr:

pdftk secure.pdf input_pw own output - | lpr

If you don't want that this command is listed in bash command history:

set +x history
set -x history



OR use a script (adapted from here):

unset password
prompt="Enter Password:"
while IFS= read -p "$prompt" -r -s -n 1 char; do
    [[ $char == $'\0' ]] && break
pdftk secure.pdf input_pw "$password" output - | lpr

Source for disabling bash history

  • That is exactly what I did to be honest given that I needed the document printed urgently. But the purist in me wants to know if there is a way without taking the detour. But given that within a few days no other solution turns up I take it that none exists and accept your answer. – lord.garbage Jul 17 '14 at 13:56
  • 1
    Ah well, yeah I haven't found or know of any other solution. man lpr doesn't give us any option, too. Darn. – polym Jul 17 '14 at 13:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.