PyPDFForm 3.3.2__py3-none-any.whl → 3.4.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of PyPDFForm might be problematic. Click here for more details.

PyPDFForm/__init__.py CHANGED
@@ -20,7 +20,7 @@ The library supports various PDF form features, including:
20
20
  PyPDFForm aims to simplify PDF form manipulation, making it accessible to developers of all skill levels.
21
21
  """
22
22
 
23
- __version__ = "3.3.2"
23
+ __version__ = "3.4.0"
24
24
 
25
25
  from .middleware.text import Text # exposing for setting global font attrs
26
26
  from .wrapper import PdfWrapper
PyPDFForm/hooks.py CHANGED
@@ -22,8 +22,8 @@ from pypdf.generic import (ArrayObject, DictionaryObject, FloatObject,
22
22
  NameObject, NumberObject, TextStringObject)
23
23
 
24
24
  from .constants import (COMB, DA, FONT_COLOR_IDENTIFIER, FONT_SIZE_IDENTIFIER,
25
- MULTILINE, READ_ONLY, REQUIRED, TU, Annots, Ff, Opt,
26
- Parent, Q, Rect)
25
+ MULTILINE, READ_ONLY, REQUIRED, TU, Annots, Ff, MaxLen,
26
+ Opt, Parent, Q, Rect)
27
27
  from .template import get_widget_key
28
28
  from .utils import stream_to_io
29
29
 
@@ -204,7 +204,19 @@ def update_text_field_multiline(annot: DictionaryObject, val: bool) -> None:
204
204
  val (bool): True to enable multiline, False to disable.
205
205
  """
206
206
  if val:
207
- annot[NameObject(Ff)] = NumberObject(int(annot[NameObject(Ff)]) | MULTILINE)
207
+ if Parent in annot and Ff not in annot:
208
+ annot[NameObject(Parent)][NameObject(Ff)] = NumberObject(
209
+ int(
210
+ annot[NameObject(Parent)][NameObject(Ff)]
211
+ if Ff in annot[NameObject(Parent)]
212
+ else 0
213
+ )
214
+ | MULTILINE
215
+ )
216
+ else:
217
+ annot[NameObject(Ff)] = NumberObject(
218
+ int(annot[NameObject(Ff)] if Ff in annot else 0) | MULTILINE
219
+ )
208
220
 
209
221
 
210
222
  def update_text_field_comb(annot: DictionaryObject, val: bool) -> None:
@@ -220,7 +232,33 @@ def update_text_field_comb(annot: DictionaryObject, val: bool) -> None:
220
232
  val (bool): True to enable comb, False to disable.
221
233
  """
222
234
  if val:
223
- annot[NameObject(Ff)] = NumberObject(int(annot[NameObject(Ff)]) | COMB)
235
+ if Parent in annot and Ff not in annot:
236
+ annot[NameObject(Parent)][NameObject(Ff)] = NumberObject(
237
+ int(
238
+ annot[NameObject(Parent)][NameObject(Ff)]
239
+ if Ff in annot[NameObject(Parent)]
240
+ else 0
241
+ )
242
+ | COMB
243
+ )
244
+ else:
245
+ annot[NameObject(Ff)] = NumberObject(
246
+ int(annot[NameObject(Ff)] if Ff in annot else 0) | COMB
247
+ )
248
+
249
+
250
+ def update_text_field_max_length(annot: DictionaryObject, val: int) -> None:
251
+ """
252
+ Updates the maximum length of a text field annotation.
253
+
254
+ This function sets the 'MaxLen' entry in the annotation dictionary, which
255
+ specifies the maximum number of characters that can be entered into the text field.
256
+
257
+ Args:
258
+ annot (DictionaryObject): The annotation dictionary for the text field.
259
+ val (int): The maximum number of characters allowed in the text field.
260
+ """
261
+ annot[NameObject(MaxLen)] = NumberObject(val)
224
262
 
225
263
 
226
264
  def update_check_radio_size(annot: DictionaryObject, val: float) -> None:
@@ -47,12 +47,16 @@ class Dropdown(Widget):
47
47
  self.SET_ATTR_TRIGGER_HOOK_MAP.update(
48
48
  {
49
49
  "font": "update_text_field_font",
50
+ "font_size": "update_text_field_font_size",
51
+ "font_color": "update_text_field_font_color",
50
52
  "choices": "update_dropdown_choices",
51
53
  }
52
54
  )
53
55
  super().__init__(name, value)
54
56
 
55
57
  self.font: str = None
58
+ self.font_size: float = None
59
+ self.font_color: tuple = None
56
60
  self.choices: Union[tuple, list] = None
57
61
 
58
62
  @property
@@ -51,6 +51,7 @@ class Text(Widget):
51
51
  "comb": "update_text_field_comb",
52
52
  "alignment": "update_text_field_alignment",
53
53
  "multiline": "update_text_field_multiline",
54
+ "max_length": "update_text_field_max_length",
54
55
  }
55
56
  )
56
57
  super().__init__(name, value)
@@ -61,7 +62,6 @@ class Text(Widget):
61
62
  self.comb: bool = None
62
63
  self.alignment: int = None
63
64
  self.multiline: bool = None
64
-
65
65
  self.max_length: int = None
66
66
 
67
67
  @property
PyPDFForm/template.py CHANGED
@@ -67,7 +67,8 @@ def build_widgets(
67
67
 
68
68
  if isinstance(_widget, Text):
69
69
  # mostly for schema for now
70
- _widget.max_length = get_text_field_max_length(widget)
70
+ # doesn't trigger hook
71
+ _widget.__dict__["max_length"] = get_text_field_max_length(widget)
71
72
  get_text_value(widget, _widget)
72
73
 
73
74
  if type(_widget) is Checkbox:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PyPDFForm
3
- Version: 3.3.2
3
+ Version: 3.4.0
4
4
  Summary: The Python library for PDF forms.
5
5
  Author: Jinge Li
6
6
  License-Expression: MIT
@@ -39,6 +39,9 @@ Requires-Dist: ruff; extra == "dev"
39
39
  Dynamic: license-file
40
40
 
41
41
  <p align="center"><img src="https://github.com/chinapandaman/PyPDFForm/raw/master/docs/img/logo.png"></p>
42
+ <p align="center">
43
+ <em>PDF Form Automation Simplified – Create, Merge, Style, and Fill Forms Programmatically.</em>
44
+ </p>
42
45
  <p align="center">
43
46
  <a href="https://pypi.org/project/PyPDFForm/"><img src="https://img.shields.io/pypi/v/pypdfform?label=version&color=magenta"></a>
44
47
  <a href="https://chinapandaman.github.io/PyPDFForm/"><img src="https://img.shields.io/github/v/release/chinapandaman/pypdfform?label=docs&color=cyan"></a>
@@ -1,24 +1,24 @@
1
- PyPDFForm/__init__.py,sha256=olMrWqJLpwsJgXbbe40RoJKd2czzRBTbGiud6m0olgA,925
1
+ PyPDFForm/__init__.py,sha256=SV7z1wBkJS8IDuoQvsqd9oYq5u8DtiRxg-zA86EWz2Y,925
2
2
  PyPDFForm/adapter.py,sha256=LBxHth0qJFB6rdByRJbsn4x0dftCOAolKVutZeFZm9E,2634
3
3
  PyPDFForm/constants.py,sha256=rxE9KyygdMkuPfpO6PRV6DasvIta0sZqadVPtX9Q_1U,2616
4
4
  PyPDFForm/coordinate.py,sha256=veYOlRyFKIvzLISYA_f-drNBiKOzFwr0EIFCaUAzGgo,4428
5
5
  PyPDFForm/filler.py,sha256=fqGIxT3FR3cWo3SMTDYud6Ocs9SZBmSpFv5yg1v19Wk,8450
6
6
  PyPDFForm/font.py,sha256=opZjAacsIRFcERXWegPXkOSpmnRrv4y_50yD0_BjWPM,10273
7
- PyPDFForm/hooks.py,sha256=E-KVXQGIcyJfCOJpIIf8otgZw1eQ6FqifBZ92kPze5o,14327
7
+ PyPDFForm/hooks.py,sha256=tW4VGAFZupSMhtHWoGsoljOciGT2yBBuoqNCuyGsKzM,15697
8
8
  PyPDFForm/image.py,sha256=P1P3Ejm8PVPQwpJFGAesjtwS5hxnVItrj75TE3WnFhM,4607
9
9
  PyPDFForm/patterns.py,sha256=HbTqzFllQ1cW3CqyNEfVh0qUMeFerbvOd0-HQnkifQQ,9765
10
- PyPDFForm/template.py,sha256=Jvx99HjLcEG8fZQeGSPZEFcITa4jauPSvenj3XgAf3c,11046
10
+ PyPDFForm/template.py,sha256=mmy4kVMe1plHxKtxFLbajBT1Mrv9g_oNCyzTUCWEyVw,11101
11
11
  PyPDFForm/utils.py,sha256=JavhAO4HmYRdujlsPXcZWGXTf7wDXzj4uU1XGRFsAaA,13257
12
12
  PyPDFForm/watermark.py,sha256=BJ8NeZLKf-MuJ2XusHiALaQpoqE8j6hHGbWcNhpjxN0,11299
13
13
  PyPDFForm/wrapper.py,sha256=KTFou6cXrHtLHVKwngoIr4Pwu4vOfjXY0cWRNNDlW0U,28866
14
14
  PyPDFForm/middleware/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
15
  PyPDFForm/middleware/base.py,sha256=ZmJFh3nSxj6PFjqBqsLih0pXKtcm1o-ctJVWn0v6bbI,3278
16
16
  PyPDFForm/middleware/checkbox.py,sha256=OCSZEFD8wQG_Y9qO7Os6VXTaxJCpkRYTxI4wDgG0GZc,1870
17
- PyPDFForm/middleware/dropdown.py,sha256=pfiMuAOr3ze7eboCB55UKaSR89oLNhvHGvNmDGWHVS0,3855
17
+ PyPDFForm/middleware/dropdown.py,sha256=oVIuzgjhOoPqZIXCqeXjxbXTkeCukVTTC9XtaSYhn_8,4052
18
18
  PyPDFForm/middleware/image.py,sha256=eKM7anU56jbaECnK6rq0jGsBRY3HW_fM86fgA3hq7xA,585
19
19
  PyPDFForm/middleware/radio.py,sha256=PuGDJ8RN1C-MkL9Jf14ABWYV67cN18R66dI4nR-03DU,2211
20
20
  PyPDFForm/middleware/signature.py,sha256=P6Mg9AZP5jML7GawsteVZjDaunKb9Yazu5iy0qF60bo,2432
21
- PyPDFForm/middleware/text.py,sha256=GLKuYvG4BUtNvj-3NkDeIlV1jcouhn7gAqfm9TBWduQ,3936
21
+ PyPDFForm/middleware/text.py,sha256=WLK6Ae9zT3uUu1AzcWUhR-hs5rm0z9Ydz-fL8Qu-44o,3997
22
22
  PyPDFForm/widgets/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
23
23
  PyPDFForm/widgets/base.py,sha256=iWsZ4LDtFVmrVUwvG_ORnH8fd614saI6wfNN4LrgOjQ,7230
24
24
  PyPDFForm/widgets/bedrock.py,sha256=j6beU04kaQzpAIFZHI5VJLaDT5RVAAa6LzkU1luJpN8,137660
@@ -28,8 +28,8 @@ PyPDFForm/widgets/image.py,sha256=aSD-3MEZFIRL7HYVuO6Os8irfSUOLHA_rHGkqcEIPPA,85
28
28
  PyPDFForm/widgets/radio.py,sha256=oFw8Um4g414UH93QJv6dZHRxpq0yuYog09B2W3eE8wo,2612
29
29
  PyPDFForm/widgets/signature.py,sha256=L4Et6pxtrEh7U-lnnLZrnvb_dKwGNpI6TZ11HCD0lvY,5147
30
30
  PyPDFForm/widgets/text.py,sha256=rmI0EYUTVf06AKsnxsVqewdTjt_mhBASEHyj5nAvYjE,1606
31
- pypdfform-3.3.2.dist-info/licenses/LICENSE,sha256=43awmYkI6opyTpg19me731iO1WfXZwViqb67oWtCsFY,1065
32
- pypdfform-3.3.2.dist-info/METADATA,sha256=Vp5jYPBKT8PMorIKzF6qoGByJIANBTShnB6a1_4omQY,4115
33
- pypdfform-3.3.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
34
- pypdfform-3.3.2.dist-info/top_level.txt,sha256=GQQKuWqPUjT9YZqwK95NlAQzxjwoQrsxQ8ureM8lWOY,10
35
- pypdfform-3.3.2.dist-info/RECORD,,
31
+ pypdfform-3.4.0.dist-info/licenses/LICENSE,sha256=43awmYkI6opyTpg19me731iO1WfXZwViqb67oWtCsFY,1065
32
+ pypdfform-3.4.0.dist-info/METADATA,sha256=uOBdsdX7B1B9QU8KoIIem38mkRDS38t31g22gB8IQzY,4242
33
+ pypdfform-3.4.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
34
+ pypdfform-3.4.0.dist-info/top_level.txt,sha256=GQQKuWqPUjT9YZqwK95NlAQzxjwoQrsxQ8ureM8lWOY,10
35
+ pypdfform-3.4.0.dist-info/RECORD,,