From d2ccb3f29e8eca13ad8b0b05bf7a0482889ec23d Mon Sep 17 00:00:00 2001 From: jingeli Date: Wed, 24 Jan 2024 16:36:46 -0600 Subject: [PATCH 1/4] PPF-461: simple change --- PyPDFForm/core/font.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PyPDFForm/core/font.py b/PyPDFForm/core/font.py index 32f2846a..66f4b8ea 100644 --- a/PyPDFForm/core/font.py +++ b/PyPDFForm/core/font.py @@ -124,7 +124,7 @@ def get_text_field_font_size(widget: dict) -> Union[float, int]: if text_appearance: properties = text_appearance.split(" ") for i, val in enumerate(properties): - if val == FONT_SIZE_IDENTIFIER: + if val.startswith(FONT_SIZE_IDENTIFIER): return float(properties[i - 1]) return result @@ -144,7 +144,7 @@ def get_text_field_font_color( text_appearance = text_appearance.split(" ") for i, val in enumerate(text_appearance): - if val == FONT_COLOR_IDENTIFIER.replace(" ", ""): + if val.startswith(FONT_COLOR_IDENTIFIER.replace(" ", "")): result = ( float(text_appearance[i - 3]), float(text_appearance[i - 2]), From 18f2455beb71f80fe2d06feae7dbd00fc7fa3531 Mon Sep 17 00:00:00 2001 From: jingeli Date: Wed, 24 Jan 2024 16:40:57 -0600 Subject: [PATCH 2/4] PPF-461: add test case --- pdf_samples/scenario/tools/soda.pdf | Bin 0 -> 8732 bytes pdf_samples/scenario/tools/soda_expected.pdf | Bin 0 -> 3262 bytes tests/scenario/test_tools.py | 24 +++++++++++++++++++ 3 files changed, 24 insertions(+) create mode 100644 pdf_samples/scenario/tools/soda.pdf create mode 100644 pdf_samples/scenario/tools/soda_expected.pdf diff --git a/pdf_samples/scenario/tools/soda.pdf b/pdf_samples/scenario/tools/soda.pdf new file mode 100644 index 0000000000000000000000000000000000000000..15d4279d687b354c0ad2a5b9c86c7f169991130c GIT binary patch literal 8732 zcmeHNd0Z3M77ieY5e1Y*1$0aWMI@7%Nyx$?kVUWr5fBhW5|RO;WFZLx7EoL&OF@eZ zE>N|C;tp<4jktkQwWzovZah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HZ&}S!*Hn zEaMt*X4yU62z`sw!)>@fD3>Gb>KyiU_SQ)=Y{9oO-oaB%`khus0&23^(NA+5$7EOC z`mX8wjbc}Y)pY=(A&o|vrH+II#W6PRRCq|f>9wJM=v=$e8=mg)q{#uX6i{1ifZy%d z=pWhALu6_X)X*Qw@Fz)ToQQi8asNZqhf4ulzY#ME{jPAWJ%`T9o8i5Dqf}~XSui-c zslf{<-VnP%+;X(cCMRl+!%Pd6+oGC#FEU)mj`A3{f8JrU2P*;=U()7Z_ zKc9Qyox8*97k@lqo3ZlO^gX(j$DO#uM(P0rP71Na_&lpK%%W|gef5gK%haMP{kL2} zc)bU!-s)=CE6rfL3NY{Y1tDCYt|}%>?J+o)iHS14U^c1*BGG7(#Fg+&b&LRrgsy~O z3YWx{G0_;2*IYRoFxNLwFn6|qE+kBJ!@DFh62&qxR^#|p$K1G`q= z1_^*hL^<1)5W@8Xm{K_kkcng>iQt9@T;#$ihChq*?q#gyN{CS^WegBZNJtaXN+4)Tm)f2Q z1@Cps;^na#%|Zc)#-d{NP9KDb5ZF^58`t|6BnqNtR78PP3?}krm@w%BVOfu!e;|xK zz=RR4uu#B=!nS36tY>_gELJ4ot2+#0G8)5}MFv+Y6h$Smuu8Hk0Vcs@M-t=+BY`l) zAdwg(iX(}NUA&iOVufO?m>ejT#<~&$q(VM`Rs27EiuTe4IWZ6tgF@<|3+n;HPc9Y4 z3s89vMQV5f7p&I;tsPBU3wQt;r)_DQu_8AQi84kiNdj0XmoFDcT|o6bVD~jsplx-% z$4E}Ea9*0`j5ed@6J=P&(*Gk1a%hL>l1c&P56KDhk#R8LXC87JwNNO07~C~1&{!z zuAc(n4}S{4>DY0m&M|q_Zn^9=*gpK%`zTM?zPowhKPTdNg@$8$!_oakABHIJzUlu9 Dco+R2 literal 0 HcmV?d00001 diff --git a/pdf_samples/scenario/tools/soda_expected.pdf b/pdf_samples/scenario/tools/soda_expected.pdf new file mode 100644 index 0000000000000000000000000000000000000000..14c2b389f68750bcaa094d9c7d5e7ac206638136 GIT binary patch literal 3262 zcmb_f&2HO95WeqI%*B9Rz}z1$mn0Abh#admnl_G1AcwXGT3V?LB+{X%!s$!)&^Ksb zq%%v3rbyW_<5G|`T<*>{^UcpLPp;oi&y^?G$v^-8^*56spt$|SUcF*G`EqB0U#Ba( zW&EPp{{wB|h ziU>oyF3=L2RuvIosJG_yH zFV{lc?6n-j+JK+cGY!@>z&P4)$gE$G&E&fl{Ve5&-kHq6Hu-i zVfH#fyyyBkhByj0$xiQILU&j8Dux@wA~+ zC^9FMQA?%2$34bnZA(q;|7(FkDkzfvNW!0RaRdR8kZoA}k-6mQhIv^hYv;Zu*$-XJ zL(1JI^m-)80y-EUK+Wgl7Y z_FLgL00Hw2RXX-d+>&Y^r1mg9-Z4zM_K7R_*fY(zzyiPv+w?#{XK)oY9YT;8Y3v{o z7-hU5@_k4)oyPI2&>}hmthnU61H6GHL!fr#5yZe~FQV%217agNf>_tTiad1H`QGXu z3XdU*z=f(0h;@7fa6oC@TpXp;Tu5-ug%Z6(sj9ok%LyHa_i{Q%;t5QcVep>EC308y z2~5F5_L}zaV)nj@5a70Er~~!0;koJebp&MSXo4SbgnfX{%FR~aoSN@TyTqMdDkjdl^l+ZRy|%9pTl{b=#sg^2 z7UHNKtI9N6+tR&i++=@R;(*VJq5^tFm@$5pFAJcz3U~P4R%ux|wp6S&J2|<0KV|;` D1OWwv literal 0 HcmV?d00001 diff --git a/tests/scenario/test_tools.py b/tests/scenario/test_tools.py index 5686cceb..3683cb28 100644 --- a/tests/scenario/test_tools.py +++ b/tests/scenario/test_tools.py @@ -62,3 +62,27 @@ def test_filling_sejda_dropdown_pdf_form(tool_pdf_directory, request): request.config.results["stream"] = result.read() assert len(result.read()) == len(expected) assert result.read() == expected + + +def test_filling_soda_pdf_form(tool_pdf_directory, request): + expected_path = os.path.join(tool_pdf_directory, "soda_expected.pdf") + with open(expected_path, "rb+") as f: + expected = f.read() + result = PdfWrapper(os.path.join(tool_pdf_directory, "soda.pdf")).fill( + { + "Text1": "Helvetica 8", + "Text2": "Helvetica 12", + "Text3": "Helvetica 24", + "Text4": "Helvetica 8", + "Text5": "Helvetica 12", + "Text6": "Helvetica 24", + "Text7": "Helvetica 8", + "Text8": "Helvetica 12", + "Text9": "Helvetica 24", + } + ) + request.config.results["expected_path"] = expected_path + request.config.results["stream"] = result.read() + + assert len(result.read()) == len(expected) + assert result.read() == expected From 9a674f5e368fe5e3de1190c2132876d17db61d47 Mon Sep 17 00:00:00 2001 From: jingeli Date: Wed, 24 Jan 2024 16:43:55 -0600 Subject: [PATCH 3/4] PPF-461: bump version --- PyPDFForm/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PyPDFForm/__init__.py b/PyPDFForm/__init__.py index 1f8262f0..ef2b8dca 100644 --- a/PyPDFForm/__init__.py +++ b/PyPDFForm/__init__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- """Contains any object users might need.""" -__version__ = "1.4.4" +__version__ = "1.4.5" from .wrapper import PdfWrapper, PyPDFForm From db289874e996c5719c9ef482e7481f4e0c95704b Mon Sep 17 00:00:00 2001 From: jingeli Date: Wed, 24 Jan 2024 16:46:22 -0600 Subject: [PATCH 4/4] PPF-461: windows plz --- tests/scenario/test_tools.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/scenario/test_tools.py b/tests/scenario/test_tools.py index 3683cb28..88e6a695 100644 --- a/tests/scenario/test_tools.py +++ b/tests/scenario/test_tools.py @@ -84,5 +84,6 @@ def test_filling_soda_pdf_form(tool_pdf_directory, request): request.config.results["expected_path"] = expected_path request.config.results["stream"] = result.read() - assert len(result.read()) == len(expected) - assert result.read() == expected + if os.name != "nt": + assert len(result.read()) == len(expected) + assert result.read() == expected