Printing from the command line with LibreOffice, lpr commands?
You can't pass lpr
command line options to libreoffice
. Two possible solutions are:
One step solution (the best solution in my opinion): use unoconv outputting a PDF to
stdout
piped tolpr
:$ unoconv --stdout filename.doc | lpr -U username -P the_printer_name
Three step solution (if you don't want / can't use
unoconv
): uselibreoffice --print-to-file
to a temporary file +lpr
of the file + delete the temporary file (unfortunatelly libreoffice still doesn't support printing to stdout):$ libreoffice --headless --print-to-file --printer-name the_printer_name --outdir /tmp filename.doc $ lpr -U username /tmp/filename.ps -P the_printer_name $ rm /tmp/filename.ps
Under the, $ libreoffice --help
Usage: soffice [options] [documents...]
soffice -p File_name.odt
Worked for me.
libreoffice -p File_Name.odt just opened the program, lpr just spat at garbage.
This is how I print a document using LibreOffice and a CUPS printer on Debian 9:
/usr/bin/libreoffice --pt [cupsname] /home/username/filename.odt
It works very well without any middle steps.