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.
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.docx02What 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
!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
- soffice(1) — Debian manual pageEvidence: Documents --headless and --convert-to for running LibreOffice document conversion without a GUI.
- LibreOffice Help — Converting documents in batch modeEvidence: Explains batch conversion of many documents with --convert-to and filters such as pdf:writer_pdf_Export.
Last verified: 2026-09-18 · Category: Media