from PyPDF2 import PdfReader, PdfWriter

def add_watermark(input_pdf, watermark_pdf, output_pdf):
    """Adds a watermark from `watermark_pdf` to all pages of `input_pdf`."""
    reader = PdfReader(input_pdf)
    writer = PdfWriter()
    
    watermark_reader = PdfReader(watermark_pdf)
    watermark_page = watermark_reader.pages[0]  # Assume the watermark is on the first page

    for page in reader.pages:
        page.merge_page(watermark_page)  # Overlay watermark
        writer.add_page(page)

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

    print(f"Watermarked PDF saved at {output_pdf}")
