PyPDFForm 2.3.0__tar.gz → 2.3.2__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.0 → pypdfform-2.3.2}/PKG-INFO +1 -1
- {pypdfform-2.3.0 → pypdfform-2.3.2}/PyPDFForm/__init__.py +1 -1
- {pypdfform-2.3.0 → pypdfform-2.3.2}/PyPDFForm/template.py +34 -13
- {pypdfform-2.3.0 → pypdfform-2.3.2}/PyPDFForm/wrapper.py +20 -9
- {pypdfform-2.3.0 → pypdfform-2.3.2}/PyPDFForm.egg-info/PKG-INFO +1 -1
- {pypdfform-2.3.0 → pypdfform-2.3.2}/pyproject.toml +1 -1
- {pypdfform-2.3.0 → pypdfform-2.3.2}/tests/test_use_full_widget_name.py +2 -4
- {pypdfform-2.3.0 → pypdfform-2.3.2}/LICENSE +0 -0
- {pypdfform-2.3.0 → pypdfform-2.3.2}/PyPDFForm/adapter.py +0 -0
- {pypdfform-2.3.0 → pypdfform-2.3.2}/PyPDFForm/constants.py +0 -0
- {pypdfform-2.3.0 → pypdfform-2.3.2}/PyPDFForm/coordinate.py +0 -0
- {pypdfform-2.3.0 → pypdfform-2.3.2}/PyPDFForm/filler.py +0 -0
- {pypdfform-2.3.0 → pypdfform-2.3.2}/PyPDFForm/font.py +0 -0
- {pypdfform-2.3.0 → pypdfform-2.3.2}/PyPDFForm/image.py +0 -0
- {pypdfform-2.3.0 → pypdfform-2.3.2}/PyPDFForm/middleware/__init__.py +0 -0
- {pypdfform-2.3.0 → pypdfform-2.3.2}/PyPDFForm/middleware/base.py +0 -0
- {pypdfform-2.3.0 → pypdfform-2.3.2}/PyPDFForm/middleware/checkbox.py +0 -0
- {pypdfform-2.3.0 → pypdfform-2.3.2}/PyPDFForm/middleware/dropdown.py +0 -0
- {pypdfform-2.3.0 → pypdfform-2.3.2}/PyPDFForm/middleware/image.py +0 -0
- {pypdfform-2.3.0 → pypdfform-2.3.2}/PyPDFForm/middleware/radio.py +0 -0
- {pypdfform-2.3.0 → pypdfform-2.3.2}/PyPDFForm/middleware/signature.py +0 -0
- {pypdfform-2.3.0 → pypdfform-2.3.2}/PyPDFForm/middleware/text.py +0 -0
- {pypdfform-2.3.0 → pypdfform-2.3.2}/PyPDFForm/patterns.py +0 -0
- {pypdfform-2.3.0 → pypdfform-2.3.2}/PyPDFForm/utils.py +0 -0
- {pypdfform-2.3.0 → pypdfform-2.3.2}/PyPDFForm/watermark.py +0 -0
- {pypdfform-2.3.0 → pypdfform-2.3.2}/PyPDFForm/widgets/__init__.py +0 -0
- {pypdfform-2.3.0 → pypdfform-2.3.2}/PyPDFForm/widgets/base.py +0 -0
- {pypdfform-2.3.0 → pypdfform-2.3.2}/PyPDFForm/widgets/bedrock.py +0 -0
- {pypdfform-2.3.0 → pypdfform-2.3.2}/PyPDFForm/widgets/checkbox.py +0 -0
- {pypdfform-2.3.0 → pypdfform-2.3.2}/PyPDFForm/widgets/dropdown.py +0 -0
- {pypdfform-2.3.0 → pypdfform-2.3.2}/PyPDFForm/widgets/image.py +0 -0
- {pypdfform-2.3.0 → pypdfform-2.3.2}/PyPDFForm/widgets/radio.py +0 -0
- {pypdfform-2.3.0 → pypdfform-2.3.2}/PyPDFForm/widgets/signature.py +0 -0
- {pypdfform-2.3.0 → pypdfform-2.3.2}/PyPDFForm/widgets/text.py +0 -0
- {pypdfform-2.3.0 → pypdfform-2.3.2}/PyPDFForm.egg-info/SOURCES.txt +0 -0
- {pypdfform-2.3.0 → pypdfform-2.3.2}/PyPDFForm.egg-info/dependency_links.txt +0 -0
- {pypdfform-2.3.0 → pypdfform-2.3.2}/PyPDFForm.egg-info/requires.txt +0 -0
- {pypdfform-2.3.0 → pypdfform-2.3.2}/PyPDFForm.egg-info/top_level.txt +0 -0
- {pypdfform-2.3.0 → pypdfform-2.3.2}/README.md +0 -0
- {pypdfform-2.3.0 → pypdfform-2.3.2}/setup.cfg +0 -0
- {pypdfform-2.3.0 → pypdfform-2.3.2}/tests/test_adobe_mode.py +0 -0
- {pypdfform-2.3.0 → pypdfform-2.3.2}/tests/test_create_widget.py +0 -0
- {pypdfform-2.3.0 → pypdfform-2.3.2}/tests/test_dropdown.py +0 -0
- {pypdfform-2.3.0 → pypdfform-2.3.2}/tests/test_dropdown_simple.py +0 -0
- {pypdfform-2.3.0 → pypdfform-2.3.2}/tests/test_fill_max_length_text_field.py +0 -0
- {pypdfform-2.3.0 → pypdfform-2.3.2}/tests/test_fill_max_length_text_field_simple.py +0 -0
- {pypdfform-2.3.0 → pypdfform-2.3.2}/tests/test_fill_method.py +0 -0
- {pypdfform-2.3.0 → pypdfform-2.3.2}/tests/test_functional.py +0 -0
- {pypdfform-2.3.0 → pypdfform-2.3.2}/tests/test_functional_simple.py +0 -0
- {pypdfform-2.3.0 → pypdfform-2.3.2}/tests/test_paragraph.py +0 -0
- {pypdfform-2.3.0 → pypdfform-2.3.2}/tests/test_paragraph_simple.py +0 -0
- {pypdfform-2.3.0 → pypdfform-2.3.2}/tests/test_preview.py +0 -0
- {pypdfform-2.3.0 → pypdfform-2.3.2}/tests/test_signature.py +0 -0
|
@@ -39,21 +39,30 @@ from .utils import (extract_widget_property, find_pattern_match, handle_color,
|
|
|
39
39
|
|
|
40
40
|
|
|
41
41
|
def set_character_x_paddings(
|
|
42
|
-
pdf_stream: bytes,
|
|
42
|
+
pdf_stream: bytes,
|
|
43
|
+
widgets: Dict[str, WIDGET_TYPES],
|
|
44
|
+
use_full_widget_name: bool,
|
|
43
45
|
) -> Dict[str, WIDGET_TYPES]:
|
|
44
|
-
"""Calculates and sets character spacing for comb text fields.
|
|
46
|
+
"""Calculates and sets character spacing for comb text fields in PDF forms.
|
|
47
|
+
|
|
48
|
+
This function processes each widget in the PDF form and calculates the horizontal spacing
|
|
49
|
+
between characters for comb text fields (fixed-width text fields). The spacing is stored
|
|
50
|
+
in the widget's character_paddings property.
|
|
45
51
|
|
|
46
52
|
Args:
|
|
47
|
-
pdf_stream: PDF form as bytes
|
|
48
|
-
widgets: Dictionary of widget middleware objects
|
|
53
|
+
pdf_stream (bytes): PDF form as bytes
|
|
54
|
+
widgets (Dict[str, WIDGET_TYPES]): Dictionary of widget middleware objects
|
|
55
|
+
use_full_widget_name (bool): Whether to use full widget names including parent names
|
|
49
56
|
|
|
50
57
|
Returns:
|
|
51
|
-
Dict[str, WIDGET_TYPES]: Updated
|
|
58
|
+
Dict[str, WIDGET_TYPES]: Updated widget dictionary with character paddings set for comb fields
|
|
52
59
|
"""
|
|
53
60
|
|
|
54
61
|
for _widgets in get_widgets_by_page(pdf_stream).values():
|
|
55
62
|
for widget in _widgets:
|
|
56
63
|
key = extract_widget_property(widget, WIDGET_KEY_PATTERNS, None, str)
|
|
64
|
+
if use_full_widget_name:
|
|
65
|
+
key = get_widget_full_key(widget)
|
|
57
66
|
_widget = widgets[key]
|
|
58
67
|
|
|
59
68
|
if isinstance(_widget, Text) and _widget.comb is True:
|
|
@@ -166,23 +175,35 @@ def dropdown_to_text(dropdown: Dropdown) -> Text:
|
|
|
166
175
|
def update_text_field_attributes(
|
|
167
176
|
template_stream: bytes,
|
|
168
177
|
widgets: Dict[str, WIDGET_TYPES],
|
|
178
|
+
use_full_widget_name: bool,
|
|
169
179
|
) -> None:
|
|
170
|
-
"""
|
|
180
|
+
"""Update text field properties in a PDF form template.
|
|
171
181
|
|
|
172
|
-
|
|
173
|
-
- Font
|
|
174
|
-
-
|
|
175
|
-
-
|
|
176
|
-
-
|
|
182
|
+
Processes text field widgets in the template to update their visual attributes including:
|
|
183
|
+
- Font properties (family, size, color)
|
|
184
|
+
- Text alignment and wrapping behavior
|
|
185
|
+
- Auto-sizing of text to fit within field bounds
|
|
186
|
+
- Multi-line text field formatting
|
|
177
187
|
|
|
178
188
|
Args:
|
|
179
|
-
template_stream: PDF form
|
|
180
|
-
widgets: Dictionary
|
|
189
|
+
template_stream: Raw bytes of the PDF template containing form fields
|
|
190
|
+
widgets: Dictionary mapping field names to widget objects to update
|
|
191
|
+
use_full_widget_name: If True, uses full hierarchical widget names including parent keys.
|
|
192
|
+
When False (default), uses simple field names.
|
|
193
|
+
|
|
194
|
+
Returns:
|
|
195
|
+
None: Modifies widget objects in-place
|
|
196
|
+
|
|
197
|
+
Note:
|
|
198
|
+
This function modifies the widget objects in-place and does not return anything.
|
|
199
|
+
Changes include font properties, text alignment, and auto-wrapping settings.
|
|
181
200
|
"""
|
|
182
201
|
|
|
183
202
|
for _widgets in get_widgets_by_page(template_stream).values():
|
|
184
203
|
for _widget in _widgets:
|
|
185
204
|
key = extract_widget_property(_widget, WIDGET_KEY_PATTERNS, None, str)
|
|
205
|
+
if use_full_widget_name:
|
|
206
|
+
key = get_widget_full_key(_widget)
|
|
186
207
|
|
|
187
208
|
if isinstance(widgets[key], Text):
|
|
188
209
|
should_adjust_font_size = False
|
|
@@ -249,7 +249,13 @@ class PdfWrapper(FormWrapper):
|
|
|
249
249
|
dict: Field names mapped to their sample values
|
|
250
250
|
"""
|
|
251
251
|
|
|
252
|
-
|
|
252
|
+
result = {}
|
|
253
|
+
for key, value in self.widgets.items():
|
|
254
|
+
if getattr(self, "use_full_widget_name") and key != value.full_name:
|
|
255
|
+
continue
|
|
256
|
+
result[key] = value.sample_value
|
|
257
|
+
|
|
258
|
+
return result
|
|
253
259
|
|
|
254
260
|
@property
|
|
255
261
|
def version(self) -> Union[str, None]:
|
|
@@ -432,9 +438,13 @@ class PdfWrapper(FormWrapper):
|
|
|
432
438
|
if isinstance(value, Dropdown):
|
|
433
439
|
self.widgets[key] = dropdown_to_text(value)
|
|
434
440
|
|
|
435
|
-
update_text_field_attributes(
|
|
441
|
+
update_text_field_attributes(
|
|
442
|
+
self.stream, self.widgets, getattr(self, "use_full_widget_name")
|
|
443
|
+
)
|
|
436
444
|
if self.read():
|
|
437
|
-
self.widgets = set_character_x_paddings(
|
|
445
|
+
self.widgets = set_character_x_paddings(
|
|
446
|
+
self.stream, self.widgets, getattr(self, "use_full_widget_name")
|
|
447
|
+
)
|
|
438
448
|
|
|
439
449
|
self.stream = remove_all_widgets(
|
|
440
450
|
fill(self.stream, self.widgets, getattr(self, "use_full_widget_name"))
|
|
@@ -702,12 +712,13 @@ class PdfWrapper(FormWrapper):
|
|
|
702
712
|
dict: A JSON Schema dictionary following Draft 7 format
|
|
703
713
|
"""
|
|
704
714
|
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
"
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
715
|
+
result = {}
|
|
716
|
+
for key, value in self.widgets.items():
|
|
717
|
+
if getattr(self, "use_full_widget_name") and key != value.full_name:
|
|
718
|
+
continue
|
|
719
|
+
result[key] = value.schema_definition
|
|
720
|
+
|
|
721
|
+
return {"type": "object", "properties": result}
|
|
711
722
|
|
|
712
723
|
@classmethod
|
|
713
724
|
def register_font(
|
|
@@ -14,7 +14,7 @@ def test_init(sample_template_with_full_key):
|
|
|
14
14
|
def test_sample_data(sample_template_with_full_key):
|
|
15
15
|
obj = PdfWrapper(sample_template_with_full_key, use_full_widget_name=True)
|
|
16
16
|
assert "Gain de 2 classes.0" in obj.sample_data
|
|
17
|
-
assert
|
|
17
|
+
assert "0" not in obj.sample_data
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
def test_fill(sample_template_with_full_key):
|
|
@@ -44,6 +44,4 @@ def test_commit_widget_key_updates(sample_template_with_full_key):
|
|
|
44
44
|
def test_schema(sample_template_with_full_key):
|
|
45
45
|
obj = PdfWrapper(sample_template_with_full_key, use_full_widget_name=True)
|
|
46
46
|
assert "Gain de 2 classes.0" in obj.schema["properties"]
|
|
47
|
-
assert
|
|
48
|
-
obj.schema["properties"]["Gain de 2 classes.0"] == obj.schema["properties"]["0"]
|
|
49
|
-
)
|
|
47
|
+
assert "0" not in obj.schema
|
|
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
|