LibreOffice headless document conversion via Hot Box containers.
Convert between office formats (DOCX, PDF, XLSX, PPTX, HTML, TXT, and more)
using libreoffice --headless in isolated containers. Inputs use hot://
storage URLs; outputs are written back to hot:// storage.
Uses libreofficedocker/alpine which has LibreOffice pre-installed on Alpine.
Override with a custom image via the image option.
Quick Start
out ::libreoffice/convert("hot://uploads/report.docx", {format: "pdf"})
tap(out.url)
// With explicit output path
out ::libreoffice/convert("hot://uploads/report.docx", {
format: "pdf",
output: "hot://docs/report.pdf",
})
ver ::libreoffice/version()
tap(ver.version)
Container Requirements
large
Values
DEFAULT_IMAGE
DEFAULT_IMAGE: Str "libreofficedocker/alpine:3.22"
FONT_INSTALL
FONT_INSTALL: Str "apk add --no-cache ttf-freefont > /dev/null 2>&1 || true"
Functions
build-convert-args
fn (input-path: Str, out-dir: Str, format: Str, filter: Str?, extra-args: Vec<Str>?): Vec<Str>
Build LibreOffice headless CLI arguments: --convert-to, --outdir, input path.
Example
::libreoffice/build-convert-args("/data/input.docx", "/data/out", "pdf", null, null)
// ["--headless", "--convert-to", "pdf", "--outdir", "/data/out", "/data/input.docx"]
::libreoffice/build-convert-args("/data/input.odt", "/data/out", "pdf", "writer_pdf_Export", ["--norestore"])
// ["--headless", "--convert-to", "pdf:writer_pdf_Export", "--outdir", "/data/out", "--norestore", "/data/input.odt"]
build-version-args
fn (): Vec<Str>
Build libreoffice --version arguments.
Example
::libreoffice/build-version-args() // ["--version"]
convert
fn (input: Str, opts: ConvertOpts): Map
Convert a document at a hot:// URL using headless LibreOffice.
Returns {url: Str, format: Str} with the output file URL in Hot storage.
Example
out ::libreoffice/convert("hot://uploads/notes.docx", {format: "pdf"})
out.url
out.format // "pdf"
// Advanced filter
out ::libreoffice/convert("hot://uploads/doc.odt", {
format: "pdf",
filter: "writer_pdf_Export",
})
large
expected-output-name
fn (input-path: Str, out-format: Str): Str
LibreOffice keeps the input basename and replaces the extension with the output format.
Example
::libreoffice/expected-output-name("/data/input.docx", "pdf") // "input.pdf"
::libreoffice/expected-output-name("/data/q3.final.xlsx", "csv") // "q3.final.csv"
parse-version-output
fn (stdout: Str?): Map
Parse LibreOffice version from libreoffice --version stdout (first
line).
Example
::libreoffice/parse-version-output("LibreOffice 24.2.7.2 420(Build:2)\n").version // "24.2.7.2"
::libreoffice/parse-version-output("unknown").version // "unknown"
start-convert
fn (input: Str, opts: ConvertOpts): Map
Start a LibreOffice headless conversion without awaiting the result.
Returns the box task info map immediately. Use ::hot::task/await
to retrieve the final result.
Example
task ::libreoffice/start-convert("hot://uploads/report.docx", {format: "pdf"})
result ::hot::task/await(task.id)
large
version
fn (): Map
fn (image: Str?): Map
Return LibreOffice version from libreoffice --version.
Example
ver ::libreoffice/version()
ver.version // e.g. "24.2.7.2"
large
Types
ConvertOpts
ConvertOpts type {
format: Str,
filter: Str?,
extra-args: Vec<Str>?,
output: Str?,
image: Str?,
size: Str?,
timeout: Int?
}
Options for LibreOffice headless conversion.
Fields
format— Output format, e.g."pdf","docx","xlsx","html","txt"filter— Optional LibreOffice filter name, e.g."writer_pdf_Export"; combined asformat:filteroutput— Outputhot://URL (default: auto-generated)image— Override Docker image (must havelibreofficein PATH)size— Box size override (default:"large")