PyPDFForm 1.4.15__py3-none-any.whl → 1.4.16__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
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  """Contains any object users might need."""
3
3
 
4
- __version__ = "1.4.15"
4
+ __version__ = "1.4.16"
5
5
 
6
6
  from .wrapper import FormWrapper, PdfWrapper, PyPDFForm
PyPDFForm/constants.py CHANGED
@@ -37,6 +37,7 @@ Ff = "/Ff"
37
37
  Tx = "/Tx"
38
38
  V = "/V"
39
39
  AP = "/AP"
40
+ D = "/D"
40
41
  Sig = "/Sig"
41
42
  DA = "/DA"
42
43
  Btn = "/Btn"
@@ -47,6 +48,7 @@ Opt = "/Opt"
47
48
  MK = "/MK"
48
49
  CA = "/CA"
49
50
  AS = "/AS"
51
+ Off = "/Off"
50
52
 
51
53
  # Field flag bits
52
54
  READ_ONLY = 1 << 0
@@ -70,6 +72,4 @@ BUTTON_STYLES = {
70
72
  "l": "\u25CF", # circle
71
73
  }
72
74
 
73
- Yes = "/Yes"
74
-
75
75
  COORDINATE_GRID_FONT_SIZE_MARGIN_RATIO = DEFAULT_FONT_SIZE / 100
PyPDFForm/filler.py CHANGED
@@ -158,7 +158,7 @@ def simple_fill(
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
- simple_update_radio_value(annot, widget)
161
+ simple_update_radio_value(annot)
162
162
  elif isinstance(widget, Dropdown) and widget.value is not None:
163
163
  simple_update_dropdown_value(annot, widget)
164
164
  elif isinstance(widget, Text) and widget.value:
PyPDFForm/patterns.py CHANGED
@@ -4,8 +4,8 @@
4
4
  from pypdf.generic import (DictionaryObject, NameObject, NumberObject,
5
5
  TextStringObject)
6
6
 
7
- from .constants import (AP, AS, CA, DA, FT, MK, READ_ONLY, Btn, Ch, Ff, Opt,
8
- Parent, Q, Sig, Subtype, T, Tx, V, Widget, Yes)
7
+ from .constants import (AP, AS, CA, DA, FT, MK, READ_ONLY, Btn, Ch, D, Ff, Off,
8
+ Opt, Parent, Q, Sig, Subtype, T, Tx, V, Widget)
9
9
  from .middleware.checkbox import Checkbox
10
10
  from .middleware.dropdown import Dropdown
11
11
  from .middleware.radio import Radio
@@ -83,27 +83,45 @@ BUTTON_STYLE_PATTERNS = [
83
83
  def simple_update_checkbox_value(annot: DictionaryObject) -> None:
84
84
  """Patterns to update values for checkbox annotations."""
85
85
 
86
- annot[NameObject(AS)] = NameObject(Yes)
86
+ for each in annot[AP][D]: # noqa
87
+ if str(each) != Off:
88
+ annot[NameObject(AS)] = NameObject(each)
89
+ break
87
90
 
88
91
 
89
- def simple_update_radio_value(annot: DictionaryObject, widget: Radio) -> None:
92
+ def simple_update_radio_value(annot: DictionaryObject) -> None:
90
93
  """Patterns to update values for radio annotations."""
91
94
 
92
- annot[NameObject(AS)] = NameObject(f"/{widget.value}")
95
+ for each in annot[AP][D]: # noqa
96
+ if str(each) != Off:
97
+ annot[NameObject(AS)] = NameObject(each)
98
+ break
93
99
 
94
100
 
95
101
  def simple_update_dropdown_value(annot: DictionaryObject, widget: Dropdown) -> None:
96
102
  """Patterns to update values for dropdown annotations."""
97
103
 
98
- annot[NameObject(V)] = TextStringObject(widget.choices[widget.value])
99
- annot[NameObject(AP)] = TextStringObject(widget.choices[widget.value])
104
+ if Parent in annot and T not in annot:
105
+ annot[NameObject(Parent)][NameObject(V)] = TextStringObject( # noqa
106
+ widget.choices[widget.value]
107
+ )
108
+ annot[NameObject(AP)] = TextStringObject(widget.choices[widget.value])
109
+ else:
110
+ annot[NameObject(V)] = TextStringObject(widget.choices[widget.value])
111
+ annot[NameObject(AP)] = TextStringObject(widget.choices[widget.value])
100
112
 
101
113
 
102
114
  def simple_update_text_value(annot: DictionaryObject, widget: Text) -> None:
103
115
  """Patterns to update values for text annotations."""
104
116
 
105
- annot[NameObject(V)] = TextStringObject(widget.value)
106
- annot[NameObject(AP)] = TextStringObject(widget.value)
117
+ if Parent in annot and T not in annot:
118
+ annot[NameObject(Parent)][NameObject(V)] = TextStringObject( # noqa
119
+ widget.value
120
+ )
121
+ annot[NameObject(AP)] = TextStringObject(widget.value)
122
+ else:
123
+ annot[NameObject(V)] = TextStringObject(widget.value)
124
+ annot[NameObject(AP)] = TextStringObject(widget.value)
107
125
 
108
126
 
109
127
  def simple_flatten_radio(annot: DictionaryObject) -> None:
@@ -117,6 +135,11 @@ def simple_flatten_radio(annot: DictionaryObject) -> None:
117
135
  def simple_flatten_generic(annot: DictionaryObject) -> None:
118
136
  """Patterns to flatten generic annotations."""
119
137
 
120
- annot[NameObject(Ff)] = NumberObject(
121
- int(annot.get(NameObject(Ff), 0)) | READ_ONLY # noqa
122
- )
138
+ if Parent in annot and Ff not in annot:
139
+ annot[NameObject(Parent)][NameObject(Ff)] = NumberObject( # noqa
140
+ int(annot.get(NameObject(Ff), 0)) | READ_ONLY # noqa
141
+ )
142
+ else:
143
+ annot[NameObject(Ff)] = NumberObject(
144
+ int(annot.get(NameObject(Ff), 0)) | READ_ONLY # noqa
145
+ )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PyPDFForm
3
- Version: 1.4.15
3
+ Version: 1.4.16
4
4
  Summary: The Python library for PDF forms.
5
5
  Home-page: https://github.com/chinapandaman/PyPDFForm
6
6
  Author: Jinge Li
@@ -1,11 +1,11 @@
1
- PyPDFForm/__init__.py,sha256=KgGvTymkLYyv87kBq8HFehcC47PtgmzHc1zc73Z526w,149
1
+ PyPDFForm/__init__.py,sha256=G5VFxKnti5RCcw-SqAk6LjAGVJ9fEuPt1CYJQb0QMeA,149
2
2
  PyPDFForm/adapter.py,sha256=OgAIwcmukpBqHFBLymd3I7wA7wIdipRqgURZA2Y0Hgo,885
3
- PyPDFForm/constants.py,sha256=H-MBRnFhqvCrkVnwTCzYdt6ebe7rbUBTjzZl3GFdHtM,1431
3
+ PyPDFForm/constants.py,sha256=D2lIBZllCdEcLVsSZ6fRGxEYFaTZj9Ex7ksDxbs7g44,1439
4
4
  PyPDFForm/coordinate.py,sha256=iOy_KEZO3DKsvwdclxZHLOJyrvbCVqJDK2UKmMpEM8E,7310
5
- PyPDFForm/filler.py,sha256=qobLLpYF79YZaHmZz_VbjLICebg-6xdQa4btNZO4Li4,6430
5
+ PyPDFForm/filler.py,sha256=DdPGjVxkFNf1XqLmf-Qjr3xOFL0FX2afTCNC75JwJoc,6422
6
6
  PyPDFForm/font.py,sha256=y9vNvoaBfgkd5vz9EDp04ul8KDM2jY7J61-VWFng6GY,4155
7
7
  PyPDFForm/image.py,sha256=0GV8PFgY5oLJFHmhPD1fG-_5SBEO7jVLLtxCc_Uodfo,1143
8
- PyPDFForm/patterns.py,sha256=udF5Ka-ucEKgO13FvZ3VZv8mJbi-f-aAixAyJFR8cWI,2946
8
+ PyPDFForm/patterns.py,sha256=3m_lJ3LmlHY0TxiqrrQzjUCDqrZvhIp9NbMQV1OH28o,3827
9
9
  PyPDFForm/template.py,sha256=fuoqiYD_4xQXrBgw8XC677EMxJzHaXb9NcVVYbf0r-0,11782
10
10
  PyPDFForm/utils.py,sha256=_gskLLNmwhfGF16gfMP00twVY6iYADYYAYWHMvKCDrg,4140
11
11
  PyPDFForm/watermark.py,sha256=clYdRqCuWEE25IL-BUHnSo4HgLkHPSOl7FUJLhbAfGg,4755
@@ -21,8 +21,8 @@ PyPDFForm/widgets/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU
21
21
  PyPDFForm/widgets/base.py,sha256=Stq-oQt-cfwQ6nilQ4NqpO5udFSKDNb1mAwryrWggZA,2076
22
22
  PyPDFForm/widgets/checkbox.py,sha256=issx3onojq9plTHbNQwEnkbnhTo5vJKA5XSAoxRzQCg,264
23
23
  PyPDFForm/widgets/text.py,sha256=lUVlfQ-ndemSelsKNzY6nS4Kuf_H4mDPxotFMQFV-so,484
24
- PyPDFForm-1.4.15.dist-info/LICENSE,sha256=43awmYkI6opyTpg19me731iO1WfXZwViqb67oWtCsFY,1065
25
- PyPDFForm-1.4.15.dist-info/METADATA,sha256=63tamlVBtPHyMvkegLhDXBGlZ2Wp9qMQ_HTLCRRC9_o,5178
26
- PyPDFForm-1.4.15.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
27
- PyPDFForm-1.4.15.dist-info/top_level.txt,sha256=GQQKuWqPUjT9YZqwK95NlAQzxjwoQrsxQ8ureM8lWOY,10
28
- PyPDFForm-1.4.15.dist-info/RECORD,,
24
+ PyPDFForm-1.4.16.dist-info/LICENSE,sha256=43awmYkI6opyTpg19me731iO1WfXZwViqb67oWtCsFY,1065
25
+ PyPDFForm-1.4.16.dist-info/METADATA,sha256=0AzKUrTQVCkTkdiX_qABWj2EwhnBzEJK51mQLWn7Ajs,5178
26
+ PyPDFForm-1.4.16.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
27
+ PyPDFForm-1.4.16.dist-info/top_level.txt,sha256=GQQKuWqPUjT9YZqwK95NlAQzxjwoQrsxQ8ureM8lWOY,10
28
+ PyPDFForm-1.4.16.dist-info/RECORD,,