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

# Split PDFs

> Split PDFs by page ranges or intervals with PDFEngines.split or the split option on Chromium/LibreOffice.

## PDFEngines.split

Splits PDFs using Gotenberg’s [split route](https://gotenberg.dev/docs/8.x/manipulate-pdfs/split-pdfs):

```typescript theme={null}
import { PDFEngines, PdfFormat } from "chromiumly";

const buffer = await PDFEngines.split({
  files: ["path/to/file_1.pdf", "path/to/file_2.pdf"],
  options: {
    mode: "pages",
    span: "1-2",
    unify: true,
    flatten: true,
  },
  metadata: { Author: "Taha Cherfia" },
  pdfa: PdfFormat.A_2b,
  userPassword: "my_user_password",
});
```

The `options` object holds the split configuration:

* **mode** — `"pages"` or `"intervals"`
* **span** — Page range string (e.g. `"1-2"`, `"1,3,5"`)
* **unify** — When `mode` is `"pages"`, merge the split results into one PDF
* **flatten** — Flatten form fields and annotations in the output — part of `options` on this route specifically (see the note below)

> [!WARNING]
>
> Gotenberg does not validate `span` when `mode` is `"pages"`; validation
> depends on the engine. See [Gotenberg PDF Engines
> configuration](https://gotenberg.dev/docs/8.x/configuration#pdf-engines).

`PDFEngines.split()` also accepts optional `metadata`, `pdfa`/`pdfUA`, `userPassword`/`ownerPassword` and the six permission booleans (see [PDF permissions](https://docs.chromiumly.dev/v6/advanced/permissions.md)), and `watermark`, `stamp`, and `rotate` for PDF-engine post-processing on the split output. See [Rotate PDFs](https://docs.chromiumly.dev/v6/pdf-engines/rotate.md). `downloadFrom`, `webhook`, `outputFilename`, and `trace` are also accepted — see [Request tracing](https://docs.chromiumly.dev/v6/advanced/request-tracing.md).

## Split on Chromium and LibreOffice

Chromium converters and LibreOffice also support a `split` option on `convert()` so you can split the generated PDF in the same request:

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

const buffer = await new UrlConverter().convert({
  url: "https://example.com/",
  split: { mode: "pages", span: "1-2", unify: true },
});
```

See [Chromium options](https://docs.chromiumly.dev/v6/chromium/options.md) and [Reference — types](https://docs.chromiumly.dev/v6/reference/types.md) for the `ConvertSplit` type.

> [!NOTE]
>
> `flatten` is **not** part of `split` on Chromium/LibreOffice `convert()` —
> it's a separate top-level option there (see [Flatten
> PDFs](https://docs.chromiumly.dev/v6/pdf-engines/flatten.md)). It's only nested inside `options` on the
> dedicated `PDFEngines.split()` route shown above.


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