7

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?

lord.garbage
  • 2,373

1 Answers1

3

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
<commands>
set -x history

OR

<whitespace><command>

OR use a script (adapted from here):

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

Source for disabling bash history

polym
  • 10,852
  • 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