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?
How to print password protected pdf with cups from command line
cupspdfprinting
Related Solutions
Having Referred to the following post: https://ubuntuforums.org/showthread.php?t=1975881
After many research, in the end I found my problem was the permission of the folder /var/tmp/
, it was 755 (drwxr-xr-x, root, root).
After changing it to 777 (drwxrwxrwx), cups-pdf works again ..
Because in the /etc/cups/cups-pdf.conf
, it is indicating either /var/tmp
or /tmp
must be user-writable!
I'm answering a part of your questions only, because you seem to employ a sharp mind who only needs to be shown some hidden hooks to climb up the wall:
"Which PPD will it use?"
If a printqueue
printername
is locally installed (and if it is not a 'raw' queue), it will use the PPD/etc/cups/ppd/printername.ppd
."Does it detect the format? How?"
Yes, it does. When you have debug logging enabled (line
LogLevel debug
in /etc/cups/cupsd.conf), you will see a line in the error_log reading "Auto-typing file...". (There will be no auto-typing, if the job already states a mime type, like inlp -d printername -o document-format=application/pdf my.pdf
.)The rules for classifying various MIME types are defined in /usr/share/cups/mime.types and in all other files which may be in the same directory with the suffix *.types. (You could put your own rules there too, to define your own custom MIME types which should be processed by your own custom filters...)
"What other decisions is the pipeline taking and what conversions?"
If the PPD doesn't have any line starting with one of the
*cupsFilter:
orcupsFilter2:
keywords, then it assumes the final print device to be a PostScript printer. Hence it converts everything to PostScript, which does not get submitted as PostScript.If there is one or more lines starting with the keyword
*cupsFilter:
or*cupsFilter2:
it will read from these lines which MIME type the print device can consume and it will employ an appropriate filter chain to generate the respective MIME type.The filters which can process certain MIME types are listed in /usr/share/cups/mime.convs and in all other files which may be in the same directory with the suffix *.convs. (You could put your own custom filters there for any MIME type you want to be processed by these filters...)
The *.convs files name the input as well as the output MIME types the respective filter can consume and produce, and what virtual "cost" (just an integer number) such a conversion will cause. When faced with different possible filtering chains which CUPS could construct to go from
application/alpha
toapplication/zeta
it picks the one with the lowest total cost.
"Will it reconvert to PDF again?"
Most likely no. Unless you asked for a print option to be used for the original PDF that requires it: to print only a range of pages; to print 2 or more pages on one sheet of paper; to scale it; to reshuffle pages for booklet printing, etc. Then a
pdftopdf
filter may be applied, that convertsapplication/pdf
toapplication/vnd.cups-pdf
."What did CUPS detect?"
See above: search for the string "Auto-typing file" in
/var/log/error_log
:sudo grep -A 2 "Auto-typing file" /var/log/error_log
"What conversions did it do?"
See in
error_log
again and search for lines containingStarted filter
:sudo grep "Started filter" /var/log/error_log
"Where can I fetch the intermediate outputs generated?"
You cannot do this directly. You'd have to manipulate each and every filter of CUPS to write out the intermediary format. (I can do it, I have a ready-made recipe for this, but you'd have to pay me to apply it.)
So fetching intermediate outputs might be out-of-scope for you, you can do something different: simulate the filtering chain CUPS would employ for any job.
You can discover how to do this by reading the man page of
cupsfilter
. You can also just list the filters CUPS would employ for any of the print queues:cupsfilter \ --list-filters \ -d <printername> \ -i <inputmime/type> \ -m <outputmime/type> \ -o "number-up=4 page-ranges=3-5,7,11" \ <filename>
Best Answer
Why not remove the password temporary and print the resulting unsecure pdf with
lpr
:If you don't want that this command is listed in bash command history:
OR
OR use a script (adapted from here):
Source for disabling bash history