Convert Office Documents to PDF with soffice --headless

Batch-convert DOCX, ODT, XLSX, or PPTX files to PDF from the command line using LibreOffice in headless mode.

LinuxconversionheadlesslibreofficepdfLow risk
Run soffice --headless --convert-to pdf --outdir ~/Desktop report.docx to produce report.pdf on your Desktop.

01Command

Command
$ soffice --headless --convert-to pdf --outdir ~/Desktop report.docx

02What it does

soffice --headless runs LibreOffice without a window, and --convert-to pdf writes a converted copy to --outdir while leaving the original untouched; the filter name (pdf, xlsx, docx, csv...) decides the output format. You can pass several files at once, and a shell glob (*.docx) converts a whole folder. One caveat: a running LibreOffice instance blocks headless conversion — quit it first or use a separate user profile with -env:UserInstallation=file:///tmp/loconv.

03Risk

RiskLow risk
RequirementsLibreOffice (sudo apt install libreoffice); close any running LibreOffice instance first
!Warning: Complex layouts can shift in conversion (fonts, wide spreadsheets, animations are simplified or dropped), so open the produced PDF and check pagination before sending it on.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

Last verified: 2026-09-18 · Category: Media