Skip to content

Commit

Permalink
Merge pull request #685 from chinapandaman/PPF-684
Browse files Browse the repository at this point in the history
PPF-684: fix the pattern that detects sejda checkbox
  • Loading branch information
chinapandaman authored Jul 9, 2024
2 parents cd04014 + a037581 commit c58a42b
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 4 deletions.
3 changes: 1 addition & 2 deletions PyPDFForm/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
JS = "/JS"
T = "/T"
Rect = "/Rect"
Subtype = "/Subtype"
Widget = "/Widget"
FT = "/FT"
Parent = "/Parent"
Ff = "/Ff"
Expand All @@ -43,6 +41,7 @@
N = "/N"
Sig = "/Sig"
DA = "/DA"
DV = "/DV"
Btn = "/Btn"
MaxLen = "/MaxLen"
Q = "/Q"
Expand Down
4 changes: 2 additions & 2 deletions PyPDFForm/patterns.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from .constants import (AP, AS, CA, DA, FT, IMAGE_FIELD_IDENTIFIER, JS, MK,
READ_ONLY, A, Btn, Ch, Ff, N, Off, Opt, Parent, Q, Sig,
Subtype, T, Tx, V, Widget, Yes)
DV, T, Tx, V, Yes)
from .middleware.checkbox import Checkbox
from .middleware.dropdown import Dropdown
from .middleware.image import Image
Expand Down Expand Up @@ -49,7 +49,7 @@
(
(
{Parent: {FT: Btn}},
{Parent: {Subtype: Widget}},
{Parent: {DV: (Yes, Off)}},
{AS: (Yes, Off)},
),
Checkbox,
Expand Down
Binary file added pdf_samples/scenario/issues/683.pdf
Binary file not shown.
Binary file added pdf_samples/scenario/issues/683_expected.pdf
Binary file not shown.
14 changes: 14 additions & 0 deletions tests/scenario/test_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,3 +212,17 @@ def test_ppf_627_fill_3(issue_pdf_directory, request):
expected = f.read()
assert len(obj.read()) == len(expected)
assert obj.read() == expected


def test_sejda_checkbox(issue_pdf_directory, request):
obj = PdfWrapper(os.path.join(issue_pdf_directory, "683.pdf")).fill(
{"test_checkbox": True}
)

expected_path = os.path.join(issue_pdf_directory, "683_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()
assert len(obj.read()) == len(expected)
assert obj.read() == expected

0 comments on commit c58a42b

Please sign in to comment.