Skip to content

Commit

Permalink
Merge pull request #566 from chinapandaman/PPF-565
Browse files Browse the repository at this point in the history
PPF-565: cleanup PPF-561
  • Loading branch information
chinapandaman authored Apr 14, 2024
2 parents b15c319 + a3539e9 commit 9b6421f
Show file tree
Hide file tree
Showing 22 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions PyPDFForm/patterns.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
Binary file added pdf_samples/scenario/issues/PPF-415-3-expected.pdf
Binary file not shown.
Binary file added pdf_samples/scenario/issues/PPF-415-expected.pdf
Binary file not shown.
Binary file modified pdf_samples/simple/dropdown/dropdown_four.pdf
Binary file not shown.
Binary file modified pdf_samples/simple/dropdown/dropdown_one.pdf
Binary file not shown.
Binary file modified pdf_samples/simple/dropdown/dropdown_three.pdf
Binary file not shown.
Binary file modified pdf_samples/simple/dropdown/dropdown_two.pdf
Binary file not shown.
Binary file modified pdf_samples/simple/dropdown/dropdown_two_simple.pdf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified pdf_samples/simple/paragraph/sample_filled_sejda_complex.pdf
Binary file not shown.
Binary file not shown.
Binary file modified pdf_samples/simple/sample_filled_radiobutton.pdf
Binary file not shown.
Binary file modified pdf_samples/simple/sample_filled_sejda.pdf
Binary file not shown.
Binary file modified pdf_samples/simple/scenario/tools/docfly_expected.pdf
Binary file not shown.
Binary file modified pdf_samples/simple/scenario/tools/pdf_escape_expected.pdf
Binary file not shown.
32 changes: 32 additions & 0 deletions tests/scenario/test_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
):
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 9b6421f

Please sign in to comment.