Headless Printing of Office Files

These are quick notes on how to print common office formats using the command line facilities of lightweight office applications like abiword and gnumeric.

It is not a mystery that I enjoy working on the command line way more than waiting for an heavy GUI to load, so when faced with the task to print an excel file I looked for an headless solution. I know that OpenOffice.org has an headless mode, but I don't have it installed, and waiting for it to download is not fun either, so I looked for another solution.

Luckily, gnumeric offers a command line conversion tool, ssconvert, that does exactly what I needed.

This article is kept for historical reasons, but is no longer updated: see https://docs.trueelena.org/desktop/command_line_printing/index.html#converting-spreadsheet-files-to-pdf for up-to-date instructions.

Word processor

I haven't tried yet, but the AbiCommand plugin to abiword looks quite interesting.


If your print filters allows it, printing an excel file is as simple as this:

ssconvert -O paper=A4 $FILE.xsl $FILE.pdf && lpr $FILE.pdf

of course it works also with ods files:

ssconvert -O paper=A4 $FILE.ods $FILE.pdf && lpr $FILE.pdf

otherwise, you may need to convert it to postscript:

ssconvert -O paper=A4 $FILE.$EXT $FILE.pdf && pdftops $FILE.pdf - | lpr
Send a comment: unless requested otherwise I may add it, or some extract, to this page.

Return to Top