Created
August 3, 2024 21:24
-
-
Save danielfeitopin/82a34c954650590a906f3dc6faacdc0c to your computer and use it in GitHub Desktop.
Script to extract pages from a PDF.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pypdf import PdfReader, PdfWriter | |
PDF_IN = '' # CHANGE | |
PDF_OUT = '' # CHANGE | |
PAGES = [] # Starting at 1 | |
reader = PdfReader(PDF_IN) | |
writer = PdfWriter() | |
for page in PAGES: | |
writer.add_page(reader.pages[page - 1]) | |
with open(PDF_OUT, "wb") as f: | |
writer.write(f) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment