diff --git a/pdf_samples/adobe_mode/dropdown/dropdown_one.pdf b/pdf_samples/adobe_mode/dropdown/dropdown_one.pdf new file mode 100644 index 00000000..c80d17af Binary files /dev/null and b/pdf_samples/adobe_mode/dropdown/dropdown_one.pdf differ diff --git a/pdf_samples/adobe_mode/issues/613_expected.pdf b/pdf_samples/adobe_mode/issues/613_expected.pdf new file mode 100644 index 00000000..71631280 Binary files /dev/null and b/pdf_samples/adobe_mode/issues/613_expected.pdf differ diff --git a/pdf_samples/scenario/issues/613.pdf b/pdf_samples/scenario/issues/613.pdf new file mode 100644 index 00000000..fd03ddee Binary files /dev/null and b/pdf_samples/scenario/issues/613.pdf differ diff --git a/tests/test_adobe_mode.py b/tests/test_adobe_mode.py index a8bc94ac..2051b715 100644 --- a/tests/test_adobe_mode.py +++ b/tests/test_adobe_mode.py @@ -5,6 +5,32 @@ from PyPDFForm import FormWrapper +def test_dropdown_one(sample_template_with_dropdown, pdf_samples, request): + expected_path = os.path.join(pdf_samples, "adobe_mode", "dropdown", "dropdown_one.pdf") + with open(expected_path, "rb+") as f: + obj = FormWrapper(sample_template_with_dropdown).fill( + { + "test_1": "test_1", + "test_2": "test_2", + "test_3": "test_3", + "check_1": True, + "check_2": True, + "check_3": True, + "radio_1": 1, + "dropdown_1": 0, + }, + adobe_mode=True, + ) + + request.config.results["expected_path"] = expected_path + request.config.results["stream"] = obj.read() + + expected = f.read() + + assert len(obj.read()) == len(expected) + assert obj.stream == expected + + def test_fill_sejda_complex(sejda_template_complex, pdf_samples, request): expected_path = os.path.join( pdf_samples, "adobe_mode", "paragraph", "sample_filled_sejda_complex.pdf" @@ -43,3 +69,25 @@ def test_fill_sejda_complex(sejda_template_complex, pdf_samples, request): assert len(obj.read()) == len(expected) assert obj.stream == expected + + +def test_issue_613(pdf_samples, request): + expected_path = os.path.join(pdf_samples, "adobe_mode", "issues", "613_expected.pdf") + with open(expected_path, "rb+") as f: + obj = FormWrapper( + os.path.join(pdf_samples, "scenario", "issues", "613.pdf") + ).fill( + { + "301 Full name": "John Smith", + "301 Address Street": "1234 road number 6", + }, + adobe_mode=True, + ) + + request.config.results["expected_path"] = expected_path + request.config.results["stream"] = obj.read() + + expected = f.read() + + assert len(obj.read()) == len(expected) + assert obj.stream == expected