Merge, number and extract text from PDFs

Bundle a cover, a report and an appendix into one file, number it, then read it back as text for search and as an image for previews. Four small APIs, one pipeline.

Generating a PDF is rarely the end of the job. A board pack is a cover page, a report and three appendices that must arrive as one file. A contract packet needs page numbers so people can say "clause 4 on page 7" on a call. Uploaded PDFs need their text pulled out so search works, and a thumbnail so the file list is not a column of identical icons.

This lesson uses four APIs, each doing one of those things, and chains them into a pipeline. Each costs 10 credits per call.

APIDoesInput
PDF MergeJoins 2 to 10 PDFs in orderurls array, or uploads
PDF Page NumbersStamps a number on each pageUpload in field pdf
PDF to TextExtracts the text layerUpload in field pdf
PDF to ImageRenders pages as PNG or JPGpdf URL, or upload

All four reject encrypted PDFs; remove the password first.

Merging: order is the whole contract

PDF Merge takes urls, a JSON array of 2 to 10 public PDF URLs, and merges them in the order you send. Alternatively upload the files as multipart in the field pdfs. Limits: 10 MB per file, 25 MB in total, and at most 500 pages in the result. Pages are copied whole, so fonts, images and page sizes are preserved, even when the inputs have different page sizes.

Try it livePDF Merge10 credits
POSThttps://api.apiverve.com/v1/pdfmerge
curl -X POST "https://api.apiverve.com/v1/pdfmerge" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"urls":["https://raw.githubusercontent.com/mozilla/pdf.js/master/test/pdfs/rotation.pdf","https://raw.githubusercontent.com/mozilla/pdf.js/master/test/pdfs/sizes.pdf"]}'
Sign in or create a free account to run this with your own key.

pageCount should equal the sum of the inputs' pages: 2 + 3 here.

The response gives fileCount, pageCount, size and the usual downloadURL (valid for 2 days) with expires in milliseconds. Paid plans add sources: for each input, its index, name, pageCount, startPage and endPage in the merged file. That table is what you need to build a table of contents ("Appendix B starts on page 14") without counting pages yourself. For the two sample files above, it looks like this:

{
  "fileCount": 2,
  "pageCount": 5,
  "sources": [
    { "index": 1, "name": "rotation.pdf", "pageCount": 2, "startPage": 1, "endPage": 2 },
    { "index": 2, "name": "sizes.pdf", "pageCount": 3, "startPage": 3, "endPage": 5 }
  ]
}

Send one URL and the call fails with "send at least 2 PDFs to merge". If your code assembles a packet from optional parts, handle the one-part case by skipping the merge, not by sending the same file twice.

Chaining without downloading

Here is the trick that makes these APIs compose. Every file APIVerve generates comes back as a signed downloadURL on a public storage host, and PDF Merge accepts public URLs. So you can pass the downloadURLs from HTML to PDF and Office to PDF straight into a merge without downloading anything in between. We merged a 2-page HTML render with a 2-page converted Word document that way and got pageCount: 4.

Two cautions. The links expire, so chain promptly rather than storing them for a nightly batch. And a signed URL is a bearer credential for that file until it expires: do not log it at info level or paste it into tickets when the document contains personal data.

Check yourself

You merge cover.pdf (1 page), report.pdf (12 pages) and appendix.pdf (5 pages). Which check best confirms the merge did what you expected?

Answer the check above to continue.

Run every example on your own key. Free plan, no card.

Scaling up?

Volume pricing, custom SLAs, and dedicated support for high-traffic teams.

Contact sales