Logo
Apdf tutorials August 2026 3 min read

How to Compress a Folder of PDFs with Claude Code

Batch-compressing PDFs is exactly the job nobody wants to own: a folder of oversized exports, a compression tool that handles one file at a time, and an afternoon of drag-drop-download-rename. Scripting it means learning some CLI's flags for a task you'll run twice a year.

With Apdf connected to Claude Code over MCP, the loop is the agent's problem. You say which files; it calls the compression tool for each, watches the jobs, and reports what it saved.

What you'll build
An archive folder batch-compressed from your editor — this conversation, working end to end: “Compress everything in the archive” → 74.3 MB → 4.5 MB on the worst offender
MCP access needs Pro (14-day trial, no card)
1

Connect Claude Code to Apdf

One command, then sign in when the OAuth window opens:

claude mcp add --transport http apdf https://apdf.io/mcp/main

The same endpoint works in Claude Desktop, Cursor, ChatGPT — anything that speaks MCP. The PDF tools need the files at publicly reachable URLs (your object storage, your web server), which is where an archive folder usually already lives.

2

Hand the agent the folder

Describe the batch once. The agent picks the compress-pdf-file tool and loops it over every file:

You
Compress everything in our reports archive and tell me what you saved:
https://files.northlight.example/archive/q3-board-pack.pdf
https://files.northlight.example/archive/merged-reports.pdf
https://files.northlight.example/archive/lease-1997-scan.pdf
Claude
apdf · compress-pdf-file ×3
All three are queued — compression runs as background jobs, so I'll poll for the results and report back with the savings per file.

Compression is heavy work, so each call returns a job id immediately; the agent polls check-job-status while you do something better with your time. The board pack comes back like this:

{
    "id": "01KY72EBTPH8P6VNE5CQ6HM2JH",
    "created": "2026-07-23T08:46:00.000000Z",
    "status": "successful",
    "result": {
        "file": "https://apdf-files.s3.eu-central-1.amazonaws.com/9d21ae246a61d4ca86827.pdf",
        "expiration": "2026-07-23T09:46:03.642774Z",
        "size_original": 77952379,
        "size_compressed": 4713594
    }
}
Heads up: Result files expire after 1 hour — have the agent download the compressed versions (or push them back to your storage) as the final step of the batch.
3

Read the batch report honestly

When the jobs finish, the agent totals it up:

You
How did the batch go?
Claude
apdf · check-job-status ×3
Done — page counts verified intact on all three:

• q3-board-pack.pdf: 74.3 MB → 4.5 MB (−94%)
• merged-reports.pdf: 70.5 KB → 67.7 KB (−4%)
• lease-1997-scan.pdf: no savings — kept the original

The board pack was full of print-resolution images; downsampling did almost all the work. The lease scan is already-optimized JPEG, so there was nothing left to squeeze.

That spread is what real batches look like. Image-heavy exports (slides, board packs, brochures) collapse by 80–95%; lean text PDFs shave single digits; and when recompression can't beat the original, the tool keeps your original file instead of shipping a worse one.

Where to go from here

The same connection carries every PDF operation — and the engagement layer behind them.

After the API call

Your code made the PDF.
Then it went dark.

Opened, read, re-read, dropped on page 4 — you never see any of it. Share the PDFs you generate through Apdf recipient links, and every signal becomes something you can act on: ping Slack, update the CRM, let an agent follow up. Same account, same API token, one more call.

Your PDF, after sending Live
document:loaded CFO
page:read p4 · 38s
link:clicked pricing

API · Webhook · MCP