PyPDFForm 2.3.3__tar.gz → 2.4.0__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.
- {pypdfform-2.3.3 → pypdfform-2.4.0}/PKG-INFO +2 -3
- {pypdfform-2.3.3 → pypdfform-2.4.0}/PyPDFForm/__init__.py +1 -1
- {pypdfform-2.3.3 → pypdfform-2.4.0}/PyPDFForm/filler.py +3 -1
- {pypdfform-2.3.3 → pypdfform-2.4.0}/PyPDFForm/wrapper.py +27 -6
- {pypdfform-2.3.3 → pypdfform-2.4.0}/PyPDFForm.egg-info/PKG-INFO +2 -3
- {pypdfform-2.3.3 → pypdfform-2.4.0}/pyproject.toml +1 -2
- {pypdfform-2.3.3 → pypdfform-2.4.0}/LICENSE +0 -0
- {pypdfform-2.3.3 → pypdfform-2.4.0}/PyPDFForm/adapter.py +0 -0
- {pypdfform-2.3.3 → pypdfform-2.4.0}/PyPDFForm/constants.py +0 -0
- {pypdfform-2.3.3 → pypdfform-2.4.0}/PyPDFForm/coordinate.py +0 -0
- {pypdfform-2.3.3 → pypdfform-2.4.0}/PyPDFForm/font.py +0 -0
- {pypdfform-2.3.3 → pypdfform-2.4.0}/PyPDFForm/image.py +0 -0
- {pypdfform-2.3.3 → pypdfform-2.4.0}/PyPDFForm/middleware/__init__.py +0 -0
- {pypdfform-2.3.3 → pypdfform-2.4.0}/PyPDFForm/middleware/base.py +0 -0
- {pypdfform-2.3.3 → pypdfform-2.4.0}/PyPDFForm/middleware/checkbox.py +0 -0
- {pypdfform-2.3.3 → pypdfform-2.4.0}/PyPDFForm/middleware/dropdown.py +0 -0
- {pypdfform-2.3.3 → pypdfform-2.4.0}/PyPDFForm/middleware/image.py +0 -0
- {pypdfform-2.3.3 → pypdfform-2.4.0}/PyPDFForm/middleware/radio.py +0 -0
- {pypdfform-2.3.3 → pypdfform-2.4.0}/PyPDFForm/middleware/signature.py +0 -0
- {pypdfform-2.3.3 → pypdfform-2.4.0}/PyPDFForm/middleware/text.py +0 -0
- {pypdfform-2.3.3 → pypdfform-2.4.0}/PyPDFForm/patterns.py +0 -0
- {pypdfform-2.3.3 → pypdfform-2.4.0}/PyPDFForm/template.py +0 -0
- {pypdfform-2.3.3 → pypdfform-2.4.0}/PyPDFForm/utils.py +0 -0
- {pypdfform-2.3.3 → pypdfform-2.4.0}/PyPDFForm/watermark.py +0 -0
- {pypdfform-2.3.3 → pypdfform-2.4.0}/PyPDFForm/widgets/__init__.py +0 -0
- {pypdfform-2.3.3 → pypdfform-2.4.0}/PyPDFForm/widgets/base.py +0 -0
- {pypdfform-2.3.3 → pypdfform-2.4.0}/PyPDFForm/widgets/bedrock.py +0 -0
- {pypdfform-2.3.3 → pypdfform-2.4.0}/PyPDFForm/widgets/checkbox.py +0 -0
- {pypdfform-2.3.3 → pypdfform-2.4.0}/PyPDFForm/widgets/dropdown.py +0 -0
- {pypdfform-2.3.3 → pypdfform-2.4.0}/PyPDFForm/widgets/image.py +0 -0
- {pypdfform-2.3.3 → pypdfform-2.4.0}/PyPDFForm/widgets/radio.py +0 -0
- {pypdfform-2.3.3 → pypdfform-2.4.0}/PyPDFForm/widgets/signature.py +0 -0
- {pypdfform-2.3.3 → pypdfform-2.4.0}/PyPDFForm/widgets/text.py +0 -0
- {pypdfform-2.3.3 → pypdfform-2.4.0}/PyPDFForm.egg-info/SOURCES.txt +0 -0
- {pypdfform-2.3.3 → pypdfform-2.4.0}/PyPDFForm.egg-info/dependency_links.txt +0 -0
- {pypdfform-2.3.3 → pypdfform-2.4.0}/PyPDFForm.egg-info/requires.txt +0 -0
- {pypdfform-2.3.3 → pypdfform-2.4.0}/PyPDFForm.egg-info/top_level.txt +0 -0
- {pypdfform-2.3.3 → pypdfform-2.4.0}/README.md +0 -0
- {pypdfform-2.3.3 → pypdfform-2.4.0}/setup.cfg +0 -0
- {pypdfform-2.3.3 → pypdfform-2.4.0}/tests/test_adobe_mode.py +0 -0
- {pypdfform-2.3.3 → pypdfform-2.4.0}/tests/test_create_widget.py +0 -0
- {pypdfform-2.3.3 → pypdfform-2.4.0}/tests/test_dropdown.py +0 -0
- {pypdfform-2.3.3 → pypdfform-2.4.0}/tests/test_dropdown_simple.py +0 -0
- {pypdfform-2.3.3 → pypdfform-2.4.0}/tests/test_fill_max_length_text_field.py +0 -0
- {pypdfform-2.3.3 → pypdfform-2.4.0}/tests/test_fill_max_length_text_field_simple.py +0 -0
- {pypdfform-2.3.3 → pypdfform-2.4.0}/tests/test_fill_method.py +0 -0
- {pypdfform-2.3.3 → pypdfform-2.4.0}/tests/test_functional.py +0 -0
- {pypdfform-2.3.3 → pypdfform-2.4.0}/tests/test_functional_simple.py +0 -0
- {pypdfform-2.3.3 → pypdfform-2.4.0}/tests/test_paragraph.py +0 -0
- {pypdfform-2.3.3 → pypdfform-2.4.0}/tests/test_paragraph_simple.py +0 -0
- {pypdfform-2.3.3 → pypdfform-2.4.0}/tests/test_preview.py +0 -0
- {pypdfform-2.3.3 → pypdfform-2.4.0}/tests/test_signature.py +0 -0
- {pypdfform-2.3.3 → pypdfform-2.4.0}/tests/test_use_full_widget_name.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: PyPDFForm
|
|
3
|
-
Version: 2.
|
|
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.
|
|
20
|
+
Requires-Python: >=3.9
|
|
22
21
|
Description-Content-Type: text/markdown
|
|
23
22
|
License-File: LICENSE
|
|
24
23
|
Requires-Dist: cryptography
|
|
@@ -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(),
|
|
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:
|
|
@@ -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.
|
|
106
|
-
|
|
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
|
|
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
|
-
|
|
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 =
|
|
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
|
+
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.
|
|
20
|
+
Requires-Python: >=3.9
|
|
22
21
|
Description-Content-Type: text/markdown
|
|
23
22
|
License-File: LICENSE
|
|
24
23
|
Requires-Dist: cryptography
|
|
@@ -17,7 +17,6 @@ classifiers = [
|
|
|
17
17
|
"Intended Audience :: Developers",
|
|
18
18
|
"Programming Language :: Python :: 3",
|
|
19
19
|
"Programming Language :: Python :: 3 :: Only",
|
|
20
|
-
"Programming Language :: Python :: 3.8",
|
|
21
20
|
"Programming Language :: Python :: 3.9",
|
|
22
21
|
"Programming Language :: Python :: 3.10",
|
|
23
22
|
"Programming Language :: Python :: 3.11",
|
|
@@ -26,7 +25,7 @@ classifiers = [
|
|
|
26
25
|
"Operating System :: OS Independent",
|
|
27
26
|
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
28
27
|
]
|
|
29
|
-
requires-python = ">=3.
|
|
28
|
+
requires-python = ">=3.9"
|
|
30
29
|
dependencies = [
|
|
31
30
|
"cryptography",
|
|
32
31
|
"pillow",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|