LibreOffice is a free and open-source office suite, which includes programs for word processing, spreadsheets, presentations, graphics, and databases. The command line interface (CLI) for LibreOffice allows users to perform various tasks, such as converting documents to different formats, automating tasks, and scripting.
The basic syntax for using the LibreOffice CLI is “libreoffice [options] [file]”, where options specify the desired action and file is the path to the document you want to work with. For example, the command “libreoffice –headless –convert-to pdf file.docx” will convert a Word document to a PDF in headless mode (meaning without opening the LibreOffice GUI).
Some common options for the LibreOffice CLI include:
- –headless: runs LibreOffice in the background without opening the GUI
- –convert-to: converts a document to a specified format
- –print-to-file: prints a document to a file
- –invisible: runs LibreOffice without showing the GUI
- –nologo: suppresses the display of the logo when starting LibreOffice.
It’s worth noting that in addition to these basic options, LibreOffice also provides advanced options like –writer, –calc, –impress, and –draw that allow you to launch the specific module of LibreOffice, and also advanced command line options like –accept= and –infilter= that allow you to set up the connection to a remote server and the filter options respectively.
libreoffice Command Examples
1. Open a space-separated list of files in read-only mode:
# libreoffice --view path/to/file1 path/to/file2
2. Display the content of specific files:
# libreoffice --cat path/to/file1 path/to/file2
3. Print files to a specific printer:
# libreoffice --pt printer_name path/to/file1 path/to/file2
4. Convert all `.doc` files in current directory to PDF:
# libreoffice --convert-to pdf *.doc