from PyPDF2 import PdfReader, PdfWriter

def split_pdf(input_pdf, output_folder):
    """Splits a PDF into individual pages."""
    reader = PdfReader(input_pdf)
    for i, page in enumerate(reader.pages):
        writer = PdfWriter()
        writer.add_page(page)
        output_path = f"{output_folder}/page_{i+1}.pdf"
        with open(output_path, "wb") as output_pdf:
            writer.write(output_pdf)
        print(f"Page {i+1} saved as {output_path}")

# Ask the user for input PDF file path and output folder
input_pdf = input("Please enter the full path of the PDF file to split: ")
output_folder = input("Please enter the folder where the pages will be saved: ")

# Usage
split_pdf(input_pdf, output_folder)
