PyPDFForm 4.8.4__tar.gz → 5.0.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.
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PKG-INFO +1 -1
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm/__init__.py +1 -1
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm/cli/update.py +1 -3
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm/lib/annotations/link.py +0 -1
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm/lib/wrapper.py +9 -46
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm.egg-info/PKG-INFO +1 -1
- {pypdfform-4.8.4 → pypdfform-5.0.0}/tests/test_create_widget.py +0 -15
- {pypdfform-4.8.4 → pypdfform-5.0.0}/tests/test_functional.py +2 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/LICENSE +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm/api/__init__.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm/api/common.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm/api/create.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm/api/inspect.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm/api/root.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm/api/update.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm/cli/__init__.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm/cli/common.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm/cli/create.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm/cli/entry.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm/cli/inspect.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm/cli/root.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm/cli/schemas/__init__.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm/cli/schemas/create.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm/cli/schemas/update.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm/lib/__init__.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm/lib/adapter.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm/lib/annotations/__init__.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm/lib/annotations/base.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm/lib/annotations/stamp.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm/lib/annotations/text.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm/lib/annotations/text_markup.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm/lib/assets/__init__.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm/lib/assets/bedrock.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm/lib/assets/blank.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm/lib/constants.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm/lib/coordinate.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm/lib/deprecation.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm/lib/egress.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm/lib/filler.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm/lib/font.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm/lib/hooks.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm/lib/image.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm/lib/middleware/__init__.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm/lib/middleware/base.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm/lib/middleware/checkbox.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm/lib/middleware/dropdown.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm/lib/middleware/image.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm/lib/middleware/radio.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm/lib/middleware/signature.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm/lib/middleware/text.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm/lib/patterns.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm/lib/raw/__init__.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm/lib/raw/circle.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm/lib/raw/ellipse.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm/lib/raw/image.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm/lib/raw/line.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm/lib/raw/rect.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm/lib/raw/text.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm/lib/template.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm/lib/types.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm/lib/utils.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm/lib/watermark.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm/lib/widgets/__init__.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm/lib/widgets/base.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm/lib/widgets/checkbox.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm/lib/widgets/dropdown.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm/lib/widgets/image.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm/lib/widgets/radio.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm/lib/widgets/signature.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm/lib/widgets/text.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm/shared/__init__.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm/shared/utils.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm.egg-info/SOURCES.txt +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm.egg-info/dependency_links.txt +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm.egg-info/entry_points.txt +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm.egg-info/requires.txt +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/PyPDFForm.egg-info/top_level.txt +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/README.md +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/pyproject.toml +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/setup.cfg +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/tests/test_bulk_create_fields.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/tests/test_draw_elements.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/tests/test_dropdown.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/tests/test_extract_middleware_attributes.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/tests/test_fill_max_length_text_field.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/tests/test_font_widths.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/tests/test_generate_appearance_streams.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/tests/test_js.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/tests/test_need_appearances.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/tests/test_paragraph.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/tests/test_signature.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/tests/test_use_full_widget_name.py +0 -0
- {pypdfform-4.8.4 → pypdfform-5.0.0}/tests/test_widget_attr_trigger.py +0 -0
|
@@ -140,9 +140,7 @@ def rename(
|
|
|
140
140
|
for item in input_data:
|
|
141
141
|
for k, v in item.items():
|
|
142
142
|
widget = get_widget(obj, k, cli_widget_key_error("--file"))
|
|
143
|
-
obj.update_widget_key(
|
|
144
|
-
widget.name, v["new_key"], index=v.get("index", 0), defer=True
|
|
145
|
-
)
|
|
143
|
+
obj.update_widget_key(widget.name, v["new_key"], index=v.get("index", 0))
|
|
146
144
|
|
|
147
145
|
obj.commit_widget_key_updates().write(output or pdf)
|
|
148
146
|
|
|
@@ -29,7 +29,6 @@ from .adapter import (fp_or_f_obj_or_f_content_to_content,
|
|
|
29
29
|
fp_or_f_obj_or_stream_to_stream)
|
|
30
30
|
from .constants import VERSION_IDENTIFIER_PREFIX, VERSION_IDENTIFIERS
|
|
31
31
|
from .coordinate import generate_coordinate_grid
|
|
32
|
-
from .deprecation import deprecation_notice
|
|
33
32
|
from .egress import appearance_streams_handler, preserve_pdf_properties
|
|
34
33
|
from .filler import fill
|
|
35
34
|
from .font import (get_all_available_fonts, register_font_acroform,
|
|
@@ -160,7 +159,7 @@ class PdfWrapper:
|
|
|
160
159
|
unique_suffix = generate_unique_suffix()
|
|
161
160
|
for k in self.widgets:
|
|
162
161
|
if k in other.widgets:
|
|
163
|
-
other.update_widget_key(k, f"{k}-{unique_suffix}"
|
|
162
|
+
other.update_widget_key(k, f"{k}-{unique_suffix}")
|
|
164
163
|
|
|
165
164
|
other.commit_widget_key_updates()
|
|
166
165
|
|
|
@@ -246,7 +245,7 @@ class PdfWrapper:
|
|
|
246
245
|
"properties": {
|
|
247
246
|
key: value.schema_definition for key, value in self.widgets.items()
|
|
248
247
|
},
|
|
249
|
-
"additionalProperties":
|
|
248
|
+
"additionalProperties": False,
|
|
250
249
|
}
|
|
251
250
|
|
|
252
251
|
@property
|
|
@@ -666,44 +665,20 @@ class PdfWrapper:
|
|
|
666
665
|
|
|
667
666
|
return self
|
|
668
667
|
|
|
669
|
-
@deprecation_notice(to_replace="bulk_create_fields")
|
|
670
|
-
def create_field(
|
|
671
|
-
self,
|
|
672
|
-
field: FieldTypes,
|
|
673
|
-
) -> PdfWrapper:
|
|
674
|
-
"""
|
|
675
|
-
Creates a new form field (widget) on the PDF using a `FieldTypes` object.
|
|
676
|
-
|
|
677
|
-
This method simplifies widget creation by taking a `FieldTypes` object
|
|
678
|
-
and delegating to the internal `_bulk_create_fields` method.
|
|
679
|
-
|
|
680
|
-
Args:
|
|
681
|
-
field (FieldTypes): An object representing the field to create.
|
|
682
|
-
This object encapsulates all necessary properties like name,
|
|
683
|
-
page number, coordinates, and type of the field.
|
|
684
|
-
|
|
685
|
-
Returns:
|
|
686
|
-
PdfWrapper: The `PdfWrapper` object, allowing for method chaining.
|
|
687
|
-
"""
|
|
688
|
-
|
|
689
|
-
return self._bulk_create_fields([field])
|
|
690
|
-
|
|
691
668
|
def update_widget_key(
|
|
692
|
-
self, old_key: str, new_key: str, index: int = 0
|
|
669
|
+
self, old_key: str, new_key: str, index: int = 0
|
|
693
670
|
) -> PdfWrapper:
|
|
694
671
|
"""
|
|
695
672
|
Updates the key (name) of a widget, allowing you to rename form fields.
|
|
696
673
|
|
|
697
|
-
This method
|
|
698
|
-
standardizing field names or resolving naming conflicts. The update
|
|
699
|
-
|
|
674
|
+
This method queues a change to the name of a form field in the PDF. This can be useful for
|
|
675
|
+
standardizing field names or resolving naming conflicts. The queued update is applied when
|
|
676
|
+
`commit_widget_key_updates` is called.
|
|
700
677
|
|
|
701
678
|
Args:
|
|
702
679
|
old_key (str): The old key of the widget that you want to rename.
|
|
703
680
|
new_key (str): The new key to assign to the widget.
|
|
704
681
|
index (int): The index of the widget if there are multiple widgets with the same name (default: 0).
|
|
705
|
-
defer (bool): Whether to defer the update. If True, the update is added to a queue and applied
|
|
706
|
-
when `commit_widget_key_updates` is called. If False, the update is applied immediately (default: False).
|
|
707
682
|
|
|
708
683
|
Returns:
|
|
709
684
|
PdfWrapper: The PdfWrapper object.
|
|
@@ -712,27 +687,15 @@ class PdfWrapper:
|
|
|
712
687
|
if getattr(self, "use_full_widget_name"):
|
|
713
688
|
raise NotImplementedError
|
|
714
689
|
|
|
715
|
-
|
|
716
|
-
deprecation_notice(to_replace="", param="defer").emit_notice(
|
|
717
|
-
self, "update_widget_key"
|
|
718
|
-
)
|
|
719
|
-
self._keys_to_update.append((old_key, new_key, index))
|
|
720
|
-
return self
|
|
721
|
-
|
|
722
|
-
self._key_update_tracker[new_key] = old_key
|
|
723
|
-
self._stream = update_widget_keys(
|
|
724
|
-
self._read(), self.widgets, [old_key], [new_key], [index]
|
|
725
|
-
)
|
|
726
|
-
self._init_helper()
|
|
727
|
-
|
|
690
|
+
self._keys_to_update.append((old_key, new_key, index))
|
|
728
691
|
return self
|
|
729
692
|
|
|
730
693
|
def commit_widget_key_updates(self) -> PdfWrapper:
|
|
731
694
|
"""
|
|
732
695
|
Commits deferred widget key updates, applying all queued key renames to the PDF.
|
|
733
696
|
|
|
734
|
-
This method applies all widget key updates
|
|
735
|
-
|
|
697
|
+
This method applies all widget key updates queued by the `update_widget_key` method. It updates
|
|
698
|
+
the underlying PDF stream with the new key names.
|
|
736
699
|
|
|
737
700
|
Returns:
|
|
738
701
|
PdfWrapper: The PdfWrapper object.
|
|
@@ -7,21 +7,6 @@ import pytest
|
|
|
7
7
|
from PyPDFForm import Fields, PdfWrapper
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
def test_create_field_deprecated(template_stream):
|
|
11
|
-
with pytest.warns(
|
|
12
|
-
DeprecationWarning,
|
|
13
|
-
match="PdfWrapper.create_field will be deprecated soon. Use PdfWrapper.bulk_create_fields instead.",
|
|
14
|
-
):
|
|
15
|
-
assert (
|
|
16
|
-
PdfWrapper(template_stream)
|
|
17
|
-
.create_field(Fields.TextField("foo", 1, 100, 100))
|
|
18
|
-
.read()
|
|
19
|
-
== PdfWrapper(template_stream)
|
|
20
|
-
.bulk_create_fields([Fields.TextField("foo", 1, 100, 100)])
|
|
21
|
-
.read()
|
|
22
|
-
)
|
|
23
|
-
|
|
24
|
-
|
|
25
10
|
@pytest.mark.posix_only
|
|
26
11
|
def test_create_checkbox_complex_fill(template_stream, pdf_samples, request):
|
|
27
12
|
expected_path = os.path.join(
|
|
@@ -645,6 +645,7 @@ def test_update_radio_key(template_with_radiobutton_stream, pdf_samples, request
|
|
|
645
645
|
with open(expected_path, "rb+") as f:
|
|
646
646
|
obj = PdfWrapper(template_with_radiobutton_stream)
|
|
647
647
|
obj.update_widget_key("radio_3", "RADIO")
|
|
648
|
+
obj.commit_widget_key_updates()
|
|
648
649
|
obj.fill({"RADIO": 0})
|
|
649
650
|
|
|
650
651
|
request.config.results["expected_path"] = expected_path
|
|
@@ -664,6 +665,7 @@ def test_update_sejda_key(sejda_template, pdf_samples, request):
|
|
|
664
665
|
obj.update_widget_key("at_future_date", "FUTURE_DATE")
|
|
665
666
|
obj.update_widget_key("purchase_option", "PURCHASE_OPTION")
|
|
666
667
|
obj.update_widget_key("buyer_signed_date", "BUYER_SIGNED_DATE")
|
|
668
|
+
obj.commit_widget_key_updates()
|
|
667
669
|
obj.fill(
|
|
668
670
|
{
|
|
669
671
|
"YEAR": "12",
|
|
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
|
|
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
|