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?

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

1 Answer 1

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

2
  • 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. Commented Jul 17, 2014 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
    Commented Jul 17, 2014 at 13:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .