Stirling PDF icon

Stirling PDF

Merged API: Stirling PDF - Processing API + Stirling PDF - Management API + Stirling PDF - System API

Actions260

Misc → Optimize Pdf

AI-generated

Summary

Optimize PDF files by applying configurable compression levels and transformations to reduce filesize and enhance compatibility or viewing experience.

Inputs

  • fileInputBinaryProperty — Name of the binary property containing the PDF file data to be optimized if providing the file directly.
  • fileId — Identifier of a previously processed file on the server, used instead of direct file input for asynchronous operations.
  • optimizeLevel (required) — An integer from 1 to 9 representing the optimization level; higher levels apply greater compression but might degrade quality.
  • expectedOutputSize (required) — Target size for the optimized PDF output, specified as a string with units, such as '25KB' or '100MB'.
  • linearize (required) — Boolean flag to linearize the PDF for faster web viewing.
  • normalize (required) — Boolean flag to normalize PDF content to improve compatibility with various readers.
  • grayscale (required) — Boolean flag to convert the PDF content to grayscale, reducing color data.
  • lineArt — Optional boolean to convert images within the PDF to high-contrast line art using ImageMagick.
  • lineArtThreshold — Number (0-100) defining the threshold for the line art conversion process.
  • lineArtEdgeLevel — Integer (1-3) controlling edge detection strength during line art conversion, mapping to ImageMagick's edge radius.

Output shape

a single optimized PDF file in binary format

Output is the optimized PDF binary data; inputs can be direct binary file input or server-side file ID. Operation supports batching and can be configured with proxy and timeout settings.

Examples

Example 1: Provide a PDF file binary with 'fileInputBinaryProperty' set to 'data', specify optimization level 5, expect output around 25KB, enable grayscale and linearize settings to prepare the PDF for efficient web viewing with reduced color.

Input binary named 'data', optimizeLevel=5, expectedOutputSize='25KB', linearize=true, grayscale=true, other settings as false/default.

Links

Discussion