Print LibreOffice Documents via Command Line to a Printer

This guide explains how to print LibreOffice documents silently to a specific printer using command-line arguments. By running LibreOffice in headless mode with targeted print parameters, you can automate batch printing jobs and integrate document printing into scripts without launching the graphical user interface.

The Core Command

To print a document silently to a specific printer, use the following syntax:

soffice --headless --pt "Printer_Name" "path/to/document.odt"

(Note: Depending on your operating system and installation, you can use either soffice or libreoffice as the executable command.)

Command-Line Arguments Explained

Finding the Exact Printer Name

To ensure the command executes correctly, you must provide the exact printer name recognized by your operating system.

Linux and macOS

List all available printer names using the CUPS command:

lpstat -p -d

Windows

List all available printers using PowerShell:

Get-Printer | Select-Object Name

Practical Examples

Linux / macOS Example

Print a Word document (report.docx) to an office network printer named Office_HP_LaserJet:

libreoffice --headless --pt "Office_HP_LaserJet" /home/user/documents/report.docx

Windows Example

Print a spreadsheet (budget.xlsx) to a local printer named Canon_TS8300:

"C:\Program Files\LibreOffice\program\soffice.exe" --headless --pt "Canon_TS8300" "C:\Users\Username\Documents\budget.xlsx"

Printing to the Default Printer

If you want to print silently to the system’s default printer rather than specifying one, use the -p or --print-to-default argument instead:

soffice --headless -p "path/to/document.odt"