diff --git a/PyPDFForm/patterns.py b/PyPDFForm/patterns.py index 6ac6cd2e..ebdbe5db 100644 --- a/PyPDFForm/patterns.py +++ b/PyPDFForm/patterns.py @@ -96,6 +96,7 @@ def simple_update_radio_value(annot: DictionaryObject) -> None: for each in annot[AP][D]: # noqa if str(each) != Off: annot[NameObject(AS)] = NameObject(each) + annot[NameObject(Parent)][NameObject(V)] = NameObject(each) # noqa break diff --git a/pdf_samples/scenario/issues/PPF-415-3-expected.pdf b/pdf_samples/scenario/issues/PPF-415-3-expected.pdf new file mode 100644 index 00000000..7b5ade0e Binary files /dev/null and b/pdf_samples/scenario/issues/PPF-415-3-expected.pdf differ diff --git a/pdf_samples/scenario/issues/PPF-415-expected.pdf b/pdf_samples/scenario/issues/PPF-415-expected.pdf new file mode 100644 index 00000000..13febc44 Binary files /dev/null and b/pdf_samples/scenario/issues/PPF-415-expected.pdf differ diff --git a/pdf_samples/simple/dropdown/dropdown_four.pdf b/pdf_samples/simple/dropdown/dropdown_four.pdf index 3ed825f3..cab46039 100644 Binary files a/pdf_samples/simple/dropdown/dropdown_four.pdf and b/pdf_samples/simple/dropdown/dropdown_four.pdf differ diff --git a/pdf_samples/simple/dropdown/dropdown_one.pdf b/pdf_samples/simple/dropdown/dropdown_one.pdf index a53b0c1d..92bcab77 100644 Binary files a/pdf_samples/simple/dropdown/dropdown_one.pdf and b/pdf_samples/simple/dropdown/dropdown_one.pdf differ diff --git a/pdf_samples/simple/dropdown/dropdown_three.pdf b/pdf_samples/simple/dropdown/dropdown_three.pdf index a2b92691..1ac6fe35 100644 Binary files a/pdf_samples/simple/dropdown/dropdown_three.pdf and b/pdf_samples/simple/dropdown/dropdown_three.pdf differ diff --git a/pdf_samples/simple/dropdown/dropdown_two.pdf b/pdf_samples/simple/dropdown/dropdown_two.pdf index 8801899c..e281ce63 100644 Binary files a/pdf_samples/simple/dropdown/dropdown_two.pdf and b/pdf_samples/simple/dropdown/dropdown_two.pdf differ diff --git a/pdf_samples/simple/dropdown/dropdown_two_simple.pdf b/pdf_samples/simple/dropdown/dropdown_two_simple.pdf index 22eabe29..783204e2 100644 Binary files a/pdf_samples/simple/dropdown/dropdown_two_simple.pdf and b/pdf_samples/simple/dropdown/dropdown_two_simple.pdf differ diff --git a/pdf_samples/simple/max_length_text_field_related/comb_text_field_all_chars.pdf b/pdf_samples/simple/max_length_text_field_related/comb_text_field_all_chars.pdf index 1912916f..34e05aa2 100644 Binary files a/pdf_samples/simple/max_length_text_field_related/comb_text_field_all_chars.pdf and b/pdf_samples/simple/max_length_text_field_related/comb_text_field_all_chars.pdf differ diff --git a/pdf_samples/simple/max_length_text_field_related/comb_text_field_even_chars.pdf b/pdf_samples/simple/max_length_text_field_related/comb_text_field_even_chars.pdf index 88421ecf..51e9e9db 100644 Binary files a/pdf_samples/simple/max_length_text_field_related/comb_text_field_even_chars.pdf and b/pdf_samples/simple/max_length_text_field_related/comb_text_field_even_chars.pdf differ diff --git a/pdf_samples/simple/max_length_text_field_related/comb_text_field_even_chars_right_aligned.pdf b/pdf_samples/simple/max_length_text_field_related/comb_text_field_even_chars_right_aligned.pdf index ddbcdece..e06ac926 100644 Binary files a/pdf_samples/simple/max_length_text_field_related/comb_text_field_even_chars_right_aligned.pdf and b/pdf_samples/simple/max_length_text_field_related/comb_text_field_even_chars_right_aligned.pdf differ diff --git a/pdf_samples/simple/max_length_text_field_related/comb_text_field_odd_chars.pdf b/pdf_samples/simple/max_length_text_field_related/comb_text_field_odd_chars.pdf index 62bf7c12..09868857 100644 Binary files a/pdf_samples/simple/max_length_text_field_related/comb_text_field_odd_chars.pdf and b/pdf_samples/simple/max_length_text_field_related/comb_text_field_odd_chars.pdf differ diff --git a/pdf_samples/simple/max_length_text_field_related/max_length_text_field_all_chars.pdf b/pdf_samples/simple/max_length_text_field_related/max_length_text_field_all_chars.pdf index 17331e52..1d4b7d0d 100644 Binary files a/pdf_samples/simple/max_length_text_field_related/max_length_text_field_all_chars.pdf and b/pdf_samples/simple/max_length_text_field_related/max_length_text_field_all_chars.pdf differ diff --git a/pdf_samples/simple/max_length_text_field_related/max_length_text_field_even_chars.pdf b/pdf_samples/simple/max_length_text_field_related/max_length_text_field_even_chars.pdf index 0a171c73..abd042aa 100644 Binary files a/pdf_samples/simple/max_length_text_field_related/max_length_text_field_even_chars.pdf and b/pdf_samples/simple/max_length_text_field_related/max_length_text_field_even_chars.pdf differ diff --git a/pdf_samples/simple/max_length_text_field_related/max_length_text_field_odd_chars.pdf b/pdf_samples/simple/max_length_text_field_related/max_length_text_field_odd_chars.pdf index b5f85db6..012a0fad 100644 Binary files a/pdf_samples/simple/max_length_text_field_related/max_length_text_field_odd_chars.pdf and b/pdf_samples/simple/max_length_text_field_related/max_length_text_field_odd_chars.pdf differ diff --git a/pdf_samples/simple/paragraph/sample_filled_sejda_complex.pdf b/pdf_samples/simple/paragraph/sample_filled_sejda_complex.pdf index 4137174f..7d651897 100644 Binary files a/pdf_samples/simple/paragraph/sample_filled_sejda_complex.pdf and b/pdf_samples/simple/paragraph/sample_filled_sejda_complex.pdf differ diff --git a/pdf_samples/simple/paragraph/sample_filled_sejda_complex_flatten.pdf b/pdf_samples/simple/paragraph/sample_filled_sejda_complex_flatten.pdf index 5e58aaa2..28056e43 100644 Binary files a/pdf_samples/simple/paragraph/sample_filled_sejda_complex_flatten.pdf and b/pdf_samples/simple/paragraph/sample_filled_sejda_complex_flatten.pdf differ diff --git a/pdf_samples/simple/sample_filled_radiobutton.pdf b/pdf_samples/simple/sample_filled_radiobutton.pdf index df948457..374e5b85 100644 Binary files a/pdf_samples/simple/sample_filled_radiobutton.pdf and b/pdf_samples/simple/sample_filled_radiobutton.pdf differ diff --git a/pdf_samples/simple/sample_filled_sejda.pdf b/pdf_samples/simple/sample_filled_sejda.pdf index b67bacde..822dd239 100644 Binary files a/pdf_samples/simple/sample_filled_sejda.pdf and b/pdf_samples/simple/sample_filled_sejda.pdf differ diff --git a/pdf_samples/simple/scenario/tools/docfly_expected.pdf b/pdf_samples/simple/scenario/tools/docfly_expected.pdf index e87dc45f..53944ff2 100644 Binary files a/pdf_samples/simple/scenario/tools/docfly_expected.pdf and b/pdf_samples/simple/scenario/tools/docfly_expected.pdf differ diff --git a/pdf_samples/simple/scenario/tools/pdf_escape_expected.pdf b/pdf_samples/simple/scenario/tools/pdf_escape_expected.pdf index 67cb91a0..581e8f3b 100644 Binary files a/pdf_samples/simple/scenario/tools/pdf_escape_expected.pdf and b/pdf_samples/simple/scenario/tools/pdf_escape_expected.pdf differ diff --git a/tests/scenario/test_issues.py b/tests/scenario/test_issues.py index 924025c5..7916f085 100644 --- a/tests/scenario/test_issues.py +++ b/tests/scenario/test_issues.py @@ -42,6 +42,22 @@ def test_pdf_form_with_central_aligned_text_fields_void(issue_pdf_directory): assert PdfWrapper(os.path.join(issue_pdf_directory, "PPF-285.pdf")).fill({}).read() +def test_pdf_form_with_paragraph_fields_new_line_symbol_text( + issue_pdf_directory, request +): + obj = PdfWrapper(os.path.join(issue_pdf_directory, "PPF-415.pdf")).fill( + {"Address": "Mr John Smith\n132, My Street\nKingston, New York 12401"} + ) + + expected_path = os.path.join(issue_pdf_directory, "PPF-415-expected.pdf") + request.config.results["expected_path"] = expected_path + request.config.results["stream"] = obj.read() + with open(expected_path, "rb+") as f: + expected = f.read() + if os.name != "nt": + assert abs(len(obj.read()) - len(expected)) <= 1 + + def test_pdf_form_with_paragraph_fields_new_line_symbol_text_overflow( issue_pdf_directory, request ): @@ -80,6 +96,22 @@ def test_521(issue_pdf_directory, request): assert obj.stream == expected +def test_pdf_form_with_paragraph_fields_new_line_symbol_short_text( + issue_pdf_directory, request +): + obj = PdfWrapper(os.path.join(issue_pdf_directory, "PPF-415.pdf")).fill( + {"Address": "J Smith\n132 A St\nNYC, NY 12401"} + ) + + expected_path = os.path.join(issue_pdf_directory, "PPF-415-3-expected.pdf") + request.config.results["expected_path"] = expected_path + request.config.results["stream"] = obj.read() + with open(expected_path, "rb+") as f: + expected = f.read() + if os.name != "nt": + assert abs(len(obj.read()) - len(expected)) <= 1 + + def test_encrypted_edit_pdf_form(issue_pdf_directory, request): obj = PdfWrapper(os.path.join(issue_pdf_directory, "437.pdf")) obj = obj.fill(obj.sample_data)