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

# Merge PDFs

> Merge multiple PDF files into one with PDFEngines.merge.

`PDFEngines.merge()` combines multiple PDFs into a single file. The merged PDF order follows the **alphanumeric order** of the input filenames (numbers first, then alphabetical). It uses Gotenberg’s [merge route](https://gotenberg.dev/docs/8.x/manipulate-pdfs/merge-pdfs), which can use PDFtk, PDFcpu, QPDF, or UNO.

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

const buffer = await PDFEngines.merge({
  files: ["path/to/file_1.pdf", "path/to/file_2.pdf"],
  pdfa: PdfFormat.A_2b,
  pdfUA: true,
  metadata: { Author: "Taha Cherfia" },
  flatten: true,
  bookmarks: [{ title: "Section 1", page: 1 }],
  autoIndexBookmarks: false,
  userPassword: "my_user_password",
  ownerPassword: "my_owner_password",
  allowPrinting: false,
});
```

Optional `pdfa` and `pdfUA` convert the merged result to PDF/A and/or PDF/UA. Optional `metadata` writes metadata to the merged PDF, and `flatten` flattens its form fields and annotations. See [Reference — PDFEngines](https://docs.chromiumly.dev/v6/reference/pdf-engines.md).

Optional `bookmarks` sets a final bookmark list on the merged PDF, or a filename-keyed map applied to each input before merging (its page indexes get offset automatically). Optional `autoIndexBookmarks` instead auto-extracts and offsets each input's existing bookmarks — `bookmarks` and `autoIndexBookmarks` are mutually exclusive strategies for the merged PDF's outline.

Optional `userPassword`/`ownerPassword` and the six permission booleans (`allowPrinting`, `allowCopying`, `allowModifying`, `allowAnnotating`, `allowFillingForms`, `allowAssembling`) encrypt the merged output — see [Encryption](https://docs.chromiumly.dev/v6/advanced/encryption.md) and [PDF permissions](https://docs.chromiumly.dev/v6/advanced/permissions.md).

You can also pass `watermark` and/or `stamp` to apply PDF-engine overlays during merge. Optional **`rotate`** (`{ angle: 90 | 180 | 270; pages?: string }`) runs a PDF-engine rotation pass after merge. See [Rotate PDFs](https://docs.chromiumly.dev/v6/pdf-engines/rotate.md) and [Watermark and stamp](https://docs.chromiumly.dev/v6/pdf-engines/watermark-stamp.md).

`downloadFrom`, `webhook`, `outputFilename`, and `trace` are also accepted — see [Request tracing](https://docs.chromiumly.dev/v6/advanced/request-tracing.md).


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