Skip to main content
Try it live: PDF Compress → API Tester — send a real request from your browser.

POST /v2/pdf/compress

A new and improved compression API - our 1st version 2 PDF.co endpoint!
Allows for more granular control over PDF compression with enhanced results.

Attributes

Attributes are case-sensitive and should be inside JSON for POST request. for example: { "url": "https://example.com/file1.pdf" }

config

The config object defines granular settings for the compression process as follows:

config.images

Image compression options. Each key defines how to treat certain image types in the document. In this way you can target color, grayscale or monochrome images with different approaches. Each key above takes the same bundle of key/value pairs as follows:

Downsample & Compression object

config.images.color, config.images.grayscale & config.images.monochrome all utlize this object schema.

Downsample object

Here you can choose the target ppi / threshold ppi or skip downsampling if you want. The threshold ppi is the limit for which to start downsizing from and the downsample ppi is the target ppi to meet.
Example: If the threshold ppi (threshold_ppi) is 400 and downsample ppi (downsample_ppi) is 250, it will reduce the resolution to 250 ppi for any images with resolution equal or higher than 400 ppi.

Compression object

Here you can choose different compression options for each image type: color, grayscale or monochrome.

Compression parameters object

Depending on what you have set for the compression_format algorithm you have different options.
  • jpeg: can choose quality
  • jpeg2000: can choose quality and layers
JPEG Example
JPEG2000 | Key | Type | Description | | --- | --- | --- | | quality_mode | string. Either “rates” or “dB” depending on the units you want to use to specify image quality. Default is “rates”. | String used to define quality mode for JPEG2000. | | quality_layers | number[]. A sequence of numbers, each of which represents either an approximate size reduction (if quality mode is “rates”) or a signal to noise ratio value in decibels. If not specified, defaults to a single layer of full quality. Default is[30]ifquality_modeis “rates”. Default is[38.0,34.0,30.0]ifquality_modeis “dB”. | An array of numbers for the layers. | Example

config.save

Contains one key for use with garbage collection to free up space that has been allocated to objects no longer needed.

config.save.garbage

Example

The default config object

The default config is set to match the standard configuration for image optimization by Adobe Acrobat Pro and is defined as follows:

Query parameters

No query parameters accepted.

Responses

Example Payload

To see the request size limits, please refer to the Request Size Limits.

Example Response

To see the main response codes, please refer to the Response Codes page.
Inconsistent URL Encoding in cURL Output: When using cURL to make API requests, the output JSON may show URL characters encoded as Unicode escape sequences. For example, the ampersand character (&) may appear as \u0026 in the cURL output. This is normal JSON encoding behavior and does not affect the validity of the URL. The URL will function correctly when used, as JSON parsers automatically decode these escape sequences. If you’re parsing the response programmatically, your JSON parser will handle this conversion automatically.

Code Samples