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). For the full list, see Gotenberg – LibreOffice.
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 configuration).
Image compression: Use losslessImageCompression: true for line art or diagrams (PNG); leave it off for photos (JPEG). Control JPEG with quality (1–100); use reduceImageResolution and maxImageResolution to shrink image DPI and file size.
Macros: Macros in documents (e.g. .docm, .xlsm) are disabled during conversion. Files still convert, but macro-driven content is not executed.
Basic conversion
files can be a path string or { data: Buffer | ReadStream, ext: string }. The method returns a single PDF buffer (or multiple if merge is not set). With merge: true, PDFs are combined in alphanumeric order by original filename (numbers first, then alphabetical).
Optional parameters
- properties — Page layout; includes
passwordfor protected source files. - pdfa — PDF/A format (e.g.
PDF/A-1a,PDF/A-2b,PDF/A-3b). - pdfUA — PDF/UA for accessibility.
- merge — Merge all converted PDFs into one (order: alphanumeric by filename).
- metadata — Write metadata to the generated PDF.
- losslessImageCompression — Toggle lossless image compression (PNG vs JPEG).
- reduceImageResolution — Toggle image resolution reduction.
- quality — JPG export quality (1–100).
- maxImageResolution — Reduce images to DPI:
75,150,300,600,1200. - initialView — Initial viewer panel (
0: none,1: outline,2: thumbnails). - initialPage — Page number opened by default.
- magnification — Initial zoom mode (
0: default,1: fit page,2: fit width,3: fit visible,4: usezoom). - zoom — Initial zoom percentage when
magnificationis4. - pageLayout — Initial layout (
0: default,1: single page,2: one column,3: two columns). - firstPageOnLeft — Place the first page on the left for two-column layout.
- 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). - downloadFrom — Fetch input files remotely (
DownloadFromEntryorDownloadFromEntry[]). - flatten — Flatten form fields and annotations.
- userPassword / ownerPassword — PDF encryption (see Encryption).
- embeds — Attach files to the PDF (e.g. for ZUGFeRD/Factur-X).
- nativeWatermarkText, nativeWatermarkColor, nativeWatermarkFontHeight, nativeWatermarkRotateAngle, nativeWatermarkFontName, nativeTiledWatermarkText — LibreOffice-native watermark fields applied during export.
- webhook — Request-level webhook headers for asynchronous callbacks.
- watermark / stamp — PDF-engine post-processing overlays. Watermark is behind content; stamp is on top.
- rotate — PDF-engine post-process page rotation (
{ angle: 90 | 180 | 270; pages?: string }). See Rotate PDFs.
Watermark and stamp
LibreOffice.convert() supports two watermark modes:
- Native LibreOffice watermark fields (
nativeWatermark*) for export-time watermarking. - PDF-engine watermark/stamp (
watermark,stamp) for post-processing with the configured PDF engine.
source to "image" or "pdf", set expression to the uploaded filename, and pass the file with file.
See Reference — LibreOffice for the full API.