PyPDFForm 1.4.24__tar.gz → 1.4.26__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 (46) hide show
  1. {pypdfform-1.4.24 → pypdfform-1.4.26}/PKG-INFO +1 -1
  2. {pypdfform-1.4.24 → pypdfform-1.4.26}/PyPDFForm/__init__.py +1 -1
  3. {pypdfform-1.4.24 → pypdfform-1.4.26}/PyPDFForm/constants.py +1 -1
  4. {pypdfform-1.4.24 → pypdfform-1.4.26}/PyPDFForm/patterns.py +3 -3
  5. {pypdfform-1.4.24 → pypdfform-1.4.26}/PyPDFForm/template.py +22 -2
  6. {pypdfform-1.4.24 → pypdfform-1.4.26}/PyPDFForm.egg-info/PKG-INFO +1 -1
  7. {pypdfform-1.4.24 → pypdfform-1.4.26}/LICENSE +0 -0
  8. {pypdfform-1.4.24 → pypdfform-1.4.26}/PyPDFForm/adapter.py +0 -0
  9. {pypdfform-1.4.24 → pypdfform-1.4.26}/PyPDFForm/coordinate.py +0 -0
  10. {pypdfform-1.4.24 → pypdfform-1.4.26}/PyPDFForm/filler.py +0 -0
  11. {pypdfform-1.4.24 → pypdfform-1.4.26}/PyPDFForm/font.py +0 -0
  12. {pypdfform-1.4.24 → pypdfform-1.4.26}/PyPDFForm/image.py +0 -0
  13. {pypdfform-1.4.24 → pypdfform-1.4.26}/PyPDFForm/middleware/__init__.py +0 -0
  14. {pypdfform-1.4.24 → pypdfform-1.4.26}/PyPDFForm/middleware/base.py +0 -0
  15. {pypdfform-1.4.24 → pypdfform-1.4.26}/PyPDFForm/middleware/checkbox.py +0 -0
  16. {pypdfform-1.4.24 → pypdfform-1.4.26}/PyPDFForm/middleware/dropdown.py +0 -0
  17. {pypdfform-1.4.24 → pypdfform-1.4.26}/PyPDFForm/middleware/image.py +0 -0
  18. {pypdfform-1.4.24 → pypdfform-1.4.26}/PyPDFForm/middleware/radio.py +0 -0
  19. {pypdfform-1.4.24 → pypdfform-1.4.26}/PyPDFForm/middleware/signature.py +0 -0
  20. {pypdfform-1.4.24 → pypdfform-1.4.26}/PyPDFForm/middleware/text.py +0 -0
  21. {pypdfform-1.4.24 → pypdfform-1.4.26}/PyPDFForm/utils.py +0 -0
  22. {pypdfform-1.4.24 → pypdfform-1.4.26}/PyPDFForm/watermark.py +0 -0
  23. {pypdfform-1.4.24 → pypdfform-1.4.26}/PyPDFForm/widgets/__init__.py +0 -0
  24. {pypdfform-1.4.24 → pypdfform-1.4.26}/PyPDFForm/widgets/base.py +0 -0
  25. {pypdfform-1.4.24 → pypdfform-1.4.26}/PyPDFForm/widgets/checkbox.py +0 -0
  26. {pypdfform-1.4.24 → pypdfform-1.4.26}/PyPDFForm/widgets/dropdown.py +0 -0
  27. {pypdfform-1.4.24 → pypdfform-1.4.26}/PyPDFForm/widgets/text.py +0 -0
  28. {pypdfform-1.4.24 → pypdfform-1.4.26}/PyPDFForm/wrapper.py +0 -0
  29. {pypdfform-1.4.24 → pypdfform-1.4.26}/PyPDFForm.egg-info/SOURCES.txt +0 -0
  30. {pypdfform-1.4.24 → pypdfform-1.4.26}/PyPDFForm.egg-info/dependency_links.txt +0 -0
  31. {pypdfform-1.4.24 → pypdfform-1.4.26}/PyPDFForm.egg-info/requires.txt +0 -0
  32. {pypdfform-1.4.24 → pypdfform-1.4.26}/PyPDFForm.egg-info/top_level.txt +0 -0
  33. {pypdfform-1.4.24 → pypdfform-1.4.26}/README.md +0 -0
  34. {pypdfform-1.4.24 → pypdfform-1.4.26}/setup.cfg +0 -0
  35. {pypdfform-1.4.24 → pypdfform-1.4.26}/setup.py +0 -0
  36. {pypdfform-1.4.24 → pypdfform-1.4.26}/tests/test_create_widget.py +0 -0
  37. {pypdfform-1.4.24 → pypdfform-1.4.26}/tests/test_dropdown.py +0 -0
  38. {pypdfform-1.4.24 → pypdfform-1.4.26}/tests/test_dropdown_simple.py +0 -0
  39. {pypdfform-1.4.24 → pypdfform-1.4.26}/tests/test_fill_max_length_text_field.py +0 -0
  40. {pypdfform-1.4.24 → pypdfform-1.4.26}/tests/test_fill_max_length_text_field_simple.py +0 -0
  41. {pypdfform-1.4.24 → pypdfform-1.4.26}/tests/test_functional.py +0 -0
  42. {pypdfform-1.4.24 → pypdfform-1.4.26}/tests/test_functional_simple.py +0 -0
  43. {pypdfform-1.4.24 → pypdfform-1.4.26}/tests/test_paragraph.py +0 -0
  44. {pypdfform-1.4.24 → pypdfform-1.4.26}/tests/test_paragraph_simple.py +0 -0
  45. {pypdfform-1.4.24 → pypdfform-1.4.26}/tests/test_preview.py +0 -0
  46. {pypdfform-1.4.24 → pypdfform-1.4.26}/tests/test_signature.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PyPDFForm
3
- Version: 1.4.24
3
+ Version: 1.4.26
4
4
  Summary: The Python library for PDF forms.
5
5
  Home-page: https://github.com/chinapandaman/PyPDFForm
6
6
  Author: Jinge Li
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  """Contains any object users might need."""
3
3
 
4
- __version__ = "1.4.24"
4
+ __version__ = "1.4.26"
5
5
 
6
6
  from .wrapper import FormWrapper, PdfWrapper, PyPDFForm
@@ -40,7 +40,7 @@ Ff = "/Ff"
40
40
  Tx = "/Tx"
41
41
  V = "/V"
42
42
  AP = "/AP"
43
- D = "/D"
43
+ N = "/N"
44
44
  Sig = "/Sig"
45
45
  DA = "/DA"
46
46
  Btn = "/Btn"
@@ -5,7 +5,7 @@ from pypdf.generic import (DictionaryObject, NameObject, NumberObject,
5
5
  TextStringObject)
6
6
 
7
7
  from .constants import (AP, AS, CA, DA, FT, IMAGE_FIELD_IDENTIFIER, JS, MK,
8
- READ_ONLY, A, Btn, Ch, D, Ff, Off, Opt, Parent, Q, Sig,
8
+ READ_ONLY, A, Btn, Ch, Ff, N, Off, Opt, Parent, Q, Sig,
9
9
  Subtype, T, Tx, V, Widget, Yes)
10
10
  from .middleware.checkbox import Checkbox
11
11
  from .middleware.dropdown import Dropdown
@@ -96,7 +96,7 @@ BUTTON_STYLE_PATTERNS = [
96
96
  def simple_update_checkbox_value(annot: DictionaryObject, check: bool = False) -> None:
97
97
  """Patterns to update values for checkbox annotations."""
98
98
 
99
- for each in annot[AP][D]: # noqa
99
+ for each in annot[AP][N]: # noqa
100
100
  if (check and str(each) != Off) or (not check and str(each) == Off):
101
101
  annot[NameObject(AS)] = NameObject(each)
102
102
  annot[NameObject(V)] = NameObject(each)
@@ -106,7 +106,7 @@ def simple_update_checkbox_value(annot: DictionaryObject, check: bool = False) -
106
106
  def simple_update_radio_value(annot: DictionaryObject) -> None:
107
107
  """Patterns to update values for radio annotations."""
108
108
 
109
- for each in annot[AP][D]: # noqa
109
+ for each in annot[AP][N]: # noqa
110
110
  if str(each) != Off:
111
111
  annot[NameObject(AS)] = NameObject(each)
112
112
  annot[NameObject(Parent)][NameObject(V)] = NameObject(each) # noqa
@@ -134,7 +134,9 @@ def update_text_field_attributes(
134
134
  if not is_paragraph
135
135
  else DEFAULT_FONT_SIZE
136
136
  )
137
- should_adjust_font_size = is_paragraph and not template_font_size
137
+ should_adjust_font_size = (
138
+ not template_font_size and widgets[key].max_length is None
139
+ )
138
140
  if widgets[key].font_color is None:
139
141
  widgets[key].font_color = get_text_field_font_color(_widget)
140
142
  if is_paragraph and widgets[key].text_wrap_length is None:
@@ -142,8 +144,11 @@ def update_text_field_attributes(
142
144
  widgets[key].text_wrap_length = get_paragraph_auto_wrap_length(
143
145
  widgets[key]
144
146
  )
145
- if widgets[key].value and should_adjust_font_size:
147
+ if widgets[key].value and should_adjust_font_size:
148
+ if is_paragraph:
146
149
  adjust_paragraph_font_size(_widget, widgets[key])
150
+ else:
151
+ adjust_text_field_font_size(_widget, widgets[key])
147
152
 
148
153
 
149
154
  @lru_cache()
@@ -413,3 +418,18 @@ def adjust_paragraph_font_size(widget: dict, widget_middleware: Text) -> None:
413
418
  ):
414
419
  widget_middleware.font_size -= FONT_SIZE_REDUCE_STEP
415
420
  widget_middleware.text_lines = get_paragraph_lines(widget, widget_middleware)
421
+
422
+
423
+ def adjust_text_field_font_size(widget: dict, widget_middleware: Text) -> None:
424
+ """Reduces the font size of a text field until texts fits."""
425
+
426
+ width = abs(float(widget[Rect][0]) - float(widget[Rect][2]))
427
+
428
+ while (
429
+ widget_middleware.font_size > FONT_SIZE_REDUCE_STEP
430
+ and stringWidth(
431
+ widget_middleware.value, widget_middleware.font, widget_middleware.font_size
432
+ )
433
+ > width
434
+ ):
435
+ widget_middleware.font_size -= FONT_SIZE_REDUCE_STEP
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PyPDFForm
3
- Version: 1.4.24
3
+ Version: 1.4.26
4
4
  Summary: The Python library for PDF forms.
5
5
  Home-page: https://github.com/chinapandaman/PyPDFForm
6
6
  Author: Jinge Li
File without changes
File without changes
File without changes
File without changes
File without changes