PyPDFForm 3.5.1__tar.gz → 3.5.3__tar.gz

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.

Files changed (52) hide show
  1. {pypdfform-3.5.1 → pypdfform-3.5.3}/PKG-INFO +1 -1
  2. {pypdfform-3.5.1 → pypdfform-3.5.3}/PyPDFForm/__init__.py +1 -1
  3. {pypdfform-3.5.1 → pypdfform-3.5.3}/PyPDFForm/hooks.py +19 -4
  4. {pypdfform-3.5.1 → pypdfform-3.5.3}/PyPDFForm/patterns.py +29 -2
  5. {pypdfform-3.5.1 → pypdfform-3.5.3}/PyPDFForm/template.py +3 -1
  6. {pypdfform-3.5.1 → pypdfform-3.5.3}/PyPDFForm.egg-info/PKG-INFO +1 -1
  7. {pypdfform-3.5.1 → pypdfform-3.5.3}/LICENSE +0 -0
  8. {pypdfform-3.5.1 → pypdfform-3.5.3}/PyPDFForm/adapter.py +0 -0
  9. {pypdfform-3.5.1 → pypdfform-3.5.3}/PyPDFForm/constants.py +0 -0
  10. {pypdfform-3.5.1 → pypdfform-3.5.3}/PyPDFForm/coordinate.py +0 -0
  11. {pypdfform-3.5.1 → pypdfform-3.5.3}/PyPDFForm/filler.py +0 -0
  12. {pypdfform-3.5.1 → pypdfform-3.5.3}/PyPDFForm/font.py +0 -0
  13. {pypdfform-3.5.1 → pypdfform-3.5.3}/PyPDFForm/image.py +0 -0
  14. {pypdfform-3.5.1 → pypdfform-3.5.3}/PyPDFForm/middleware/__init__.py +0 -0
  15. {pypdfform-3.5.1 → pypdfform-3.5.3}/PyPDFForm/middleware/base.py +0 -0
  16. {pypdfform-3.5.1 → pypdfform-3.5.3}/PyPDFForm/middleware/checkbox.py +0 -0
  17. {pypdfform-3.5.1 → pypdfform-3.5.3}/PyPDFForm/middleware/dropdown.py +0 -0
  18. {pypdfform-3.5.1 → pypdfform-3.5.3}/PyPDFForm/middleware/image.py +0 -0
  19. {pypdfform-3.5.1 → pypdfform-3.5.3}/PyPDFForm/middleware/radio.py +0 -0
  20. {pypdfform-3.5.1 → pypdfform-3.5.3}/PyPDFForm/middleware/signature.py +0 -0
  21. {pypdfform-3.5.1 → pypdfform-3.5.3}/PyPDFForm/middleware/text.py +0 -0
  22. {pypdfform-3.5.1 → pypdfform-3.5.3}/PyPDFForm/utils.py +0 -0
  23. {pypdfform-3.5.1 → pypdfform-3.5.3}/PyPDFForm/watermark.py +0 -0
  24. {pypdfform-3.5.1 → pypdfform-3.5.3}/PyPDFForm/widgets/__init__.py +0 -0
  25. {pypdfform-3.5.1 → pypdfform-3.5.3}/PyPDFForm/widgets/base.py +0 -0
  26. {pypdfform-3.5.1 → pypdfform-3.5.3}/PyPDFForm/widgets/bedrock.py +0 -0
  27. {pypdfform-3.5.1 → pypdfform-3.5.3}/PyPDFForm/widgets/checkbox.py +0 -0
  28. {pypdfform-3.5.1 → pypdfform-3.5.3}/PyPDFForm/widgets/dropdown.py +0 -0
  29. {pypdfform-3.5.1 → pypdfform-3.5.3}/PyPDFForm/widgets/image.py +0 -0
  30. {pypdfform-3.5.1 → pypdfform-3.5.3}/PyPDFForm/widgets/radio.py +0 -0
  31. {pypdfform-3.5.1 → pypdfform-3.5.3}/PyPDFForm/widgets/signature.py +0 -0
  32. {pypdfform-3.5.1 → pypdfform-3.5.3}/PyPDFForm/widgets/text.py +0 -0
  33. {pypdfform-3.5.1 → pypdfform-3.5.3}/PyPDFForm/wrapper.py +0 -0
  34. {pypdfform-3.5.1 → pypdfform-3.5.3}/PyPDFForm.egg-info/SOURCES.txt +0 -0
  35. {pypdfform-3.5.1 → pypdfform-3.5.3}/PyPDFForm.egg-info/dependency_links.txt +0 -0
  36. {pypdfform-3.5.1 → pypdfform-3.5.3}/PyPDFForm.egg-info/requires.txt +0 -0
  37. {pypdfform-3.5.1 → pypdfform-3.5.3}/PyPDFForm.egg-info/top_level.txt +0 -0
  38. {pypdfform-3.5.1 → pypdfform-3.5.3}/README.md +0 -0
  39. {pypdfform-3.5.1 → pypdfform-3.5.3}/pyproject.toml +0 -0
  40. {pypdfform-3.5.1 → pypdfform-3.5.3}/setup.cfg +0 -0
  41. {pypdfform-3.5.1 → pypdfform-3.5.3}/tests/test_adobe_mode.py +0 -0
  42. {pypdfform-3.5.1 → pypdfform-3.5.3}/tests/test_create_widget.py +0 -0
  43. {pypdfform-3.5.1 → pypdfform-3.5.3}/tests/test_dropdown.py +0 -0
  44. {pypdfform-3.5.1 → pypdfform-3.5.3}/tests/test_extract_values.py +0 -0
  45. {pypdfform-3.5.1 → pypdfform-3.5.3}/tests/test_fill_max_length_text_field.py +0 -0
  46. {pypdfform-3.5.1 → pypdfform-3.5.3}/tests/test_fill_method.py +0 -0
  47. {pypdfform-3.5.1 → pypdfform-3.5.3}/tests/test_font_widths.py +0 -0
  48. {pypdfform-3.5.1 → pypdfform-3.5.3}/tests/test_functional.py +0 -0
  49. {pypdfform-3.5.1 → pypdfform-3.5.3}/tests/test_paragraph.py +0 -0
  50. {pypdfform-3.5.1 → pypdfform-3.5.3}/tests/test_signature.py +0 -0
  51. {pypdfform-3.5.1 → pypdfform-3.5.3}/tests/test_use_full_widget_name.py +0 -0
  52. {pypdfform-3.5.1 → pypdfform-3.5.3}/tests/test_widget_attr_trigger.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PyPDFForm
3
- Version: 3.5.1
3
+ Version: 3.5.3
4
4
  Summary: The Python library for PDF forms.
5
5
  Author: Jinge Li
6
6
  License-Expression: MIT
@@ -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.5.1"
23
+ __version__ = "3.5.3"
24
24
 
25
25
  from .middleware.text import Text # exposing for setting global font attrs
26
26
  from .widgets import Fields
@@ -83,19 +83,31 @@ def update_text_field_font(annot: DictionaryObject, val: str) -> None:
83
83
  Updates the font of a text field annotation.
84
84
 
85
85
  This function modifies the appearance string (DA) in the annotation dictionary
86
- to change the font used for the text field.
86
+ to change the font used for the text field. It ensures that the provided font
87
+ name is a proper PDF font by checking if it starts with a slash "/".
88
+ The function then correctly identifies and updates the font in the appearance
89
+ stream by locating the existing font identifier (which also starts with a slash).
87
90
 
88
91
  Args:
89
92
  annot (DictionaryObject): The annotation dictionary for the text field.
90
- val (str): The new font name to use for the text field.
93
+ val (str): The new font name to use for the text field. Must start with "/".
91
94
  """
95
+ if not val.startswith("/"):
96
+ return
92
97
  if Parent in annot and DA not in annot:
93
98
  text_appearance = annot[Parent][DA]
94
99
  else:
95
100
  text_appearance = annot[DA]
96
101
 
97
102
  text_appearance = text_appearance.split(" ")
98
- text_appearance[0] = val
103
+
104
+ index_to_update = 0
105
+ for i, each in enumerate(text_appearance):
106
+ if each.startswith("/"):
107
+ index_to_update = i
108
+ break
109
+
110
+ text_appearance[index_to_update] = val
99
111
  new_text_appearance = " ".join(text_appearance)
100
112
 
101
113
  if Parent in annot and DA not in annot:
@@ -204,7 +216,10 @@ def update_text_field_multiline(annot: DictionaryObject, val: bool) -> None:
204
216
  val (bool): True to enable multiline, False to disable.
205
217
  """
206
218
  if val:
207
- if Parent in annot and Ff not in annot:
219
+ # TODO: investigate this more
220
+ # may need to change everywhere how feature flags precedence work
221
+ # https://github.com/chinapandaman/PyPDFForm/issues/1162#issuecomment-3326233842
222
+ if Parent in annot and Ff in annot[Parent]:
208
223
  annot[NameObject(Parent)][NameObject(Ff)] = NumberObject(
209
224
  int(
210
225
  annot[NameObject(Parent)][NameObject(Ff)]
@@ -17,8 +17,9 @@ from typing import Union
17
17
  from pypdf.generic import (ArrayObject, DictionaryObject, NameObject,
18
18
  NumberObject, TextStringObject)
19
19
 
20
- from .constants import (AP, AS, DV, FT, IMAGE_FIELD_IDENTIFIER, JS, SLASH, TU,
21
- A, Btn, Ch, I, N, Off, Opt, Parent, Sig, T, Tx, V, Yes)
20
+ from .constants import (AP, AS, DV, FT, IMAGE_FIELD_IDENTIFIER, JS, MULTILINE,
21
+ SLASH, TU, A, Btn, Ch, Ff, I, N, Off, Opt, Parent, Sig,
22
+ T, Tx, V, Yes)
22
23
  from .middleware.checkbox import Checkbox
23
24
  from .middleware.dropdown import Dropdown
24
25
  from .middleware.image import Image
@@ -277,3 +278,29 @@ def update_annotation_name(annot: DictionaryObject, val: str) -> None:
277
278
  annot[NameObject(Parent)][NameObject(T)] = TextStringObject(val)
278
279
  else:
279
280
  annot[NameObject(T)] = TextStringObject(val)
281
+
282
+
283
+ def get_text_field_multiline(annot: DictionaryObject) -> bool:
284
+ """
285
+ Checks if a text field annotation is multiline.
286
+
287
+ This function inspects the 'Ff' (field flags) entry of the text annotation
288
+ dictionary (or its parent if it's a child annotation) to determine if the
289
+ Multiline flag is set.
290
+
291
+ Args:
292
+ annot (DictionaryObject): The text annotation dictionary.
293
+
294
+ Returns:
295
+ bool: True if the text field is multiline, False otherwise.
296
+ """
297
+ if Parent in annot and Ff not in annot:
298
+ return bool(
299
+ int(
300
+ annot[NameObject(Parent)][NameObject(Ff)]
301
+ if Ff in annot[NameObject(Parent)]
302
+ else 0
303
+ )
304
+ & MULTILINE
305
+ )
306
+ return bool(int(annot[NameObject(Ff)] if Ff in annot else 0) & MULTILINE)
@@ -28,7 +28,8 @@ from .middleware.text import Text
28
28
  from .patterns import (DROPDOWN_CHOICE_PATTERNS, WIDGET_DESCRIPTION_PATTERNS,
29
29
  WIDGET_KEY_PATTERNS, WIDGET_TYPE_PATTERNS,
30
30
  get_checkbox_value, get_dropdown_value, get_radio_value,
31
- get_text_value, update_annotation_name)
31
+ get_text_field_multiline, get_text_value,
32
+ update_annotation_name)
32
33
  from .utils import extract_widget_property, find_pattern_match, stream_to_io
33
34
 
34
35
 
@@ -69,6 +70,7 @@ def build_widgets(
69
70
  # mostly for schema for now
70
71
  # doesn't trigger hook
71
72
  _widget.__dict__["max_length"] = get_text_field_max_length(widget)
73
+ _widget.__dict__["multiline"] = get_text_field_multiline(widget)
72
74
  get_text_value(widget, _widget)
73
75
 
74
76
  if type(_widget) is Checkbox:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PyPDFForm
3
- Version: 3.5.1
3
+ Version: 3.5.3
4
4
  Summary: The Python library for PDF forms.
5
5
  Author: Jinge Li
6
6
  License-Expression: MIT
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes