Integration-PDF API – Fast and Affordable Document Generation-merge-pdfs

Merge PDFs

Easily merge multiple PDF documents using the CustomJS API. Great for invoices, reports, and automation.


CustomJS Code

const { PDF_MERGE } = require('./utils'); 

const pdfInputs = [...input.files || [],...input.urls || []].filter(i => i); 

return PDF_MERGE(pdfInputs);

Reponse Type

Make sure that the response type is set to PDF.

Execution via API request

Option 1: Passing the PDFs as a URLs

This example shows how to merge multiple PDFs by providing their URLs. You can also combine URLs and Base64-encoded strings.

curl -X POST https://e.customjs.io/zeXXXy \
  -H "Content-Type: application/json" \
  -H "x-api-key: YOUR_API_KEY_HERE" \
  -d '{
    "urls": [
        "https://css4.pub/2017/newsletter/drylab.pdf", 
        "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
    ]
  }' --output test-by-urls.pdf

Option 2: Passing the PDFs as a base64 encoded strings

This example shows how to merge multiple PDFs by sending Base64-encoded binary strings. Keep in mind that the payload size is limited to 6 MB. You can also combine Base64 strings with URLs.

curl -X POST https://e.customjs.io/zeXXXy \
  -H "Content-Type: application/json" \
  -H "x-api-key: YOUR_API_KEY_HERE" \
  -d '{
    "files": [
        "JVBERi0x..........EyNzg3CiUlRU9GCg==", 
        "JVBERi0x..........EyNzg3CiUlRU9GCg=="
    ]
  }' --output test-by-strings.pdf