Skip to main content
Version: 9.x

Merge PDFs

Combines PDFs into one.

POST/forms/pdf/merge
filesfile[]required

The PDFs.

archivesfile[]

ZIP files Gotenberg unpacks: each entry counts as a file uploaded under files.

URLs Gotenberg downloads first, as if you had uploaded the files. Each entry takes a url, and optionally extraHttpHeaders.

No options.

One PDF.

The route also takes the headers. An error answers a status and a message: see Errors.

curl \
--request POST http://localhost:3000/forms/pdf/merge \
--form files=@report.pdf \
--form files=@annex.pdf \
-o merged.pdf

Gotenberg merges the files in the alphanumeric order of their names, not in the order you upload them: annex.pdf comes first here. Name them 1-report.pdf and 2-annex.pdf to pick the order. The result takes the name of the first file.

Each PDF keeps its bookmarks, pointed at the merged pages. For one bookmark per file, add a set-bookmarks stage after merge.

In a list of stages​

The stage also runs in a list on /forms/pdf/pipe, and on the PDFs a Chromium or LibreOffice conversion makes, in its stages field:

curl \
--request POST http://localhost:3000/forms/pdf/pipe \
--form files=@annex.pdf \
--form files=@report.pdf \
--form 'stages=[
{ "op": "merge" }
]' \
-o merged.pdf

Conversions merge too: a merge stage turns several office documents into one PDF.