Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to print a word document from the command line, but I need to specify printing options that I would normally use lpr for. This is the command I'm using

libreoffice -p "filename.doc"

I need to be able to specify a username (-U), is this possible? The following doesn't work

libreoffice -p "filename.doc" -U username

Should this work, or is there another way?

share|improve this question
up vote 1 down vote accepted

You can't pass lpr command line options to libreoffice. Two possible solutions are:

  1. One step solution (the best solution in my opinion): use unoconv outputting a PDF to stdout piped to lpr:

    $ unoconv --stdout filename.doc | lpr -U username -P the_printer_name
    
  2. Three step solution (if you don't want / can't use unoconv): use libreoffice --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
    
share|improve this answer
    
The first command of 2nd solution does not produce any file im /tmp. Does it work with doc only, not with odt? – Sigur Jul 1 at 14:24
    
It should work with any support file type. – Pedro Romano Jul 3 at 19:37

You must log in to answer this question.

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