LibreOffice class calls Gotenberg’s LibreOffice 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. - flatten — Flatten form fields and annotations.
- userPassword / ownerPassword — PDF encryption (see Encryption).
- embeds — Attach files to the PDF (e.g. for ZUGFeRD/Factur-X).