Compress PDF

Open in ChatGPT Open in ChatGPT to ask questions about this page
Open in Claude Open in Claude to ask questions about this page
Copy as MarkdownCopy this page as markdown to use with AI assistants
View as Markdown Open this page as markdown in a new tab

Reduces the file size of a PDF by optimizing images, fonts, and document resources, and discarding unneeded objects and metadata, then makes the compressed PDF available for download.


Field Precedence: When both are set, discard_objects.flatten_form_fields takes precedence over discard_objects.discard_form_fields, and discard_objects.discard_annotations takes precedence over discard_objects.discard_hidden_annotations (and makes discard_user_data.discard_rich_media redundant, since all annotations are already removed).

Endpoint

OAuth Scope

ZohoWriter.pdfEditor.ALLCopied!

Request Example

cURL
cURL
Java
Python
Deluge
Copied!
curl --request POST \
  --url https://www.zohoapis.com/pdfeditor/api/v1/pdf/compress \
  --header 'Authorization: Zoho-oauthtoken d92d4xxxxxxxxxxxxx15f52' \
  --header 'content-type: multipart/form-data' \
  -F 'file=@file_path' \
  -F 'input_options={
  "image_settings": {
    "color_images": {
      "enable_resize": true,
      "enable_dpi_reduction": true,
      "target_dpi": 150,
      "max_dimension": 1500,
      "convert_to_grayscale": false,
      "compression_type": "jpeg",
      "quality": 0.75,
      "deduplicate_images": true,
      "extract_inline_images": false
    },
    "grayscale_images": {
      "enable_resize": true,
      "enable_dpi_reduction": true,
      "target_dpi": 150,
      "max_dimension": 1500,
      "compression_type": "jpeg",
      "quality": 0.8,
      "deduplicate_images": true
    },
    "monochrome_images": {
      "enable_resize": false,
      "enable_dpi_reduction": true,
      "target_dpi": 300,
      "compression_type": "lossless",
      "quality": "lossless"
    }
  },
  "font_settings": {
    "deduplicate_fonts": true,
    "subset_fonts": true
  },
  "resource_optimization": {
    "remove_unused_resources": true,
    "deduplicate_streams": true,
    "compress_objects": true,
    "enable_stream_compression": true
  },
  "discard_objects": {
    "discard_form_fields": false,
    "flatten_form_fields": true,
    "discard_annotations": false,
    "discard_hidden_annotations": true,
    "discard_alternate_images": true,
    "discard_bookmarks": true,
    "discard_thumbnails": true,
    "discard_page_actions": true,
    "discard_open_actions": true,
    "discard_output_intents": true,
    "discard_optional_content_layers": true
  },
  "discard_user_data": {
    "discard_metadata": true,
    "discard_javascript": true,
    "discard_embedded_files": true,
    "discard_rich_media": true,
    "discard_accessibility_tags": false,
    "discard_private_application_data": true
  },
  "color_management": {
    "normalize_transparency": true,
    "force_rgb": true
  }
}' \
  -F 'password=OpenSesame123'

Request Body

multipart/form-data
filebinary(Required)

The source PDF to compress, uploaded directly or imported from a publicly accessible URL. The file must be no larger than 50 MB, contain no more than 400 pages, and have no page larger than 2,400 square inches. Its filename must not exceed 255 characters. Supported formats: pdf.

Example
quarterly-review.pdf
input_optionsJSON Object(Required)

Configures how the PDF is compressed. At least one setting must be provided.

Example
{
  "image_settings": {
    "color_images": {
      "enable_resize": true,
      "enable_dpi_reduction": true,
      "target_dpi": 150,
      "max_dimension": 1500,
      "convert_to_grayscale": false,
      "compression_type": "jpeg",
      "quality": 0.75,
      "deduplicate_images": true,
      "extract_inline_images": false
    },
    "grayscale_images": {
      "enable_resize": true,
      "enable_dpi_reduction": true,
      "target_dpi": 150,
      "max_dimension": 1500,
      "compression_type": "jpeg",
      "quality": 0.8,
      "deduplicate_images": true
    },
    "monochrome_images": {
      "enable_resize": false,
      "enable_dpi_reduction": true,
      "target_dpi": 300,
      "compression_type": "lossless",
      "quality": "lossless"
    }
  },
  "font_settings": {
    "deduplicate_fonts": true,
    "subset_fonts": true
  },
  "resource_optimization": {
    "remove_unused_resources": true,
    "deduplicate_streams": true,
    "compress_objects": true,
    "enable_stream_compression": true
  },
  "discard_objects": {
    "discard_form_fields": false,
    "flatten_form_fields": true,
    "discard_annotations": false,
    "discard_hidden_annotations": true,
    "discard_alternate_images": true,
    "discard_bookmarks": true,
    "discard_thumbnails": true,
    "discard_page_actions": true,
    "discard_open_actions": true,
    "discard_output_intents": true,
    "discard_optional_content_layers": true
  },
  "discard_user_data": {
    "discard_metadata": true,
    "discard_javascript": true,
    "discard_embedded_files": true,
    "discard_rich_media": true,
    "discard_accessibility_tags": false,
    "discard_private_application_data": true
  },
  "color_management": {
    "normalize_transparency": true,
    "force_rgb": true
  }
}
Show Sub-Attributes
image_settingsJSON Object(Optional)

Compression settings for images in the PDF, grouped by image type.

Example
{
  "color_images": {
    "enable_resize": true,
    "enable_dpi_reduction": true,
    "target_dpi": 150,
    "max_dimension": 1500,
    "convert_to_grayscale": false,
    "compression_type": "jpeg",
    "quality": 0.75,
    "deduplicate_images": true,
    "extract_inline_images": false
  },
  "grayscale_images": {
    "enable_resize": true,
    "enable_dpi_reduction": true,
    "target_dpi": 150,
    "max_dimension": 1500,
    "compression_type": "jpeg",
    "quality": 0.8,
    "deduplicate_images": true
  },
  "monochrome_images": {
    "enable_resize": false,
    "enable_dpi_reduction": true,
    "target_dpi": 300,
    "compression_type": "lossless",
    "quality": "lossless"
  }
}
Show Sub-Attributes
color_imagesJSON Object(Optional)

Compression settings applied to full-color images.

Example
{
  "enable_resize": true,
  "enable_dpi_reduction": true,
  "target_dpi": 150,
  "max_dimension": 1500,
  "convert_to_grayscale": false,
  "compression_type": "jpeg",
  "quality": 0.75,
  "deduplicate_images": true,
  "extract_inline_images": false
}
Show Sub-Attributes
enable_resizeboolean(Optional)

Resizes full-color images down to max_dimension when they exceed it.

Example
true
Default Value :falsefalseCopied!
enable_dpi_reductionboolean(Optional)

Reduces the effective resolution of full-color images down to target_dpi when they exceed it.

Example
true
Default Value :falsefalseCopied!
target_dpiinteger(Optional)

The resolution, in DPI, full-color images are downscaled to when enable_dpi_reduction is true.

Example
150
Default Value :150150Copied!
max_dimensioninteger(Optional)

The maximum width or height, in pixels, full-color images are downscaled to when enable_resize is true.

Example
1500
Default Value :15001500Copied!
convert_to_grayscaleboolean(Optional)

Converts full-color images to grayscale.

Example
false
Default Value :falsefalseCopied!
compression_typestring(Optional)

The compression algorithm applied to full-color images.

Example
jpeg
Allowed Values :
Show Values ▾
jpegCopied!
losslessCopied!
Copied!Copy all as JSON Array
Default Value :jpegjpegCopied!
qualitynumber(Optional)

The JPEG compression quality (0–1) for full-color images. Applies only when compression_type is jpeg.

Example
0.75
Default Value :0.750.75Copied!
deduplicate_imagesboolean(Optional)

Reuses a single copy of a full-color image wherever it repeats in the document, instead of storing it multiple times.

Example
true
Default Value :falsefalseCopied!
extract_inline_imagesboolean(Optional)

Extracts inline images embedded directly in page content streams so they can be compressed like other images.

Example
false
Default Value :falsefalseCopied!
grayscale_imagesJSON Object(Optional)

Compression settings applied to grayscale images.

Example
{
  "enable_resize": true,
  "enable_dpi_reduction": true,
  "target_dpi": 150,
  "max_dimension": 1500,
  "compression_type": "jpeg",
  "quality": 0.8,
  "deduplicate_images": true
}
Show Sub-Attributes
enable_resizeboolean(Optional)

Resizes grayscale images down to max_dimension when they exceed it.

Example
true
Default Value :falsefalseCopied!
enable_dpi_reductionboolean(Optional)

Reduces the effective resolution of grayscale images down to target_dpi when they exceed it.

Example
true
Default Value :falsefalseCopied!
target_dpiinteger(Optional)

The resolution, in DPI, grayscale images are downscaled to when enable_dpi_reduction is true.

Example
150
Default Value :150150Copied!
max_dimensioninteger(Optional)

The maximum width or height, in pixels, grayscale images are downscaled to when enable_resize is true.

Example
1500
Default Value :15001500Copied!
compression_typestring(Optional)

The compression algorithm applied to grayscale images.

Example
jpeg
Allowed Values :
Show Values ▾
jpegCopied!
losslessCopied!
Copied!Copy all as JSON Array
Default Value :jpegjpegCopied!
qualitynumber(Optional)

The JPEG compression quality (0–1) for grayscale images. Applies only when compression_type is jpeg.

Example
0.8
Default Value :0.80.8Copied!
deduplicate_imagesboolean(Optional)

Reuses a single copy of a grayscale image wherever it repeats in the document, instead of storing it multiple times.

Example
true
Default Value :falsefalseCopied!
monochrome_imagesJSON Object(Optional)

Compression settings applied to 1-bit (monochrome) images.

Example
{
  "enable_resize": false,
  "enable_dpi_reduction": true,
  "target_dpi": 300,
  "compression_type": "lossless",
  "quality": "lossless"
}
Show Sub-Attributes
enable_resizeboolean(Optional)

Resizes 1-bit (monochrome) images based on the page size and target_dpi when enable_dpi_reduction is true.

Example
false
Default Value :falsefalseCopied!
enable_dpi_reductionboolean(Optional)

Reduces the effective resolution of monochrome images down to target_dpi when they exceed it.

Example
true
Default Value :falsefalseCopied!
target_dpiinteger(Optional)

The resolution, in DPI, monochrome images are downscaled to when enable_dpi_reduction is true.

Example
300
Default Value :300300Copied!
compression_typestring(Optional)

The compression algorithm applied to monochrome images.

Example
lossless
Allowed Values :
Show Values ▾
jpegCopied!
losslessCopied!
Copied!Copy all as JSON Array
Default Value :losslesslosslessCopied!
qualitystring(Optional)

The compression quality applied to monochrome images.

Example
lossless
Allowed Values :
Show Values ▾
losslessCopied!
lossyCopied!
Copied!Copy all as JSON Array
Default Value :losslesslosslessCopied!
font_settingsJSON Object(Optional)

Font-related compression settings.

Example
{
  "deduplicate_fonts": true,
  "subset_fonts": true
}
Show Sub-Attributes
deduplicate_fontsboolean(Optional)

Consolidates identical embedded font programs into a single shared copy.

Example
true
Default Value :falsefalseCopied!
subset_fontsboolean(Optional)

Reduces each embedded font to only the glyphs actually used in the document.

Example
true
Default Value :falsefalseCopied!
resource_optimizationJSON Object(Optional)

Settings for optimizing the PDF's internal object and stream storage.

Example
{
  "remove_unused_resources": true,
  "deduplicate_streams": true,
  "compress_objects": true,
  "enable_stream_compression": true
}
Show Sub-Attributes
remove_unused_resourcesboolean(Optional)

Removes page resources (images, fonts, color spaces, and similar) that are no longer referenced by any page content.

Example
true
Default Value :falsefalseCopied!
deduplicate_streamsboolean(Optional)

Consolidates identical content streams that appear more than once in the document into a single shared copy.

Example
true
Default Value :falsefalseCopied!
compress_objectsboolean(Optional)

Compresses the PDF's internal object streams.

Example
true
Default Value :falsefalseCopied!
enable_stream_compressionboolean(Optional)

Compresses the PDF's content streams.

Example
true
Default Value :truetrueCopied!
discard_objectsJSON Object(Optional)

Configures which structural objects are discarded from the PDF.

Example
{
  "discard_form_fields": false,
  "flatten_form_fields": true,
  "discard_annotations": false,
  "discard_hidden_annotations": true,
  "discard_alternate_images": true,
  "discard_bookmarks": true,
  "discard_thumbnails": true,
  "discard_page_actions": true,
  "discard_open_actions": true,
  "discard_output_intents": true,
  "discard_optional_content_layers": true
}
Show Sub-Attributes
discard_form_fieldsboolean(Optional)

Removes the PDF's fillable form entirely.

Example
false
Default Value :falsefalseCopied!
flatten_form_fieldsboolean(Optional)

Flattens the PDF's form fields into static page content.

Example
true
Default Value :falsefalseCopied!
discard_annotationsboolean(Optional)

Removes every annotation from every page.

Example
false
Default Value :falsefalseCopied!
discard_hidden_annotationsboolean(Optional)

Removes only annotations that are invisible, hidden, marked no-view, or have a zero-size rectangle.

Example
true
Default Value :falsefalseCopied!
discard_alternate_imagesboolean(Optional)

Removes alternate image representations stored alongside an image's primary representation.

Example
true
Default Value :falsefalseCopied!
discard_bookmarksboolean(Optional)

Removes the PDF's bookmark/outline tree.

Example
true
Default Value :falsefalseCopied!
discard_thumbnailsboolean(Optional)

Removes cached page thumbnail images.

Example
true
Default Value :falsefalseCopied!
discard_page_actionsboolean(Optional)

Removes per-page additional actions.

Example
true
Default Value :falsefalseCopied!
discard_open_actionsboolean(Optional)

Removes the document's open action.

Example
true
Default Value :falsefalseCopied!
discard_output_intentsboolean(Optional)

Removes the document's output intents.

Example
true
Default Value :falsefalseCopied!
discard_optional_content_layersboolean(Optional)

Removes optional content group (layer) definitions.

Example
true
Default Value :falsefalseCopied!
discard_user_dataJSON Object(Optional)

Configures which document-level metadata and embedded data is discarded.

Example
{
  "discard_metadata": true,
  "discard_javascript": true,
  "discard_embedded_files": true,
  "discard_rich_media": true,
  "discard_accessibility_tags": false,
  "discard_private_application_data": true
}
Show Sub-Attributes
discard_metadataboolean(Optional)

Removes the document's information dictionary and XMP metadata.

Example
true
Default Value :falsefalseCopied!
discard_javascriptboolean(Optional)

Removes embedded JavaScript and related additional actions.

Example
true
Default Value :falsefalseCopied!
discard_embedded_filesboolean(Optional)

Removes all embedded file attachments.

Example
true
Default Value :falsefalseCopied!
discard_rich_mediaboolean(Optional)

Removes rich media (video/3D) annotations.

Example
true
Default Value :falsefalseCopied!
discard_accessibility_tagsboolean(Optional)

Removes the document's structure tree and tagging information.

Example
false
Default Value :falsefalseCopied!
discard_private_application_databoolean(Optional)

Removes application-specific private data stored alongside pages.

Example
true
Default Value :falsefalseCopied!
color_managementJSON Object(Optional)

Settings for normalizing color spaces in the PDF.

Example
{
  "normalize_transparency": true,
  "force_rgb": true
}
Show Sub-Attributes
normalize_transparencyboolean(Optional)

Normalizes transparency groups in the PDF to a consistent color space.

Example
true
Default Value :falsefalseCopied!
force_rgbboolean(Optional)

Converts CMYK images without transparency to RGB.

Example
true
Default Value :falsefalseCopied!
passwordstring(Optional)

The password to unlock the source PDF, if it is password-protected.

Example
OpenSesame123
Maximum Length :255255Copied!

Body Parameters

Copied!
// Note: payload contains multiple type attributes

// type: file
file = quarterly-review.pdf

// type: object
input_options = {
  "image_settings": {
    "color_images": {
      "enable_resize": true,
      "enable_dpi_reduction": true,
      "target_dpi": 150,
      "max_dimension": 1500,
      "convert_to_grayscale": false,
      "compression_type": "jpeg",
      "quality": 0.75,
      "deduplicate_images": true,
      "extract_inline_images": false
    },
    "grayscale_images": {
      "enable_resize": true,
      "enable_dpi_reduction": true,
      "target_dpi": 150,
      "max_dimension": 1500,
      "compression_type": "jpeg",
      "quality": 0.8,
      "deduplicate_images": true
    },
    "monochrome_images": {
      "enable_resize": false,
      "enable_dpi_reduction": true,
      "target_dpi": 300,
      "compression_type": "lossless",
      "quality": "lossless"
    }
  },
  "font_settings": {
    "deduplicate_fonts": true,
    "subset_fonts": true
  },
  "resource_optimization": {
    "remove_unused_resources": true,
    "deduplicate_streams": true,
    "compress_objects": true,
    "enable_stream_compression": true
  },
  "discard_objects": {
    "discard_form_fields": false,
    "flatten_form_fields": true,
    "discard_annotations": false,
    "discard_hidden_annotations": true,
    "discard_alternate_images": true,
    "discard_bookmarks": true,
    "discard_thumbnails": true,
    "discard_page_actions": true,
    "discard_open_actions": true,
    "discard_output_intents": true,
    "discard_optional_content_layers": true
  },
  "discard_user_data": {
    "discard_metadata": true,
    "discard_javascript": true,
    "discard_embedded_files": true,
    "discard_rich_media": true,
    "discard_accessibility_tags": false,
    "discard_private_application_data": true
  },
  "color_management": {
    "normalize_transparency": true,
    "force_rgb": true
  }
}

// type: string
password = OpenSesame123
▼ Show full

Response Example

200
Copied!
  {
    "status": "inprogress",
    "status_check_url": "https://www.zohoapis.com/pdfeditor/api/v1/pdf/compress/job/3f65c7592a741d98e46bf310cbe678f574a1d51fce306a8d9b6430217e538acd"
  }
                
▼ Show full

Rate Limits

Duration1 minute
Threshold50
Lock Period5 minutes 30 seconds
Duration1 hour
Threshold200
Lock Period15 minutes
Duration1 day
Threshold2000
Lock Period2 hours

Duration - Time window for the threshold.
Threshold - Number of API calls allowed within the specified duration.
Lock Period - Wait time before consecutive API requests.