from pypdf import PdfReader, PdfWriter
import sys

def split_pdf(input_path, start_page, end_page, output_path):
    reader = PdfReader(input_path)
    writer = PdfWriter()
    # 1-indexed to 0-indexed
    start_idx = start_page - 1
    end_idx = end_page
    for i in range(start_idx, end_idx):
        writer.add_page(reader.pages[i])
    with open(output_path, "wb") as f:
        writer.write(f)

split_pdf("/opt/openclaw/.openclaw/workspace/Dieu_gi_that_su_co_gia_tri_Myanmar_Drive.pdf", 102, 111, "/opt/openclaw/.openclaw/workspace/pages_102_111.pdf")
