iLovePDF Developers
Log in Sign up

Compress PDF Guide
Learn to develop your own PDF compression software to automatically reduce the size of PDF files.

Remember that in order to use our Tool Guides, you need to have previous knowledge about the basics to processing a PDF with our REST API. We strongly recommend that you read the Processing a PDF guide before starting this one.

Basic compress

You may have seen how compress works in previous guides, it is very easy as you will see in this code:

Basic compress

You can add as many files as you want to compress. To process your files, simply choose the Compress PDF tool.

Advanced compress

You can choose between 3 compression levels. By default, these are set as the recommended compression levels in order to achieve the best ratio between file size and visual quality of the document.


Simply set the property compression_level with your desired level of compression like this:

Advanced compress

These are the following levels to choose from:

  • low compress the pdf with a minimal compression to gain some KB without quality loss.
  • recommended compress the pdf with the best mix of compression and quality standards.
  • extreme compress the pdf in order to reduce the maximum amount of data. This can cause quality loss and it is not recommended for PDFs where images and pictures are important.

The REST API combines several algorithms to try to compress all your files with the highest compression according to the chosen compression level.