Merge PDFs
Combines PDFs into one.
POST/forms/pdf/merge
Form data
Options
No options.
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.