From f8e01e744f3d2686f4463ebfccb977fe06e47817 Mon Sep 17 00:00:00 2001 From: Aryama Srivastav Date: Sat, 7 Mar 2026 22:18:11 +0530 Subject: [PATCH 1/2] Update input.txt with UC Vaccine Declination Statement for Sarah Johnson. --- src/inputs/input.txt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/inputs/input.txt b/src/inputs/input.txt index faa55cd..e68385c 100644 --- a/src/inputs/input.txt +++ b/src/inputs/input.txt @@ -1 +1,10 @@ -Officer Voldemort here, at an incident reported at 456 Oak Street. Two victims, Mark Smith and Jane Doe. Medical aid rendered for minor lacerations. Handed off to Sheriff's Deputy Alvarez. End of transmission. +UC Vaccine Declination Statement + +Name/SID: Sarah Johnson, SID 4527891 +Job Title: Research Scientist +Department: Microbiology +Phone Number: 831-555-0142 +Email: sjohnson@ucsc.edu +Date: 03/15/2026 + +Signature: ________________________ \ No newline at end of file From a00a0ad95ece78f721d51d6b89c7270348e80929 Mon Sep 17 00:00:00 2001 From: Aryama Srivastav Date: Fri, 13 Mar 2026 11:21:02 +0530 Subject: [PATCH 2/2] fix: preserve field index across multi-page PDF fill --- src/filler.py | 2 +- src/test/test_filler_multi_page.py | 53 ++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 src/test/test_filler_multi_page.py diff --git a/src/filler.py b/src/filler.py index e31e535..89a387e 100644 --- a/src/filler.py +++ b/src/filler.py @@ -28,6 +28,7 @@ def fill_form(self, pdf_form: str, llm: LLM): # Read PDF pdf = PdfReader(pdf_form) + i = 0 # Loop through pages for page in pdf.pages: if page.Annots: @@ -35,7 +36,6 @@ def fill_form(self, pdf_form: str, llm: LLM): page.Annots, key=lambda a: (-float(a.Rect[1]), float(a.Rect[0])) ) - i = 0 for annot in sorted_annots: if annot.Subtype == "/Widget" and annot.T: if i < len(answers_list): diff --git a/src/test/test_filler_multi_page.py b/src/test/test_filler_multi_page.py new file mode 100644 index 0000000..f250864 --- /dev/null +++ b/src/test/test_filler_multi_page.py @@ -0,0 +1,53 @@ +from src.filler import Filler + + +class DummyAnnot: + def __init__(self, x, y): + self.Subtype = "/Widget" + self.T = "(field)" + self.Rect = [str(x), str(y), str(x + 10), str(y + 10)] + self.V = None + self.AP = "placeholder" + + +class DummyPage: + def __init__(self, annots): + self.Annots = annots + + +class DummyPdf: + def __init__(self, pages): + self.pages = pages + + +class DummyWriter: + def write(self, output_pdf, pdf): + return None + + +class DummyLLM: + def __init__(self, data): + self._data = data + + def main_loop(self): + return self + + def get_data(self): + return self._data + + +def test_fill_form_keeps_value_index_across_pages(monkeypatch): + page_one_annot = DummyAnnot(0, 100) + page_two_annot = DummyAnnot(0, 100) + dummy_pdf = DummyPdf([DummyPage([page_one_annot]), DummyPage([page_two_annot])]) + + monkeypatch.setattr("src.filler.PdfReader", lambda *_args, **_kwargs: dummy_pdf) + monkeypatch.setattr("src.filler.PdfWriter", lambda: DummyWriter()) + + llm = DummyLLM({"field1": "value-1", "field2": "value-2"}) + filler = Filler() + + filler.fill_form("form.pdf", llm) + + assert page_one_annot.V == "value-1" + assert page_two_annot.V == "value-2"