Reduce PDF Size

There are multiple ways to reduce the size of a given PDF file. The easiest one is to remove content (e.g. images) or pages.

Remove images

import PyPDF2

writer = PyPDF2.PdfWriter()

writer.remove_images()

with open("out.pdf", "wb") as f:
writer.write(f)


Compression

import PyPDF2