> ## Documentation Index
> Fetch the complete documentation index at: https://docs.chromiumly.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# LibreOffice

> Convert office documents (DOCX, XLSX, PPTX, etc.) to PDF using Gotenberg's LibreOffice route.

The `LibreOffice` class calls Gotenberg’s [LibreOffice convert route](https://gotenberg.dev/docs/convert-with-libreoffice/convert-to-pdf) 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](https://gotenberg.dev/docs/convert-with-libreoffice/convert-to-pdf#supported-extensions).

**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](https://gotenberg.dev/docs/configuration#fonts)).

**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

```typescript theme={null}
import { LibreOffice } from "chromiumly";

const buffer = await LibreOffice.convert({
  files: [
    "path/to/file.docx",
    "path/to/file.xlsx",
    { data: xlsxBuffer, ext: "xlsx" },
  ],
});
```

Each item in `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 `password` for 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`: use `zoom`).
* **zoom** — Initial zoom percentage when `magnification` is `4`.
* **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 (`-1` opens all levels).
* **downloadFrom** — Fetch input files remotely (`DownloadFromEntry` or `DownloadFromEntry[]`).
* **flatten** — Flatten form fields and annotations.
* **userPassword** / **ownerPassword** — PDF encryption (see [Encryption](/advanced/encryption)).
* **embeds** — Attach files to the PDF (e.g. for [ZUGFeRD/Factur-X](/advanced/embedding)).
* **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](/pdf-engines/rotate).

## 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.

```typescript theme={null}
import { LibreOffice } from "chromiumly";

const buffer = await LibreOffice.convert({
  files: ["path/to/report.docx"],
  nativeWatermarkText: "DRAFT",
  watermark: {
    source: "text",
    expression: "CONFIDENTIAL",
    options: { opacity: 0.2, rotation: 45 },
  },
  stamp: {
    source: "text",
    expression: "APPROVED",
    options: { opacity: 0.5, rotation: 0 },
  },
});
```

For image/PDF overlays, set `source` to `"image"` or `"pdf"`, set `expression` to the uploaded filename, and pass the file with `file`.

See [Reference — LibreOffice](/reference/libreoffice) for the full API.
