PyPDFForm 1.4.17__tar.gz → 1.4.19__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.17 → pypdfform-1.4.19}/PKG-INFO +1 -2
  2. {PyPDFForm-1.4.17 → pypdfform-1.4.19}/PyPDFForm/__init__.py +1 -1
  3. {PyPDFForm-1.4.17 → pypdfform-1.4.19}/PyPDFForm/filler.py +5 -5
  4. {PyPDFForm-1.4.17 → pypdfform-1.4.19}/PyPDFForm/patterns.py +4 -2
  5. pypdfform-1.4.19/PyPDFForm/widgets/checkbox.py +19 -0
  6. {PyPDFForm-1.4.17 → pypdfform-1.4.19}/PyPDFForm/widgets/dropdown.py +6 -1
  7. {PyPDFForm-1.4.17 → pypdfform-1.4.19}/PyPDFForm/widgets/text.py +4 -1
  8. {PyPDFForm-1.4.17 → pypdfform-1.4.19}/PyPDFForm.egg-info/PKG-INFO +1 -2
  9. {PyPDFForm-1.4.17 → pypdfform-1.4.19}/README.md +0 -1
  10. {PyPDFForm-1.4.17 → pypdfform-1.4.19}/tests/test_create_widget.py +18 -1
  11. {PyPDFForm-1.4.17 → pypdfform-1.4.19}/tests/test_functional_simple.py +24 -0
  12. PyPDFForm-1.4.17/PyPDFForm/widgets/checkbox.py +0 -11
  13. {PyPDFForm-1.4.17 → pypdfform-1.4.19}/LICENSE +0 -0
  14. {PyPDFForm-1.4.17 → pypdfform-1.4.19}/PyPDFForm/adapter.py +0 -0
  15. {PyPDFForm-1.4.17 → pypdfform-1.4.19}/PyPDFForm/constants.py +0 -0
  16. {PyPDFForm-1.4.17 → pypdfform-1.4.19}/PyPDFForm/coordinate.py +0 -0
  17. {PyPDFForm-1.4.17 → pypdfform-1.4.19}/PyPDFForm/font.py +0 -0
  18. {PyPDFForm-1.4.17 → pypdfform-1.4.19}/PyPDFForm/image.py +0 -0
  19. {PyPDFForm-1.4.17 → pypdfform-1.4.19}/PyPDFForm/middleware/__init__.py +0 -0
  20. {PyPDFForm-1.4.17 → pypdfform-1.4.19}/PyPDFForm/middleware/base.py +0 -0
  21. {PyPDFForm-1.4.17 → pypdfform-1.4.19}/PyPDFForm/middleware/checkbox.py +0 -0
  22. {PyPDFForm-1.4.17 → pypdfform-1.4.19}/PyPDFForm/middleware/dropdown.py +0 -0
  23. {PyPDFForm-1.4.17 → pypdfform-1.4.19}/PyPDFForm/middleware/radio.py +0 -0
  24. {PyPDFForm-1.4.17 → pypdfform-1.4.19}/PyPDFForm/middleware/signature.py +0 -0
  25. {PyPDFForm-1.4.17 → pypdfform-1.4.19}/PyPDFForm/middleware/text.py +0 -0
  26. {PyPDFForm-1.4.17 → pypdfform-1.4.19}/PyPDFForm/template.py +0 -0
  27. {PyPDFForm-1.4.17 → pypdfform-1.4.19}/PyPDFForm/utils.py +0 -0
  28. {PyPDFForm-1.4.17 → pypdfform-1.4.19}/PyPDFForm/watermark.py +0 -0
  29. {PyPDFForm-1.4.17 → pypdfform-1.4.19}/PyPDFForm/widgets/__init__.py +0 -0
  30. {PyPDFForm-1.4.17 → pypdfform-1.4.19}/PyPDFForm/widgets/base.py +0 -0
  31. {PyPDFForm-1.4.17 → pypdfform-1.4.19}/PyPDFForm/wrapper.py +0 -0
  32. {PyPDFForm-1.4.17 → pypdfform-1.4.19}/PyPDFForm.egg-info/SOURCES.txt +0 -0
  33. {PyPDFForm-1.4.17 → pypdfform-1.4.19}/PyPDFForm.egg-info/dependency_links.txt +0 -0
  34. {PyPDFForm-1.4.17 → pypdfform-1.4.19}/PyPDFForm.egg-info/requires.txt +0 -0
  35. {PyPDFForm-1.4.17 → pypdfform-1.4.19}/PyPDFForm.egg-info/top_level.txt +0 -0
  36. {PyPDFForm-1.4.17 → pypdfform-1.4.19}/setup.cfg +0 -0
  37. {PyPDFForm-1.4.17 → pypdfform-1.4.19}/setup.py +0 -0
  38. {PyPDFForm-1.4.17 → pypdfform-1.4.19}/tests/test_dropdown.py +0 -0
  39. {PyPDFForm-1.4.17 → pypdfform-1.4.19}/tests/test_dropdown_simple.py +0 -0
  40. {PyPDFForm-1.4.17 → pypdfform-1.4.19}/tests/test_fill_max_length_text_field.py +0 -0
  41. {PyPDFForm-1.4.17 → pypdfform-1.4.19}/tests/test_fill_max_length_text_field_simple.py +0 -0
  42. {PyPDFForm-1.4.17 → pypdfform-1.4.19}/tests/test_functional.py +0 -0
  43. {PyPDFForm-1.4.17 → pypdfform-1.4.19}/tests/test_paragraph.py +0 -0
  44. {PyPDFForm-1.4.17 → pypdfform-1.4.19}/tests/test_paragraph_simple.py +0 -0
  45. {PyPDFForm-1.4.17 → pypdfform-1.4.19}/tests/test_preview.py +0 -0
  46. {PyPDFForm-1.4.17 → pypdfform-1.4.19}/tests/test_signature.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PyPDFForm
3
- Version: 1.4.17
3
+ Version: 1.4.19
4
4
  Summary: The Python library for PDF forms.
5
5
  Home-page: https://github.com/chinapandaman/PyPDFForm
6
6
  Author: Jinge Li
@@ -29,7 +29,6 @@ Requires-Dist: reportlab
29
29
  <p align="center">
30
30
  <a href="https://github.com/chinapandaman/PyPDFForm/actions/workflows/python-black-isort.yml/badge.svg"><img src="https://github.com/chinapandaman/PyPDFForm/actions/workflows/python-black-isort.yml/badge.svg"></a>
31
31
  <a href="https://github.com/chinapandaman/PyPDFForm/actions/workflows/python-package.yml/badge.svg"><img src="https://github.com/chinapandaman/PyPDFForm/actions/workflows/python-package.yml/badge.svg"></a>
32
- <a href="https://codecov.io/gh/chinapandaman/PyPDFForm"><img src="https://codecov.io/gh/chinapandaman/PyPDFForm/branch/master/graph/badge.svg?token=CSRLN14IFE"></a>
33
32
  <a href="https://github.com/chinapandaman/PyPDFForm/actions/workflows/python-publish.yml/badge.svg"><img src="https://github.com/chinapandaman/PyPDFForm/actions/workflows/python-publish.yml/badge.svg"></a>
34
33
  <a href="https://pepy.tech/project/pypdfform"><img src="https://static.pepy.tech/personalized-badge/pypdfform?period=total&units=international_system&left_color=black&right_color=blue&left_text=Downloads"></a>
35
34
  <a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-orange.svg"></a>
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  """Contains any object users might need."""
3
3
 
4
- __version__ = "1.4.17"
4
+ __version__ = "1.4.19"
5
5
 
6
6
  from .wrapper import FormWrapper, PdfWrapper, PyPDFForm
@@ -148,20 +148,20 @@ def simple_fill(
148
148
  key = get_widget_key(annot.get_object())
149
149
 
150
150
  widget = widgets.get(key)
151
- if widget is None:
151
+ if widget is None or widget.value is None:
152
152
  continue
153
153
 
154
- if type(widget) is Checkbox and widget.value is True:
155
- simple_update_checkbox_value(annot)
154
+ if type(widget) is Checkbox:
155
+ simple_update_checkbox_value(annot, widget.value)
156
156
  elif isinstance(widget, Radio):
157
157
  if key not in radio_button_tracker:
158
158
  radio_button_tracker[key] = 0
159
159
  radio_button_tracker[key] += 1
160
160
  if widget.value == radio_button_tracker[key] - 1:
161
161
  simple_update_radio_value(annot)
162
- elif isinstance(widget, Dropdown) and widget.value is not None:
162
+ elif isinstance(widget, Dropdown):
163
163
  simple_update_dropdown_value(annot, widget)
164
- elif isinstance(widget, Text) and widget.value:
164
+ elif isinstance(widget, Text):
165
165
  simple_update_text_value(annot, widget)
166
166
 
167
167
  if flatten:
@@ -80,12 +80,13 @@ BUTTON_STYLE_PATTERNS = [
80
80
  ]
81
81
 
82
82
 
83
- def simple_update_checkbox_value(annot: DictionaryObject) -> None:
83
+ def simple_update_checkbox_value(annot: DictionaryObject, check: bool = False) -> None:
84
84
  """Patterns to update values for checkbox annotations."""
85
85
 
86
86
  for each in annot[AP][D]: # noqa
87
- if str(each) != Off:
87
+ if (check and str(each) != Off) or (not check and str(each) == Off):
88
88
  annot[NameObject(AS)] = NameObject(each)
89
+ annot[NameObject(V)] = NameObject(each)
89
90
  break
90
91
 
91
92
 
@@ -95,6 +96,7 @@ def simple_update_radio_value(annot: DictionaryObject) -> None:
95
96
  for each in annot[AP][D]: # noqa
96
97
  if str(each) != Off:
97
98
  annot[NameObject(AS)] = NameObject(each)
99
+ annot[NameObject(Parent)][NameObject(V)] = NameObject(each) # noqa
98
100
  break
99
101
 
100
102
 
@@ -0,0 +1,19 @@
1
+ # -*- coding: utf-8 -*-
2
+ """Contains checkbox widget to create."""
3
+
4
+ from .base import Widget
5
+
6
+
7
+ class CheckBoxWidget(Widget):
8
+ """Checkbox widget to create."""
9
+
10
+ USER_PARAMS = [
11
+ ("size", "size"),
12
+ ("button_style", "buttonStyle"),
13
+ ("tick_color", "textColor"),
14
+ ("bg_color", "fillColor"),
15
+ ("border_color", "borderColor"),
16
+ ("border_width", "borderWidth"),
17
+ ]
18
+ COLOR_PARAMS = ["tick_color", "bg_color", "border_color"]
19
+ ACRO_FORM_FUNC = "checkbox"
@@ -7,6 +7,8 @@ from .base import Widget
7
7
  class DropdownWidget(Widget):
8
8
  """Dropdown widget to create."""
9
9
 
10
+ # pylint: disable=R0801
11
+
10
12
  USER_PARAMS = [
11
13
  ("width", "width"),
12
14
  ("height", "height"),
@@ -14,8 +16,11 @@ class DropdownWidget(Widget):
14
16
  ("font", "fontName"),
15
17
  ("font_size", "fontSize"),
16
18
  ("font_color", "textColor"),
19
+ ("bg_color", "fillColor"),
20
+ ("border_color", "borderColor"),
21
+ ("border_width", "borderWidth"),
17
22
  ]
18
- COLOR_PARAMS = ["font_color"]
23
+ COLOR_PARAMS = ["font_color", "bg_color", "border_color"]
19
24
  ACRO_FORM_FUNC = "_textfield"
20
25
 
21
26
  def __init__(
@@ -14,7 +14,10 @@ class TextWidget(Widget):
14
14
  ("font", "fontName"),
15
15
  ("font_size", "fontSize"),
16
16
  ("font_color", "textColor"),
17
+ ("bg_color", "fillColor"),
18
+ ("border_color", "borderColor"),
19
+ ("border_width", "borderWidth"),
17
20
  ]
18
- COLOR_PARAMS = ["font_color"]
21
+ COLOR_PARAMS = ["font_color", "bg_color", "border_color"]
19
22
  NONE_DEFAULTS = ["max_length"]
20
23
  ACRO_FORM_FUNC = "textfield"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PyPDFForm
3
- Version: 1.4.17
3
+ Version: 1.4.19
4
4
  Summary: The Python library for PDF forms.
5
5
  Home-page: https://github.com/chinapandaman/PyPDFForm
6
6
  Author: Jinge Li
@@ -29,7 +29,6 @@ Requires-Dist: reportlab
29
29
  <p align="center">
30
30
  <a href="https://github.com/chinapandaman/PyPDFForm/actions/workflows/python-black-isort.yml/badge.svg"><img src="https://github.com/chinapandaman/PyPDFForm/actions/workflows/python-black-isort.yml/badge.svg"></a>
31
31
  <a href="https://github.com/chinapandaman/PyPDFForm/actions/workflows/python-package.yml/badge.svg"><img src="https://github.com/chinapandaman/PyPDFForm/actions/workflows/python-package.yml/badge.svg"></a>
32
- <a href="https://codecov.io/gh/chinapandaman/PyPDFForm"><img src="https://codecov.io/gh/chinapandaman/PyPDFForm/branch/master/graph/badge.svg?token=CSRLN14IFE"></a>
33
32
  <a href="https://github.com/chinapandaman/PyPDFForm/actions/workflows/python-publish.yml/badge.svg"><img src="https://github.com/chinapandaman/PyPDFForm/actions/workflows/python-publish.yml/badge.svg"></a>
34
33
  <a href="https://pepy.tech/project/pypdfform"><img src="https://static.pepy.tech/personalized-badge/pypdfform?period=total&units=international_system&left_color=black&right_color=blue&left_text=Downloads"></a>
35
34
  <a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-orange.svg"></a>
@@ -2,7 +2,6 @@
2
2
  <p align="center">
3
3
  <a href="https://github.com/chinapandaman/PyPDFForm/actions/workflows/python-black-isort.yml/badge.svg"><img src="https://github.com/chinapandaman/PyPDFForm/actions/workflows/python-black-isort.yml/badge.svg"></a>
4
4
  <a href="https://github.com/chinapandaman/PyPDFForm/actions/workflows/python-package.yml/badge.svg"><img src="https://github.com/chinapandaman/PyPDFForm/actions/workflows/python-package.yml/badge.svg"></a>
5
- <a href="https://codecov.io/gh/chinapandaman/PyPDFForm"><img src="https://codecov.io/gh/chinapandaman/PyPDFForm/branch/master/graph/badge.svg?token=CSRLN14IFE"></a>
6
5
  <a href="https://github.com/chinapandaman/PyPDFForm/actions/workflows/python-publish.yml/badge.svg"><img src="https://github.com/chinapandaman/PyPDFForm/actions/workflows/python-publish.yml/badge.svg"></a>
7
6
  <a href="https://pepy.tech/project/pypdfform"><img src="https://static.pepy.tech/personalized-badge/pypdfform?period=total&units=international_system&left_color=black&right_color=blue&left_text=Downloads"></a>
8
7
  <a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-orange.svg"></a>
@@ -68,8 +68,19 @@ def test_create_checkbox_complex(template_stream, pdf_samples, request):
68
68
  expected_path = os.path.join(pdf_samples, "widget", "create_checkbox_complex.pdf")
69
69
  with open(expected_path, "rb+") as f:
70
70
  obj = PdfWrapper(template_stream).create_widget(
71
- "checkbox", "foo", 1, 100, 100, size=100
71
+ "checkbox",
72
+ "foo",
73
+ 1,
74
+ 100,
75
+ 100,
76
+ size=100,
77
+ button_style="check",
78
+ tick_color=(0, 1, 0),
79
+ bg_color=(0, 0, 1),
80
+ border_color=(1, 0, 0),
81
+ border_width=5,
72
82
  )
83
+
73
84
  assert obj.schema["properties"]["foo"]["type"] == "boolean"
74
85
 
75
86
  request.config.results["expected_path"] = expected_path
@@ -225,6 +236,9 @@ def test_create_text_complex(template_stream, pdf_samples, request):
225
236
  font="Times-Roman",
226
237
  font_size=50,
227
238
  font_color=(1, 0.5, 1),
239
+ bg_color=(0, 0, 1),
240
+ border_color=(1, 0, 0),
241
+ border_width=5,
228
242
  )
229
243
  assert obj.schema["properties"]["foo"]["type"] == "string"
230
244
  assert obj.schema["properties"]["foo"]["maxLength"] == 2
@@ -363,6 +377,9 @@ def test_create_dropdown(template_stream, pdf_samples, request):
363
377
  font="Courier",
364
378
  font_size=15,
365
379
  font_color=(1, 0, 0),
380
+ bg_color=(0, 0, 1),
381
+ border_color=(1, 0, 0),
382
+ border_width=5,
366
383
  )
367
384
  assert obj.schema["properties"]["new_dropdown_widget"]["type"] == "integer"
368
385
 
@@ -127,3 +127,27 @@ def test_fill_complex_fonts(sample_template_with_complex_fonts, pdf_samples, req
127
127
  if os.name != "nt":
128
128
  assert len(obj.read()) == len(expected)
129
129
  assert obj.stream == expected
130
+
131
+
132
+ def test_undo_checkbox(pdf_samples, request):
133
+ expected_path = os.path.join(
134
+ pdf_samples, "simple", "undo", "test_undo_checkbox.pdf"
135
+ )
136
+ with open(expected_path, "rb+") as f:
137
+ obj = FormWrapper(
138
+ os.path.join(pdf_samples, "simple", "undo", "sample_template_filled.pdf")
139
+ ).fill(
140
+ {
141
+ "check": False,
142
+ "check_2": False,
143
+ "check_3": False,
144
+ },
145
+ )
146
+
147
+ request.config.results["expected_path"] = expected_path
148
+ request.config.results["stream"] = obj.read()
149
+
150
+ expected = f.read()
151
+
152
+ assert len(obj.stream) == len(expected)
153
+ assert obj.stream == expected
@@ -1,11 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """Contains checkbox widget to create."""
3
-
4
- from .base import Widget
5
-
6
-
7
- class CheckBoxWidget(Widget):
8
- """Checkbox widget to create."""
9
-
10
- USER_PARAMS = [("size", "size"), ("button_style", "buttonStyle")]
11
- ACRO_FORM_FUNC = "checkbox"
File without changes
File without changes
File without changes
File without changes