soffice: LibreOffice CLI tool
You have probably used the LibreOffice suite (Writer, Calc, Impress, Draw,…) but, do you know LibreOffice includes a command-line tool called ‘soffice’ (or ‘libreoffice’) with which you can perform useful tasks with LibreOffice-compatible documents in a quick and easy way?
Table of Contents
- soffice/libreoffice
- Open a file using the GUI
- Starts with a new document
- Output the content of a text file
- Convert a document file to PDF
- Convert a spreadsheet file to CSV
- Print a file
- Open an Impress file in Presentation mode
soffice/libreoffice
You may find on your system an executable called soffice
and other called libreoffice
. libreoffice
is just an alias for soffice
.
$ ls -l `which libreoffice`
lrwxrwxrwx 1 root root 36 oct 13 17:15 /usr/bin/libreoffice -> /usr/lib/libreoffice/program/soffice
Open a file using the GUI
soffice <file>
Starts with a new document
# Calc
soffice --calc
# Writer
soffice --writer
# Impress
soffice --impress
# Draw
soffice --draw
# Base
soffice --base
# Math
soffice --math
# HTML document
soffice --web
Output the content of a text file
soffice --cat <file>
Convert a document file to PDF
soffice --convert-to pdf <file>
--convert-to pdf:writer_pdf_Export
: convert using the settings on the PDF export dialog.--out-dir <path>
: define an output folder (by default, the current folder is used).
Convert a spreadsheet file to CSV
soffice --convert-to csv <file>
--out-dir <path>
: define an output folder (by default, the current folder is used).
Print a file
soffice --pt <printer name> <file>
# Use the default printer
soffice -p <file>
Open an Impress file in Presentation mode
soffice --show <file>
If you have any suggestion, feel free to contact me via social media or email.
Latest tutorials and articles:
Featured content: