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.

Word processor

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

Spreadsheet

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