PyPDFForm 1.5.1__py3-none-any.whl → 1.5.2__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,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  """Contains any object users might need."""
3
3
 
4
- __version__ = "1.5.1"
4
+ __version__ = "1.5.2"
5
5
 
6
6
  from .wrapper import FormWrapper, PdfWrapper
7
7
 
PyPDFForm/adapter.py CHANGED
@@ -12,7 +12,7 @@ def readable(obj: Any) -> bool:
12
12
 
13
13
 
14
14
  def fp_or_f_obj_or_stream_to_stream(
15
- fp_or_f_obj_or_stream: Union[bytes, str, BinaryIO]
15
+ fp_or_f_obj_or_stream: Union[bytes, str, BinaryIO],
16
16
  ) -> bytes:
17
17
  """Converts a file path or a file object to a stream."""
18
18
 
PyPDFForm/constants.py CHANGED
@@ -76,11 +76,11 @@ NEW_LINE_SYMBOL = "\n"
76
76
  IMAGE_FIELD_IDENTIFIER = "event.target.buttonImportIcon();"
77
77
 
78
78
  DEFAULT_CHECKBOX_STYLE = "\u2713"
79
- DEFAULT_RADIO_STYLE = "\u25CF"
79
+ DEFAULT_RADIO_STYLE = "\u25cf"
80
80
  BUTTON_STYLES = {
81
81
  "4": "\u2713", # check
82
- "5": "\u00D7", # cross
83
- "l": "\u25CF", # circle
82
+ "5": "\u00d7", # cross
83
+ "l": "\u25cf", # circle
84
84
  }
85
85
 
86
86
  COORDINATE_GRID_FONT_SIZE_MARGIN_RATIO = DEFAULT_FONT_SIZE / 100
PyPDFForm/wrapper.py CHANGED
@@ -71,6 +71,13 @@ class FormWrapper:
71
71
  class PdfWrapper(FormWrapper):
72
72
  """A class to represent a PDF form."""
73
73
 
74
+ USER_PARAMS = [
75
+ "global_font",
76
+ "global_font_size",
77
+ "global_font_color",
78
+ "use_full_widget_name",
79
+ ]
80
+
74
81
  def __init__(
75
82
  self,
76
83
  template: Union[bytes, str, BinaryIO] = b"",
@@ -82,11 +89,8 @@ class PdfWrapper(FormWrapper):
82
89
  self.widgets = {}
83
90
  self._keys_to_update = []
84
91
 
85
- self.global_font = kwargs.get("global_font")
86
- self.global_font_size = kwargs.get("global_font_size")
87
- self.global_font_color = kwargs.get("global_font_color")
88
-
89
- self.use_full_widget_name = kwargs.get("use_full_widget_name", False)
92
+ for each in self.USER_PARAMS:
93
+ setattr(self, each, kwargs.get(each))
90
94
 
91
95
  self._init_helper()
92
96
 
@@ -95,7 +99,9 @@ class PdfWrapper(FormWrapper):
95
99
 
96
100
  refresh_not_needed = {}
97
101
  new_widgets = (
98
- build_widgets(self.read(), self.use_full_widget_name) if self.read() else {}
102
+ build_widgets(self.read(), getattr(self, "use_full_widget_name"))
103
+ if self.read()
104
+ else {}
99
105
  )
100
106
  for k, v in self.widgets.items():
101
107
  if k in new_widgets:
@@ -109,9 +115,9 @@ class PdfWrapper(FormWrapper):
109
115
  and isinstance(value, Text)
110
116
  and not refresh_not_needed.get(key)
111
117
  ):
112
- value.font = self.global_font
113
- value.font_size = self.global_font_size
114
- value.font_color = self.global_font_color
118
+ value.font = getattr(self, "global_font")
119
+ value.font_size = getattr(self, "global_font_size")
120
+ value.font_color = getattr(self, "global_font_color")
115
121
 
116
122
  @property
117
123
  def sample_data(self) -> dict:
@@ -133,7 +139,12 @@ class PdfWrapper(FormWrapper):
133
139
  def pages(self) -> List[PdfWrapper]:
134
140
  """Returns a list of pdf wrapper objects where each is a page of the PDF form."""
135
141
 
136
- return [self.__class__(each) for each in get_page_streams(self.stream)]
142
+ return [
143
+ self.__class__(
144
+ each, **{param: getattr(self, param) for param in self.USER_PARAMS}
145
+ )
146
+ for each in get_page_streams(self.stream)
147
+ ]
137
148
 
138
149
  def change_version(self, version: str) -> PdfWrapper:
139
150
  """Changes the version of the PDF."""
@@ -258,7 +269,7 @@ class PdfWrapper(FormWrapper):
258
269
  ) -> PdfWrapper:
259
270
  """Updates the key of an existed widget on a PDF form."""
260
271
 
261
- if self.use_full_widget_name:
272
+ if getattr(self, "use_full_widget_name"):
262
273
  raise NotImplementedError
263
274
 
264
275
  if defer:
@@ -275,7 +286,7 @@ class PdfWrapper(FormWrapper):
275
286
  def commit_widget_key_updates(self) -> PdfWrapper:
276
287
  """Commits all deferred widget key updates on a PDF form."""
277
288
 
278
- if self.use_full_widget_name:
289
+ if getattr(self, "use_full_widget_name"):
279
290
  raise NotImplementedError
280
291
 
281
292
  old_keys = [each[0] for each in self._keys_to_update]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: PyPDFForm
3
- Version: 1.5.1
3
+ Version: 1.5.2
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
- PyPDFForm/__init__.py,sha256=fM6oW3DZ3IPldn96No6E_Qf9uwf-R9ZkMZf54oZ2T-w,178
2
- PyPDFForm/adapter.py,sha256=WFP-r8FLeKa-D9mFO9AphOcuXgyeAI1Ak0d-YsqxsK4,861
3
- PyPDFForm/constants.py,sha256=48mxgyY3UgiVO2UIZuDe_B8KOE5bedyujnOjk6MtzHQ,1749
1
+ PyPDFForm/__init__.py,sha256=-SiFL-rTPed5J5k_a2JG6rtcU_vGtAZigzoS-S_Sfmk,178
2
+ PyPDFForm/adapter.py,sha256=qt0lqd7zRzaMHD2As47oiIhungO3AyWbAkxx1ZAZi9A,862
3
+ PyPDFForm/constants.py,sha256=xj9CSq7PlCpAowKAlK0o8YPgPkBkJjRDToI8aiqC_c0,1749
4
4
  PyPDFForm/coordinate.py,sha256=V_ZZQ1pXtVPAyfMJCX7fKoEimK7XwX6bU3VQ0nKOhQA,7314
5
5
  PyPDFForm/filler.py,sha256=ztYU-Rk_LKfCw-BhmdIDnK7ez-5jSPoi2Ho3xvbO4Io,7487
6
6
  PyPDFForm/font.py,sha256=TbFLY4G72d7cQ3VG2g4HaYKROzQPQUmh6-8ynN6hzXY,5713
@@ -9,7 +9,7 @@ PyPDFForm/patterns.py,sha256=Z548TjpQpaVepctvlRYe0-2i7Aws96fo-ncG82CUX14,5423
9
9
  PyPDFForm/template.py,sha256=LlnZTNF5UPLkiGqnSgHNcVr_Af6vJyg6vBf7jVD5wAM,15470
10
10
  PyPDFForm/utils.py,sha256=9omR-oT3OdZqioxpiGqA9_P0GSFC6mg4Y1xrLvWOzkk,4309
11
11
  PyPDFForm/watermark.py,sha256=L4LfzjjyJ6TDq9ad2dbtQYheBOic1_oZ7smhFFekNog,4725
12
- PyPDFForm/wrapper.py,sha256=QYGQrQs2VuvnRjrfxZfCeMxVj0gd6r_8Yi2RQ30NEQY,11375
12
+ PyPDFForm/wrapper.py,sha256=dxcFnkMv7zwT75BWZxgbrpl-Ty1dB98gjiP6xp9ihAU,11565
13
13
  PyPDFForm/middleware/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
14
  PyPDFForm/middleware/base.py,sha256=Sjo8O9RrdBu73r4BCMPuLXnrl1hzjb1dlTOPeIgrhOU,1150
15
15
  PyPDFForm/middleware/checkbox.py,sha256=0EWFECXYdz9SNxgGe1QCcRrdxLVUIJpzRYwKfGRA9e4,1346
@@ -23,8 +23,8 @@ PyPDFForm/widgets/base.py,sha256=nb6HEfRdWSjZc_Th1XI62PIlgREn_JiApGC-epb6jAg,334
23
23
  PyPDFForm/widgets/checkbox.py,sha256=MGB6NGI-XMBz4j2erykgYOCd1pswvthuQ6UFowQOd4o,503
24
24
  PyPDFForm/widgets/dropdown.py,sha256=2_R5xcLUWAL0G4raVgWWtE7TJdiWJITay-Gtl8YI2QI,705
25
25
  PyPDFForm/widgets/text.py,sha256=sCB8CQAjh30QOGr8FTIDSk3X6dXSHJztOz6YkKEBDss,691
26
- PyPDFForm-1.5.1.dist-info/LICENSE,sha256=43awmYkI6opyTpg19me731iO1WfXZwViqb67oWtCsFY,1065
27
- PyPDFForm-1.5.1.dist-info/METADATA,sha256=yHnhAICnAw0eO_IU3UwiuDIEF447E55A1PiO4CQCs9A,4376
28
- PyPDFForm-1.5.1.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
29
- PyPDFForm-1.5.1.dist-info/top_level.txt,sha256=GQQKuWqPUjT9YZqwK95NlAQzxjwoQrsxQ8ureM8lWOY,10
30
- PyPDFForm-1.5.1.dist-info/RECORD,,
26
+ PyPDFForm-1.5.2.dist-info/LICENSE,sha256=43awmYkI6opyTpg19me731iO1WfXZwViqb67oWtCsFY,1065
27
+ PyPDFForm-1.5.2.dist-info/METADATA,sha256=15iix1PjDLJk3OLrQTFdKRpt-dmH2JaL-vcjWCuPksc,4376
28
+ PyPDFForm-1.5.2.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
29
+ PyPDFForm-1.5.2.dist-info/top_level.txt,sha256=GQQKuWqPUjT9YZqwK95NlAQzxjwoQrsxQ8ureM8lWOY,10
30
+ PyPDFForm-1.5.2.dist-info/RECORD,,