PyPDFForm 1.4.17__tar.gz → 1.4.18__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 (45) hide show
  1. {PyPDFForm-1.4.17 → pypdfform-1.4.18}/PKG-INFO +1 -1
  2. {PyPDFForm-1.4.17 → pypdfform-1.4.18}/PyPDFForm/__init__.py +1 -1
  3. {PyPDFForm-1.4.17 → pypdfform-1.4.18}/PyPDFForm/filler.py +5 -5
  4. {PyPDFForm-1.4.17 → pypdfform-1.4.18}/PyPDFForm/patterns.py +4 -2
  5. {PyPDFForm-1.4.17 → pypdfform-1.4.18}/PyPDFForm.egg-info/PKG-INFO +1 -1
  6. {PyPDFForm-1.4.17 → pypdfform-1.4.18}/tests/test_functional_simple.py +24 -0
  7. {PyPDFForm-1.4.17 → pypdfform-1.4.18}/LICENSE +0 -0
  8. {PyPDFForm-1.4.17 → pypdfform-1.4.18}/PyPDFForm/adapter.py +0 -0
  9. {PyPDFForm-1.4.17 → pypdfform-1.4.18}/PyPDFForm/constants.py +0 -0
  10. {PyPDFForm-1.4.17 → pypdfform-1.4.18}/PyPDFForm/coordinate.py +0 -0
  11. {PyPDFForm-1.4.17 → pypdfform-1.4.18}/PyPDFForm/font.py +0 -0
  12. {PyPDFForm-1.4.17 → pypdfform-1.4.18}/PyPDFForm/image.py +0 -0
  13. {PyPDFForm-1.4.17 → pypdfform-1.4.18}/PyPDFForm/middleware/__init__.py +0 -0
  14. {PyPDFForm-1.4.17 → pypdfform-1.4.18}/PyPDFForm/middleware/base.py +0 -0
  15. {PyPDFForm-1.4.17 → pypdfform-1.4.18}/PyPDFForm/middleware/checkbox.py +0 -0
  16. {PyPDFForm-1.4.17 → pypdfform-1.4.18}/PyPDFForm/middleware/dropdown.py +0 -0
  17. {PyPDFForm-1.4.17 → pypdfform-1.4.18}/PyPDFForm/middleware/radio.py +0 -0
  18. {PyPDFForm-1.4.17 → pypdfform-1.4.18}/PyPDFForm/middleware/signature.py +0 -0
  19. {PyPDFForm-1.4.17 → pypdfform-1.4.18}/PyPDFForm/middleware/text.py +0 -0
  20. {PyPDFForm-1.4.17 → pypdfform-1.4.18}/PyPDFForm/template.py +0 -0
  21. {PyPDFForm-1.4.17 → pypdfform-1.4.18}/PyPDFForm/utils.py +0 -0
  22. {PyPDFForm-1.4.17 → pypdfform-1.4.18}/PyPDFForm/watermark.py +0 -0
  23. {PyPDFForm-1.4.17 → pypdfform-1.4.18}/PyPDFForm/widgets/__init__.py +0 -0
  24. {PyPDFForm-1.4.17 → pypdfform-1.4.18}/PyPDFForm/widgets/base.py +0 -0
  25. {PyPDFForm-1.4.17 → pypdfform-1.4.18}/PyPDFForm/widgets/checkbox.py +0 -0
  26. {PyPDFForm-1.4.17 → pypdfform-1.4.18}/PyPDFForm/widgets/dropdown.py +0 -0
  27. {PyPDFForm-1.4.17 → pypdfform-1.4.18}/PyPDFForm/widgets/text.py +0 -0
  28. {PyPDFForm-1.4.17 → pypdfform-1.4.18}/PyPDFForm/wrapper.py +0 -0
  29. {PyPDFForm-1.4.17 → pypdfform-1.4.18}/PyPDFForm.egg-info/SOURCES.txt +0 -0
  30. {PyPDFForm-1.4.17 → pypdfform-1.4.18}/PyPDFForm.egg-info/dependency_links.txt +0 -0
  31. {PyPDFForm-1.4.17 → pypdfform-1.4.18}/PyPDFForm.egg-info/requires.txt +0 -0
  32. {PyPDFForm-1.4.17 → pypdfform-1.4.18}/PyPDFForm.egg-info/top_level.txt +0 -0
  33. {PyPDFForm-1.4.17 → pypdfform-1.4.18}/README.md +0 -0
  34. {PyPDFForm-1.4.17 → pypdfform-1.4.18}/setup.cfg +0 -0
  35. {PyPDFForm-1.4.17 → pypdfform-1.4.18}/setup.py +0 -0
  36. {PyPDFForm-1.4.17 → pypdfform-1.4.18}/tests/test_create_widget.py +0 -0
  37. {PyPDFForm-1.4.17 → pypdfform-1.4.18}/tests/test_dropdown.py +0 -0
  38. {PyPDFForm-1.4.17 → pypdfform-1.4.18}/tests/test_dropdown_simple.py +0 -0
  39. {PyPDFForm-1.4.17 → pypdfform-1.4.18}/tests/test_fill_max_length_text_field.py +0 -0
  40. {PyPDFForm-1.4.17 → pypdfform-1.4.18}/tests/test_fill_max_length_text_field_simple.py +0 -0
  41. {PyPDFForm-1.4.17 → pypdfform-1.4.18}/tests/test_functional.py +0 -0
  42. {PyPDFForm-1.4.17 → pypdfform-1.4.18}/tests/test_paragraph.py +0 -0
  43. {PyPDFForm-1.4.17 → pypdfform-1.4.18}/tests/test_paragraph_simple.py +0 -0
  44. {PyPDFForm-1.4.17 → pypdfform-1.4.18}/tests/test_preview.py +0 -0
  45. {PyPDFForm-1.4.17 → pypdfform-1.4.18}/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.18
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.17"
4
+ __version__ = "1.4.18"
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
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PyPDFForm
3
- Version: 1.4.17
3
+ Version: 1.4.18
4
4
  Summary: The Python library for PDF forms.
5
5
  Home-page: https://github.com/chinapandaman/PyPDFForm
6
6
  Author: Jinge Li
@@ -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
File without changes
File without changes
File without changes
File without changes
File without changes