> ## 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/8.x/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/8.x/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/8.x/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).

## Page properties

Pass `properties` to `convert()` to control the rendering of the source document, and to open password-protected source files:

| Property | Type | Description |
| - | - | - |
| `password` | `string` | Password to open the source document |
| `landscape` | `boolean` | Paper orientation landscape (default: `false`) |
| `nativePageRanges` | `{ from, to }` | Page range to print |
| `exportFormFields` | `boolean` | Export form fields as interactive widgets, or `false` to flatten them during conversion (default: `true`) |
| `singlePageSheets` | `boolean` | Render entire spreadsheet as a single page (default: `false`) |
| `allowDuplicateFieldNames` | `boolean` | Allow multiple form fields with the same name |
| `exportBookmarks` | `boolean` | Export bookmarks to the resulting PDF (default: `true`) |
| `exportBookmarksToPdfDestination` | `boolean` | Export bookmarks as Named Destination in the PDF |
| `exportPlaceholders` | `boolean` | Export placeholder fields' visual markings only |
| `exportNotes` | `boolean` | Export notes to the resulting PDF |
| `exportNotesPages` | `boolean` | Export notes pages (Impress documents only) |
| `exportOnlyNotesPages` | `boolean` | Export only notes pages, when `exportNotesPages` is `true` |
| `exportNotesInMargin` | `boolean` | Export notes in the margin of the resulting PDF |
| `convertOooTargetToPdfTarget` | `boolean` | Change `.od[tpgs]` extensions to `.pdf` in exported links |
| `exportLinksRelativeFsys` | `boolean` | Export file system related hyperlinks as relative |
| `exportHiddenSlides` | `boolean` | Export hidden slides (Impress documents only) |
| `skipEmptyPages` | `boolean` | Suppress the automatic insertion of blank pages (Writer documents only) |
| `updateIndexes` | `boolean` | Update the document's indexes/table of contents before export (default: `true`) |
| `addOriginalDocumentAsStream` | `boolean` | Insert the original file as a stream in the resulting PDF |

## Optional parameters

In addition to `properties`, `convert()` accepts:

* **pdfa** — PDF/A format (e.g. `PDF/A-1b`, `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[]`).
* **split** — Split the resulting PDF into multiple files: `{ mode: "pages" | "intervals", span, unify? }`. See [Split PDFs](https://docs.chromiumly.dev/v6/pdf-engines/split.md).
* **flatten** — Flatten the resulting PDF's form fields and annotations.
* **userPassword** / **ownerPassword** — PDF encryption (see [Encryption](https://docs.chromiumly.dev/v6/advanced/encryption.md)).
* **allowPrinting**, **allowCopying**, **allowModifying**, **allowAnnotating**, **allowFillingForms**, **allowAssembling** — PDF permission booleans, each defaulting to `true` (see [PDF permissions](https://docs.chromiumly.dev/v6/advanced/permissions.md)).
* **embeds** — Attach files to the PDF (e.g. for [ZUGFeRD/Factur-X](https://docs.chromiumly.dev/v6/advanced/embedding.md)).
* **embedsMetadata** — Per-attachment metadata keyed by filename, for PDF/A-3 and Factur-X compliance (see [Embedding files](https://docs.chromiumly.dev/v6/advanced/embedding.md)).
* **facturx** — Turn the resulting PDF into a Factur-X / ZUGFeRD e-invoice (see [Factur-X](https://docs.chromiumly.dev/v6/advanced/factur-x.md)).
* **outputFilename** / **trace** — Custom output filename and/or request trace id (see [Request tracing](https://docs.chromiumly.dev/v6/advanced/request-tracing.md)).
* **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](https://docs.chromiumly.dev/v6/pdf-engines/rotate.md).

## 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](https://docs.chromiumly.dev/v6/reference/libreoffice.md) for the full API.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.