PyPDFForm 2.3.3__py3-none-any.whl → 2.4.0__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
@@ -5,7 +5,7 @@ This package provides tools for filling PDF forms, drawing text and images,
5
5
  and manipulating PDF form elements programmatically.
6
6
  """
7
7
 
8
- __version__ = "2.3.3"
8
+ __version__ = "2.4.0"
9
9
 
10
10
  from .wrapper import FormWrapper, PdfWrapper
11
11
 
PyPDFForm/filler.py CHANGED
@@ -337,6 +337,7 @@ def enable_adobe_mode(reader: PdfReader, writer: PdfWriter, adobe_mode: bool) ->
337
337
  def simple_fill(
338
338
  template: bytes,
339
339
  widgets: Dict[str, WIDGET_TYPES],
340
+ use_full_widget_name: bool,
340
341
  flatten: bool = False,
341
342
  adobe_mode: bool = False,
342
343
  ) -> bytes:
@@ -350,6 +351,7 @@ def simple_fill(
350
351
  Args:
351
352
  template: Input PDF form as bytes
352
353
  widgets: Dictionary mapping field names to widget middleware
354
+ use_full_widget_name: If True, uses the full widget name as the key in the widgets dictionary
353
355
  flatten: If True, makes form fields read-only
354
356
  adobe_mode: If True, enables Adobe Acrobat compatibility
355
357
 
@@ -367,7 +369,7 @@ def simple_fill(
367
369
  for page in out.pages:
368
370
  for annot in page.get(Annots, []):
369
371
  annot = cast(DictionaryObject, annot.get_object())
370
- key = get_widget_key(annot.get_object(), False)
372
+ key = get_widget_key(annot.get_object(), use_full_widget_name)
371
373
 
372
374
  widget = widgets.get(key)
373
375
  if widget is None or widget.value is None:
PyPDFForm/wrapper.py CHANGED
@@ -62,16 +62,21 @@ class FormWrapper:
62
62
  def __init__(
63
63
  self,
64
64
  template: Union[bytes, str, BinaryIO] = b"",
65
+ **kwargs,
65
66
  ) -> None:
66
67
  """Initializes the base form wrapper with a PDF template.
67
68
 
68
69
  Args:
69
70
  template: PDF form as bytes, file path, or file object. Defaults to
70
71
  empty bytes if not provided.
72
+ **kwargs: Additional options:
73
+ use_full_widget_name: If True, uses complete widget names including
74
+ field hierarchy (default: False)
71
75
 
72
76
  Initializes:
73
77
  - Internal PDF stream from the template
74
78
  - Basic form filling capabilities
79
+ - Widget naming configuration from kwargs
75
80
 
76
81
  Note:
77
82
  This base class is designed to be extended by PdfWrapper which adds
@@ -80,6 +85,7 @@ class FormWrapper:
80
85
 
81
86
  super().__init__()
82
87
  self.stream = fp_or_f_obj_or_stream_to_stream(template)
88
+ self.use_full_widget_name = kwargs.get("use_full_widget_name", False)
83
89
 
84
90
  def read(self) -> bytes:
85
91
  """Returns the raw bytes of the PDF form data.
@@ -102,20 +108,34 @@ class FormWrapper:
102
108
  """Fills form fields in the PDF with provided values.
103
109
 
104
110
  Takes a dictionary of field names to values and updates the corresponding
105
- form fields in the PDF. Only fields that exist in the template PDF will
106
- be filled - unknown field names are silently ignored.
111
+ form fields in the PDF. Supports these value types:
112
+ - Strings for text fields
113
+ - Booleans for checkboxes (True=checked, False=unchecked)
114
+ - Integers for numeric fields and dropdown selections
115
+
116
+ Only fields that exist in the template PDF will be filled - unknown field
117
+ names are silently ignored.
107
118
 
108
119
  Args:
109
- data: Dictionary mapping field names to values (str, bool or int)
120
+ data: Dictionary mapping field names to values. Supported types:
121
+ str: For text fields
122
+ bool: For checkboxes (True=checked)
123
+ int: For numeric fields and dropdown selections
110
124
  **kwargs: Additional options:
111
- flatten: If True, makes form fields read-only after filling
112
- adobe_mode: If True, uses Adobe-compatible filling logic
125
+ flatten (bool): If True, makes form fields read-only after filling
126
+ (default: False)
127
+ adobe_mode (bool): If True, uses Adobe-compatible filling logic
128
+ (default: False)
113
129
 
114
130
  Returns:
115
131
  FormWrapper: Returns self to allow method chaining
116
132
  """
117
133
 
118
- widgets = build_widgets(self.stream, False, False) if self.stream else {}
134
+ widgets = (
135
+ build_widgets(self.stream, self.use_full_widget_name, False)
136
+ if self.stream
137
+ else {}
138
+ )
119
139
 
120
140
  for key, value in data.items():
121
141
  if key in widgets:
@@ -124,6 +144,7 @@ class FormWrapper:
124
144
  self.stream = simple_fill(
125
145
  self.read(),
126
146
  widgets,
147
+ use_full_widget_name=self.use_full_widget_name,
127
148
  flatten=kwargs.get("flatten", False),
128
149
  adobe_mode=kwargs.get("adobe_mode", False),
129
150
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PyPDFForm
3
- Version: 2.3.3
3
+ Version: 2.4.0
4
4
  Summary: The Python library for PDF forms.
5
5
  Author: Jinge Li
6
6
  License-Expression: MIT
@@ -10,7 +10,6 @@ Classifier: Development Status :: 5 - Production/Stable
10
10
  Classifier: Intended Audience :: Developers
11
11
  Classifier: Programming Language :: Python :: 3
12
12
  Classifier: Programming Language :: Python :: 3 :: Only
13
- Classifier: Programming Language :: Python :: 3.8
14
13
  Classifier: Programming Language :: Python :: 3.9
15
14
  Classifier: Programming Language :: Python :: 3.10
16
15
  Classifier: Programming Language :: Python :: 3.11
@@ -18,7 +17,7 @@ Classifier: Programming Language :: Python :: 3.12
18
17
  Classifier: Programming Language :: Python :: 3.13
19
18
  Classifier: Operating System :: OS Independent
20
19
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
- Requires-Python: >=3.8
20
+ Requires-Python: >=3.9
22
21
  Description-Content-Type: text/markdown
23
22
  License-File: LICENSE
24
23
  Requires-Dist: cryptography
@@ -1,15 +1,15 @@
1
- PyPDFForm/__init__.py,sha256=CIeFI9ZbT-rwWJRuFoM1sf-_594uyi0_dZQZR9f8b2Y,328
1
+ PyPDFForm/__init__.py,sha256=TrLXIaBX68LQ3KQc6d_tR2c7UnzA3uXZ90KmNZuoiYM,328
2
2
  PyPDFForm/adapter.py,sha256=_5fP5UR-NzjDDayJmBRO36DgbnbUzNbjZtHZtPvSM14,1909
3
3
  PyPDFForm/constants.py,sha256=3ed0j11cWd9Uo4s-XvZwwJojPSz8aqdmZgaEishWjqE,2342
4
4
  PyPDFForm/coordinate.py,sha256=gQI7z-GsdCO33Qny5kXLBs6Y2TW5KO_mJ2in64fvXcg,16412
5
- PyPDFForm/filler.py,sha256=zyI_dBATc6ldZlJnQHhryj221CwWdkyVtlcrIYPhXvQ,13967
5
+ PyPDFForm/filler.py,sha256=oCXDzz8paw8-MIQLiTTv5goYlfCfz_EcczCj8K4JB3g,14116
6
6
  PyPDFForm/font.py,sha256=eRbDyQFhXUkHzyZvCtru9Ypg_ukfbBAnSM5xNzPb5ss,7280
7
7
  PyPDFForm/image.py,sha256=aYk7BC-AHiqt73durGIQ3e6gE5Ggbdr8jmkCUaQdsk8,1627
8
8
  PyPDFForm/patterns.py,sha256=VH7cgAFHLKEUIfE1yIlifIJ9mc0Eb2Kqo-krk34HGOY,9316
9
9
  PyPDFForm/template.py,sha256=N_Pj3SaSKs3sqIuIdtgHPXvxIHLnHeR2M9IwRCWWKoQ,20043
10
10
  PyPDFForm/utils.py,sha256=QxJSG96FHGch863UdBPT8DdTKN9gVzQzA2ezifTm7z4,8575
11
11
  PyPDFForm/watermark.py,sha256=yvtZKcdPAPprBVEWcFZEnZMJcTwVpQ6u72m0jqYHxx8,12357
12
- PyPDFForm/wrapper.py,sha256=hBgSkHq0VjzY5VDdT_XHmHt6yr2LPq6hXqBy-LcJCdc,25674
12
+ PyPDFForm/wrapper.py,sha256=jiuO-GBqAlQgWfXgPZB4dWpF7_t4UpdMokn9XBDGdEI,26582
13
13
  PyPDFForm/middleware/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
14
  PyPDFForm/middleware/base.py,sha256=Ex--sUtQqpjFYWi3oAMqjuay_HYToHFMwRtdgWusckI,2802
15
15
  PyPDFForm/middleware/checkbox.py,sha256=gRGhFySPoIpKBseoiOTS3WggoBBik12dXbZ-LJKzIwM,2611
@@ -27,8 +27,8 @@ PyPDFForm/widgets/image.py,sha256=6y8Ysmk49USr_qWOXD6KGL6cch516cUIlrxoj0pJy9Q,79
27
27
  PyPDFForm/widgets/radio.py,sha256=ipadJyHbgftDUvjGk15kapzgHPN3HjdF_iB_7amXR6o,2737
28
28
  PyPDFForm/widgets/signature.py,sha256=FdXzja3RTuyU9iyA5Y1yPb4Gsfe4rYlM4gcwekIuwog,4997
29
29
  PyPDFForm/widgets/text.py,sha256=HP2cPEUAzK5QL3kDfMz7gQcC3svCpmYuyFItBjlrBpI,1233
30
- pypdfform-2.3.3.dist-info/licenses/LICENSE,sha256=43awmYkI6opyTpg19me731iO1WfXZwViqb67oWtCsFY,1065
31
- pypdfform-2.3.3.dist-info/METADATA,sha256=Xvokh3kh7VxfWjHqELYDLiEGPZdPAGeNk7PS0ePk7BQ,4738
32
- pypdfform-2.3.3.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
33
- pypdfform-2.3.3.dist-info/top_level.txt,sha256=GQQKuWqPUjT9YZqwK95NlAQzxjwoQrsxQ8ureM8lWOY,10
34
- pypdfform-2.3.3.dist-info/RECORD,,
30
+ pypdfform-2.4.0.dist-info/licenses/LICENSE,sha256=43awmYkI6opyTpg19me731iO1WfXZwViqb67oWtCsFY,1065
31
+ pypdfform-2.4.0.dist-info/METADATA,sha256=6g0a3hKc0j1JYVkG7kEVK0iBdZc6bKMVyf2LSEt6VgA,4688
32
+ pypdfform-2.4.0.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
33
+ pypdfform-2.4.0.dist-info/top_level.txt,sha256=GQQKuWqPUjT9YZqwK95NlAQzxjwoQrsxQ8ureM8lWOY,10
34
+ pypdfform-2.4.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.4.0)
2
+ Generator: setuptools (80.7.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5