Skip to main content

Compress and optimize a PDF

Compress and optimize PDF and PDF/A files with the Pdftools API.

POST
https://api.pdf-tools.com/v1-beta/operations/optimize

Headers

X-Api-KeystringREQUIRED
Add your Pdftools API key.
Content-TypestringOPTIONAL
Specify content type as JSON.
Accepted values: application/json

Request body

inputobjectREQUIRED
Input object that contains file ID.
fileIdstringREQUIRED
File ID that serves as an input for this operation.
optionsobjectOPTIONAL
An object that contains options for optimization operation.
profilestringOPTIONAL
Optimization profile to be used
Accepted values: archive, web
Default value: archive
passwordstringOPTIONAL
If the file is password-protected, enter the password so the file can be processed.

Optimization profiles
archiveThis profile optimizes the PDF structure for long-term archiving.
webThis profile optimizes the PDF structure so web-based viewers can handle the file.
For more information, see Optimization profiles section.

Example request body

{
"options": {
"password": "password",
"profile": "archive"
},
"input": {
"fileId": "80f408df-14e3-4469-b9af-6f63f1d73f36"
}
}

Example responses

{
"operationId": "069d5344-e920-4ddc-b575-fd5b3a0a4537",
"operationType": "optimize",
"operationStatus": "inProgress"
}

Optimization profiles

Compress and optimize your PDF (PDF and PDF/A) documents for a specific purpose using optimization profiles. An optimization profile determines the type of your PDF compression. You can choose from two optimization profiles:

Web
This profile optimizes the PDF so web-based viewers can handle the file.
Archive
This profile optimizes the PDF structure for long-term archiving.

Web profile

The web optimization profile optimizes the PDF structure and content so web browsers can render it correctly. The web profile performs the following actions:

  • Removes redundant and unnecessary data for electronic document exchange.
  • Downsamples, clips, and intelligently compresses images.
  • Merges and subsets fonts.
  • Linearizes the output.
  • Converts colors to RGB.

Archive profile

The Archive optimization profile makes the document suitable for long-term archiving. With archiving, the content of the PDF must remain visibly and structurally unchanged over time. The archive profile performs these actions:

  • Removes redundant and unnecessary data for archiving.
  • Intelligently compresses images.
  • Merges and subsets fonts.