From 0f05689a46b019b60ef478469cc29b813735b956 Mon Sep 17 00:00:00 2001 From: chinapandaman Date: Mon, 8 Jul 2024 19:34:31 -0500 Subject: [PATCH 1/2] PPF-684: using the right pattern --- PyPDFForm/constants.py | 3 +-- PyPDFForm/patterns.py | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/PyPDFForm/constants.py b/PyPDFForm/constants.py index 44914272..e994bca2 100644 --- a/PyPDFForm/constants.py +++ b/PyPDFForm/constants.py @@ -32,8 +32,6 @@ JS = "/JS" T = "/T" Rect = "/Rect" -Subtype = "/Subtype" -Widget = "/Widget" FT = "/FT" Parent = "/Parent" Ff = "/Ff" @@ -43,6 +41,7 @@ N = "/N" Sig = "/Sig" DA = "/DA" +DV = "/DV" Btn = "/Btn" MaxLen = "/MaxLen" Q = "/Q" diff --git a/PyPDFForm/patterns.py b/PyPDFForm/patterns.py index 08936da9..6ec900e0 100644 --- a/PyPDFForm/patterns.py +++ b/PyPDFForm/patterns.py @@ -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 @@ -49,7 +49,7 @@ ( ( {Parent: {FT: Btn}}, - {Parent: {Subtype: Widget}}, + {Parent: {DV: (Yes, Off)}}, {AS: (Yes, Off)}, ), Checkbox, From a037581ee3dd99ddbc852ea25bf551689ba98c46 Mon Sep 17 00:00:00 2001 From: chinapandaman Date: Mon, 8 Jul 2024 19:40:49 -0500 Subject: [PATCH 2/2] PPF-684: add test --- pdf_samples/scenario/issues/683.pdf | Bin 0 -> 2253 bytes pdf_samples/scenario/issues/683_expected.pdf | Bin 0 -> 1782 bytes tests/scenario/test_issues.py | 14 ++++++++++++++ 3 files changed, 14 insertions(+) create mode 100644 pdf_samples/scenario/issues/683.pdf create mode 100644 pdf_samples/scenario/issues/683_expected.pdf diff --git a/pdf_samples/scenario/issues/683.pdf b/pdf_samples/scenario/issues/683.pdf new file mode 100644 index 0000000000000000000000000000000000000000..9dd1f3e45db371c8fbb45c3e9d73516220304f3c GIT binary patch literal 2253 zcmY!laBZ^4=fsl4ocwey{eZ;u)M5n_ zpn@PS{jk)c;>`R!1${$hBUe){eaGaYe7F3fTm@6Gyqz6aYF-M+AVUKr6Wua%N>Ymy z^xbk2OHy4@lk-zjx%7Qf^U_N)6by~cxq#Y=ONvqxb9uQc=A@pnGS2g`*TVJ>E$fT*JWv|UG58kLUf0!L1E}?$(>BXl>U1yYftq=cM&O2YDlc`-q z%S-iI%-_>L&CTSL^78f0d|>%KQ^$@MIxseo$(0erZuMFrgYjQ>v3weuY9bC>0tS15qr2U^FsD zb=75meX|e`{bxoOjLm~Io@+h1RPL#J+Q*N#s642EkBw`##({zj#uKtvF&t`hQwW)I zD)fx#iPQxT`qpSmX3SvX5L0LFH4b5LGGJQ8_x#l3BCdy*%8f$|jDk5lnYB!=7>99q zK4dDa-C@#WD(bXpM~rjBGA4#e-iqh3#hWn^=?)_tAURT>v~Vy(OHO1311p2tY<_Vp z9s#9s)bt0;KEWlx`11qC8z_c~ih)_h)DnMW8H3VA5Ndq&2EX^0auoO*9(Req)g-b0 z-rL+{AC@jdH&usKx|5#SgdKS`cV~3apZC_)tDSP~zcAl9^XAR$ndbST7A7uQ6C5JC zMS{`{0zA8TqP!x0nF~xgpxffIDu|;sgqx#x$|skmD-)(GZEZtBYn-x1am4`AJaG*{uPc9#_=$?2Gw)U1A3ilQ9N{7t8&hh?f9c;p zc=~(F!F@S@KVE6~oiK~()m7Igp)bB4*<#Cnul9A^y6M`_>D3O~P8^J0LW8@4RoLQBsU<^#{LHYS5 z3Xr6%@0pjDuK-d7tYbZ06ryb`9Gy+w9F1Iz&5cZ54V^744INz^os7-g98H}~ES)Xv z6bLH;mU+-xDkwD#Xl`CgD!52AHUY|nD?}RtZ8rikU3?S_%?@)C{M3_OxJ= zgNVz;cakL{t{<3Hl8oMX99Sy3(ZuGP!S$PS)>U1N^}n=j=P$1??N*t39!8~*f`-MW z)4iI6=PYdFj#=0^`>)>9YjL0ZH>5mTf5&RaVdi-sn&j9d<}TagA)m>9U_1MKEWuk` Xl2}wyQ3Ujlp{0Q#m#V6(zZ(|-7<)~J literal 0 HcmV?d00001 diff --git a/pdf_samples/scenario/issues/683_expected.pdf b/pdf_samples/scenario/issues/683_expected.pdf new file mode 100644 index 0000000000000000000000000000000000000000..44bd8ccee81f66caeb50bad3f2335330e2022605 GIT binary patch literal 1782 zcmb_dU2fAr5H8|vPcbi*0I6QD|1F_PBx%wL+J+=j5fu_!XA@i!Z)$I=l(TRr9=HKq zgqe-gnwSTWa2r`WKi|xJGdtcN_WB3H3EBRSpWnVS0WRpPYxeRb~R0FnmPFVJZ-0G-CW!QD{6~l5!|Z)U{}!dbTuVk~+~j1%9T>rCc=Fq5`*O z9a$+`JU>>8J7w}rB2h)Ar+G04evuciiYng<7(bIsYwQ$u=x2}#^4JDpa4zzN!CB?~1#LZ06`U3 zrc`pt)?c%aANTh5p6)%NsjsE={8NDcnfsuW_y3-6`g^*V?2|twYX@(eZCz?0;)e4L zb38w_4;JRaLG$=H&DoOOFw%QLoH`q!(6b!u0q#dLzgf*6T3i!2a_2SffK;w4Lh1_<*5^gRwJCa z)=;G`)q<|H)Ces0oJ6F43~}N)9(rJMxQuqapZU*Wa%}_dswOWeDyH9_z;&r+$QX{S z`|v;%hJFY$c#sL)B=kV>D2uT#J2D|~Q}4sRS zHgh(m%onP(pQv&EMNz$cq_qM1wBQv#DP|hzYh=G7m64^f%!nWf*#7>}d7u3Pt}4h0 literal 0 HcmV?d00001 diff --git a/tests/scenario/test_issues.py b/tests/scenario/test_issues.py index 701f42bc..b66abced 100644 --- a/tests/scenario/test_issues.py +++ b/tests/scenario/test_issues.py @@ -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