3This script takes a PDF, and creates a new PDF with just the images
6It's working around a behaviour of the "Scan Document" feature in the
7iOS Notes app – when you export the scan as PDF, it adds large white
8borders around the images which is precisely what I don't want.
13from pypdf import PdfReader
16if __name__ == "__main__":
20 sys.exit(f"Usage: {__file__} <PATH>")
22 reader = PdfReader(path)
26 for page in reader.pages:
27 images.extend([im.image for im in page.images])
29 assert len(images) == len(reader.pages)
32 path, "PDF", resolution=100.0, save_all=True, append_images=images[1:]