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?
Asked
Active
Viewed 3,098 times
7

lord.garbage
- 2,373
-
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
1 Answers
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
-
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
-
1Ah 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