Merge PDF API
Use Merge PDF from your code: send the files and get the PDF back.
At a glance
- Takes
- Makes
- Costs
- 1 credit a job, however many files it joins; nothing with a test key, nothing when it fails
- Files
- 2 to 20 a job, joined in the order sent
- File size
- Up to 1 MB with a test key; 100 MB on Free, up to 5 GB on API Scale
- Engine
- PDF engine (qpdf, PDFium)
Convert a file
Send the files to POST /v1/convert, naming the conversion, with an API key from the dashboard. The answer is the PDF.
curl "https://api.formatjet.com/v1/convert?conversion=merge-pdf" \
-H "Authorization: Bearer $FORMATJET_API_KEY" \
-F file=@first.pdf \
-F file=@second.pdf \
-o output.pdfTypeScript
import { readFile, writeFile } from 'node:fs/promises';
const form = new FormData();
for (const name of ['first.pdf', 'second.pdf']) {
form.append('file', new Blob([await readFile(name)]), name);
}
const response = await fetch('https://api.formatjet.com/v1/convert?conversion=merge-pdf', {
method: 'POST',
headers: { Authorization: `Bearer ${process.env.FORMATJET_API_KEY}` },
body: form,
});
if (!response.ok) throw new Error(`${response.status}: ${await response.text()}`);
await writeFile('output.pdf', new Uint8Array(await response.arrayBuffer()));Python
import os
import requests
names = ["first.pdf", "second.pdf"]
files = [("file", (name, open(name, "rb"))) for name in names]
response = requests.post(
"https://api.formatjet.com/v1/convert",
params={"conversion": "merge-pdf"},
headers={"Authorization": f"Bearer {os.environ['FORMATJET_API_KEY']}"},
files=files,
timeout=60,
)
response.raise_for_status()
with open("output.pdf", "wb") as file:
file.write(response.content)The quickstart makes a test key and runs a request like this one. Requests take up to 25 MB; for larger files, files at a URL or a webhook when it’s done, make a job.