Python Compress PDF File: A Beginner Guide – Python Tutorial

By | August 29, 2020

In this tutorial, we will introduce how to compress a pdf file in python. The best way to compress a pdf file is use other application to compress pdf file using python. For example: Use python call ghostscript.

Python Compress PDF File

How to use python to compress pdf file?

We can use, You can download it in here.

This python script use python to call ghostscript to compress pdf file.

How to use to compress pdf file?

You can use compress() function to compress.

power can be:

quality = {
        0: '/default',
        1: '/prepress',
        2: '/printer',
        3: '/ebook',
        4: '/screen'


/prepress: 300dpi
/printer: 300dpi
/ebook: 150dpi
/screen: 72dpi

For example:

compress("source.pdf", 'compressed.pdf')

Leave a Reply

Your email address will not be published. Required fields are marked *