Integration-PDF API – Fast and Affordable Document Generation-compress-pdf

Compress your PDF documents

Reduce the file size of your PDFs without losing quality. Perfect for faster uploads, email attachments, and saving storage.


CustomJS Code

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

const pdfInput = input.url || input.file; 

return PDF_COMPRESS(pdfInput);

Reponse Type

Make sure that the response type is set to PDF.

Execution via API request

Option 1: Passing the PDF as a URL

Here you can see how to compress your PDF using a passed URL:

curl -X POST https://e.customjs.io/zeXXXy \
  -H "Content-Type: application/json" \
  -H "x-api-key: YOUR_API_KEY_HERE" \
  -d '{
    "url": "https://css4.pub/2017/newsletter/drylab.pdf"
  }' --output test-by-url.pdf

Option 2: Passing the PDF as a base64 encoded string

This shows how to compress your PDF by sending a binary Base64-encoded string. Keep in mind that the payload size is limited to 6 MB.

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