How to Compress PDF Files in Python To run this: pip3 install -r requirements.txt To compress bert-paper.pdf file: $ python pdf_compressor.py bert-paper.pdf bert-paper-min.pdf This will spawn a new compressed PDF file under the name bert-paper-min.pdf.