LibreOffice class calls Gotenberg’s LibreOffice convert route to convert office and other document formats to PDF.
Supported extensions
LibreOffice supports many formats. Main families: Word processing (e.g..doc, .docx, .odt, .rtf, .txt), Spreadsheets (e.g. .xls, .xlsx, .ods, .csv), Presentations (e.g. .ppt, .pptx, .odp), Graphics (e.g. .odg, .svg, .vsdx), and Images (e.g. .jpg, .png, .bmp). .epub is not accepted. For the full list, see Gotenberg – LibreOffice formats.
Fonts and layout: LibreOffice uses installed fonts for layout. Missing fonts are substituted and can cause layout shifts or wrong pagination. For best results, install required fonts in your Gotenberg environment (see Gotenberg – Install fonts).
Image compression: Use nativeLosslessImageCompression: true for line art or diagrams (PNG); leave it off for photos (JPEG). Control JPEG with nativeQuality (1–100); use nativeReduceImageResolution and nativeMaxImageResolution to shrink image DPI and file size.
Macros: Macros in documents (e.g. .docm, .xlsm) don’t run unless Gotenberg starts with --libreoffice-enable-macros. Files still convert, but macro-driven content is not executed.
Basic conversion
files can be a path string or { data: Buffer | ReadStream, ext: string }. Chromiumly uploads them as file01.docx, file02.xlsx, and so on, and Gotenberg names each PDF after its document (file01.docx.pdf); set outputFilename to name the result. One document answers a PDF; several answer a ZIP, unless a merge stage joins them in alphanumeric order of their names.
Page properties
Passproperties to convert() to control the rendering of the source document, and to open password-protected source files:
Optional parameters
In addition toproperties, convert() accepts:
- nativePdfa — Export PDF/A:
"PDF/A-1b","PDF/A-2b","PDF/A-3b"or"PDF/A-4". Theremediatestage reaches the other levels. - nativePdfua — Export PDF/UA:
"PDF/UA-1". WithnativePdfa, the document needs a title, and"PDF/A-4"is refused: pair them inremediateinstead. - nativeTaggedPdf — Write a tagged PDF without declaring PDF/UA.
- nativeLosslessImageCompression — Toggle lossless image compression (PNG vs JPEG).
- nativeReduceImageResolution — Toggle image resolution reduction.
- nativeQuality — JPG export quality (1–100, default
90). - nativeMaxImageResolution — Reduce images to DPI:
75,150,300,600,1200. RequiresnativeReduceImageResolution. - initialView — Initial viewer panel:
"default","outline"or"thumbnails". - initialPage — Page number opened by default.
- magnification — How a viewer fits the page:
"default","fitWindow","fitWidth","fitVisible"or"zoom". - zoom — Initial zoom percentage when
magnificationis"zoom". - pageLayout — How a viewer lays the pages out:
"default","singlePage","oneColumn"or"twoColumnRight". - resizeWindowToInitialPage — Resize the viewer window to the first page size.
- centerWindow — Center the viewer window on screen.
- openInFullScreenMode — Open the PDF in full-screen mode.
- displayPDFDocumentTitle — Show the PDF title in the viewer title bar.
- hideViewerMenubar — Hide the viewer menubar.
- hideViewerToolbar — Hide the viewer toolbar.
- hideViewerWindowControls — Hide the viewer window controls.
- useTransitionEffects — Use transition effects for Impress slides.
- openBookmarkLevels — Number of bookmark levels to open (
-1opens all levels). - nativeWatermarkText / nativeTiledWatermarkText — LibreOffice-native watermark text, once per page or tiled in a grid (set one, not both), with nativeWatermarkColor (
"#rrggbb"), nativeWatermarkFontSize, nativeWatermarkRotation (degrees, counter-clockwise) and nativeWatermarkFont. - stages — Post-process the exported PDFs, in order: merge, split, stamp, encrypt, sign, PDF/A, and more. See Stages.
- archives / downloadFrom — Bring input files in a ZIP, or from URLs (see Files and downloads).
- webhook — Deliver the result asynchronously (see Webhooks).
- outputFilename / trace — Custom output filename and/or request trace id (see Request tracing).
Native fields or stages
A field whose name starts withnative asks LibreOffice to do the work while it exports the PDF. A stage does it afterwards, the same way on every route. For example, watermark at export time, then stamp and archive afterwards:
nativePdfa applies at export, and the stages after it may break conformance: end the list with a remediate stage when you need PDF/A after other stages.
See Reference — LibreOffice for the full API.