Compress PDF API

Reduce PDF file size while preserving visual quality.

check-mark-icnNo credit card required

Compress PDF API Overview

The Compress PDF API allows you to optimize PDF file size as part of an automated document workflow. It is designed for scenarios where PDFs need to be reduced in size before being uploaded, shared, or stored.

Compressing PDFs helps improve performance by reducing download times and storage requirements while keeping documents readable and visually consistent. This is commonly used when working with large files, image-heavy documents, or high-resolution PDFs.

This endpoint can be used on its own or combined with other PDFGate endpoints. A typical workflow includes generating a PDF from HTML, applying compression to optimize file size, and then distributing or storing the optimized document.

The Compress PDF API is well suited for SaaS platforms, internal systems, and document automation workflows that require efficient handling of PDFs without manual optimization steps.

Useful Guides

Quick Start


Get started quickly with a single API call. This endpoint fits easily into your existing workflows and works with any language that can make HTTP requests, including Node.js, Python, PHP, and more. Use the examples to compress a PDF in just a few steps.

CURL
NODE.JS
PYTHON
GO
PHP
JAVA
C#
RUBY
copy-integration-source-code-icon
curl -X POST "https://api.pdfgate.com/compress/pdf" \ -H "Authorization: Bearer YOUR_API_KEY" \ -F "file=@YOUR_FILE.pdf" \ -F "linearize=true" \ --output compressed.pdf

API Parameters

File

The PDF file you want to compress. You must provide either this or documentId.

Document Id

The ID of a PDF that already exists in your PDFGate account. Use this instead of uploading a file again.

Linearize

Re-arranges the PDF structure so the first page can be displayed before the entire file has finished downloading.

Json Response

If it is set to true, the API will return a JSON response instead of the PDF file.

Pre Signed Url Expires In

Expiration time (in seconds) for the generated temporary download URL.

Metadata

Custom metadata you want to attach to the document.