[Python] Checking for Missing Signatures in Uploaded PDF Using Python

Discussão em 'Python' iniciado por Stack, Julho 1, 2025.

  1. Stack

    Stack Membro Participativo

    I am new to Python and I want to check whether the uploaded PDF file contains all the required signatures. If any are missing, it should return "Signature missing." I’ve tried reading the file, but I’m not sure how to implement this check.

    try:
    images = convert_from_path(pdf_path, dpi=200)
    print(f"[DEBUG] PDF has {len(images)} pages")

    if len(images) >= 1:
    target_page_index = 0 # TEMP: Try first page (adjust as needed)
    page_image = images[target_page_index]
    page_image.save("debug_page0.png")

    # Debug test crop
    test_box = (100, 100, 300, 200)
    crop_test = page_image.crop(test_box)
    crop_test.save("debug_crop_test.png")

    # Real signature areas — update these after checking debug image
    inspector_sig_area = (510, 590, 650, 630)
    reviewer_sig_area = (510, 640, 650, 680)

    inspector_crop = page_image.crop(inspector_sig_area)
    reviewer_crop = page_image.crop(reviewer_sig_area)

    inspector_crop.save("debug_inspector_box.png")
    reviewer_crop.save("debug_reviewer_box.png")

    fields["Inspector Signed"] = is_signature_box_filled(inspector_crop)
    fields["Reviewer Signed"] = is_signature_box_filled(reviewer_crop)
    else:
    print("[!] No pages found in PDF!")

    except Exception as e:
    print(f"[!] Signature box check failed: {e}")


    [​IMG]

    Continue reading...

Compartilhe esta Página