PyPDFForm 3.5.4__tar.gz → 3.5.5__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-3.5.4 → pypdfform-3.5.5}/PKG-INFO +2 -2
- {pypdfform-3.5.4 → pypdfform-3.5.5}/PyPDFForm/__init__.py +1 -1
- {pypdfform-3.5.4 → pypdfform-3.5.5}/PyPDFForm.egg-info/PKG-INFO +2 -2
- {pypdfform-3.5.4 → pypdfform-3.5.5}/README.md +1 -1
- {pypdfform-3.5.4 → pypdfform-3.5.5}/LICENSE +0 -0
- {pypdfform-3.5.4 → pypdfform-3.5.5}/PyPDFForm/adapter.py +0 -0
- {pypdfform-3.5.4 → pypdfform-3.5.5}/PyPDFForm/constants.py +0 -0
- {pypdfform-3.5.4 → pypdfform-3.5.5}/PyPDFForm/coordinate.py +0 -0
- {pypdfform-3.5.4 → pypdfform-3.5.5}/PyPDFForm/filler.py +0 -0
- {pypdfform-3.5.4 → pypdfform-3.5.5}/PyPDFForm/font.py +0 -0
- {pypdfform-3.5.4 → pypdfform-3.5.5}/PyPDFForm/hooks.py +0 -0
- {pypdfform-3.5.4 → pypdfform-3.5.5}/PyPDFForm/image.py +0 -0
- {pypdfform-3.5.4 → pypdfform-3.5.5}/PyPDFForm/middleware/__init__.py +0 -0
- {pypdfform-3.5.4 → pypdfform-3.5.5}/PyPDFForm/middleware/base.py +0 -0
- {pypdfform-3.5.4 → pypdfform-3.5.5}/PyPDFForm/middleware/checkbox.py +0 -0
- {pypdfform-3.5.4 → pypdfform-3.5.5}/PyPDFForm/middleware/dropdown.py +0 -0
- {pypdfform-3.5.4 → pypdfform-3.5.5}/PyPDFForm/middleware/image.py +0 -0
- {pypdfform-3.5.4 → pypdfform-3.5.5}/PyPDFForm/middleware/radio.py +0 -0
- {pypdfform-3.5.4 → pypdfform-3.5.5}/PyPDFForm/middleware/signature.py +0 -0
- {pypdfform-3.5.4 → pypdfform-3.5.5}/PyPDFForm/middleware/text.py +0 -0
- {pypdfform-3.5.4 → pypdfform-3.5.5}/PyPDFForm/patterns.py +0 -0
- {pypdfform-3.5.4 → pypdfform-3.5.5}/PyPDFForm/template.py +0 -0
- {pypdfform-3.5.4 → pypdfform-3.5.5}/PyPDFForm/utils.py +0 -0
- {pypdfform-3.5.4 → pypdfform-3.5.5}/PyPDFForm/watermark.py +0 -0
- {pypdfform-3.5.4 → pypdfform-3.5.5}/PyPDFForm/widgets/__init__.py +0 -0
- {pypdfform-3.5.4 → pypdfform-3.5.5}/PyPDFForm/widgets/base.py +29 -29
- {pypdfform-3.5.4 → pypdfform-3.5.5}/PyPDFForm/widgets/bedrock.py +0 -0
- {pypdfform-3.5.4 → pypdfform-3.5.5}/PyPDFForm/widgets/checkbox.py +29 -29
- {pypdfform-3.5.4 → pypdfform-3.5.5}/PyPDFForm/widgets/dropdown.py +37 -37
- {pypdfform-3.5.4 → pypdfform-3.5.5}/PyPDFForm/widgets/image.py +16 -16
- {pypdfform-3.5.4 → pypdfform-3.5.5}/PyPDFForm/widgets/radio.py +25 -25
- {pypdfform-3.5.4 → pypdfform-3.5.5}/PyPDFForm/widgets/signature.py +20 -20
- {pypdfform-3.5.4 → pypdfform-3.5.5}/PyPDFForm/widgets/text.py +37 -37
- {pypdfform-3.5.4 → pypdfform-3.5.5}/PyPDFForm/wrapper.py +0 -0
- {pypdfform-3.5.4 → pypdfform-3.5.5}/PyPDFForm.egg-info/SOURCES.txt +0 -0
- {pypdfform-3.5.4 → pypdfform-3.5.5}/PyPDFForm.egg-info/dependency_links.txt +0 -0
- {pypdfform-3.5.4 → pypdfform-3.5.5}/PyPDFForm.egg-info/requires.txt +0 -0
- {pypdfform-3.5.4 → pypdfform-3.5.5}/PyPDFForm.egg-info/top_level.txt +0 -0
- {pypdfform-3.5.4 → pypdfform-3.5.5}/pyproject.toml +0 -0
- {pypdfform-3.5.4 → pypdfform-3.5.5}/setup.cfg +0 -0
- {pypdfform-3.5.4 → pypdfform-3.5.5}/tests/test_adobe_mode.py +0 -0
- {pypdfform-3.5.4 → pypdfform-3.5.5}/tests/test_create_widget.py +0 -0
- {pypdfform-3.5.4 → pypdfform-3.5.5}/tests/test_dropdown.py +0 -0
- {pypdfform-3.5.4 → pypdfform-3.5.5}/tests/test_extract_values.py +0 -0
- {pypdfform-3.5.4 → pypdfform-3.5.5}/tests/test_fill_max_length_text_field.py +0 -0
- {pypdfform-3.5.4 → pypdfform-3.5.5}/tests/test_fill_method.py +0 -0
- {pypdfform-3.5.4 → pypdfform-3.5.5}/tests/test_font_widths.py +0 -0
- {pypdfform-3.5.4 → pypdfform-3.5.5}/tests/test_functional.py +0 -0
- {pypdfform-3.5.4 → pypdfform-3.5.5}/tests/test_paragraph.py +0 -0
- {pypdfform-3.5.4 → pypdfform-3.5.5}/tests/test_signature.py +0 -0
- {pypdfform-3.5.4 → pypdfform-3.5.5}/tests/test_use_full_widget_name.py +0 -0
- {pypdfform-3.5.4 → pypdfform-3.5.5}/tests/test_widget_attr_trigger.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: PyPDFForm
|
|
3
|
-
Version: 3.5.
|
|
3
|
+
Version: 3.5.5
|
|
4
4
|
Summary: The Python library for PDF forms.
|
|
5
5
|
Author: Jinge Li
|
|
6
6
|
License-Expression: MIT
|
|
@@ -49,7 +49,7 @@ Dynamic: license-file
|
|
|
49
49
|
<a href="https://github.com/chinapandaman/PyPDFForm/actions/workflows/python-package.yml"><img src="https://img.shields.io/badge/coverage-100%25-green"></a>
|
|
50
50
|
<a href="https://github.com/chinapandaman/PyPDFForm/raw/master/LICENSE"><img src="https://img.shields.io/github/license/chinapandaman/pypdfform?label=license&color=orange"></a>
|
|
51
51
|
<a href="https://www.python.org/downloads/"><img src="https://img.shields.io/pypi/pyversions/pypdfform?label=python&color=gold"></a>
|
|
52
|
-
<a href="https://
|
|
52
|
+
<a href="https://pypistats.org/packages/pypdfform"><img src="https://img.shields.io/pypi/dm/pypdfform?color=blue"></a>
|
|
53
53
|
</p>
|
|
54
54
|
|
|
55
55
|
## Introduction
|
|
@@ -20,7 +20,7 @@ The library supports various PDF form features, including:
|
|
|
20
20
|
PyPDFForm aims to simplify PDF form manipulation, making it accessible to developers of all skill levels.
|
|
21
21
|
"""
|
|
22
22
|
|
|
23
|
-
__version__ = "3.5.
|
|
23
|
+
__version__ = "3.5.5"
|
|
24
24
|
|
|
25
25
|
from .middleware.text import Text # exposing for setting global font attrs
|
|
26
26
|
from .widgets import Fields
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: PyPDFForm
|
|
3
|
-
Version: 3.5.
|
|
3
|
+
Version: 3.5.5
|
|
4
4
|
Summary: The Python library for PDF forms.
|
|
5
5
|
Author: Jinge Li
|
|
6
6
|
License-Expression: MIT
|
|
@@ -49,7 +49,7 @@ Dynamic: license-file
|
|
|
49
49
|
<a href="https://github.com/chinapandaman/PyPDFForm/actions/workflows/python-package.yml"><img src="https://img.shields.io/badge/coverage-100%25-green"></a>
|
|
50
50
|
<a href="https://github.com/chinapandaman/PyPDFForm/raw/master/LICENSE"><img src="https://img.shields.io/github/license/chinapandaman/pypdfform?label=license&color=orange"></a>
|
|
51
51
|
<a href="https://www.python.org/downloads/"><img src="https://img.shields.io/pypi/pyversions/pypdfform?label=python&color=gold"></a>
|
|
52
|
-
<a href="https://
|
|
52
|
+
<a href="https://pypistats.org/packages/pypdfform"><img src="https://img.shields.io/pypi/dm/pypdfform?color=blue"></a>
|
|
53
53
|
</p>
|
|
54
54
|
|
|
55
55
|
## Introduction
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
<a href="https://github.com/chinapandaman/PyPDFForm/actions/workflows/python-package.yml"><img src="https://img.shields.io/badge/coverage-100%25-green"></a>
|
|
9
9
|
<a href="https://github.com/chinapandaman/PyPDFForm/raw/master/LICENSE"><img src="https://img.shields.io/github/license/chinapandaman/pypdfform?label=license&color=orange"></a>
|
|
10
10
|
<a href="https://www.python.org/downloads/"><img src="https://img.shields.io/pypi/pyversions/pypdfform?label=python&color=gold"></a>
|
|
11
|
-
<a href="https://
|
|
11
|
+
<a href="https://pypistats.org/packages/pypdfform"><img src="https://img.shields.io/pypi/dm/pypdfform?color=blue"></a>
|
|
12
12
|
</p>
|
|
13
13
|
|
|
14
14
|
## Introduction
|
|
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
|
|
@@ -25,35 +25,6 @@ from ..constants import fieldFlags, required
|
|
|
25
25
|
from ..utils import stream_to_io
|
|
26
26
|
|
|
27
27
|
|
|
28
|
-
@dataclass
|
|
29
|
-
class Field:
|
|
30
|
-
"""
|
|
31
|
-
Base dataclass for all PDF form fields.
|
|
32
|
-
|
|
33
|
-
This class defines the common properties that all types of form fields
|
|
34
|
-
(e.g., text fields, checkboxes, radio buttons) share. Specific field types
|
|
35
|
-
will extend this class to add their unique attributes.
|
|
36
|
-
|
|
37
|
-
Attributes:
|
|
38
|
-
name (str): The name of the form field. This is used to identify the
|
|
39
|
-
field within the PDF document.
|
|
40
|
-
page_number (int): The 1-based page number on which the field is located.
|
|
41
|
-
x (float): The x-coordinate of the field's position on the page.
|
|
42
|
-
y (float): The y-coordinate of the field's position on the page.
|
|
43
|
-
required (Optional[bool]): Indicates whether the field is required to be
|
|
44
|
-
filled by the user. Defaults to None, meaning not explicitly set.
|
|
45
|
-
tooltip (Optional[str]): A tooltip message that appears when the user
|
|
46
|
-
hovers over the field. Defaults to None.
|
|
47
|
-
"""
|
|
48
|
-
|
|
49
|
-
name: str
|
|
50
|
-
page_number: int
|
|
51
|
-
x: float
|
|
52
|
-
y: float
|
|
53
|
-
required: Optional[bool] = None
|
|
54
|
-
tooltip: Optional[str] = None
|
|
55
|
-
|
|
56
|
-
|
|
57
28
|
class Widget:
|
|
58
29
|
"""
|
|
59
30
|
Base class for all widgets in PyPDFForm.
|
|
@@ -219,3 +190,32 @@ class Widget:
|
|
|
219
190
|
watermark.read() if i == self.page_number - 1 else b""
|
|
220
191
|
for i in range(page_count)
|
|
221
192
|
]
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
@dataclass
|
|
196
|
+
class Field:
|
|
197
|
+
"""
|
|
198
|
+
Base dataclass for all PDF form fields.
|
|
199
|
+
|
|
200
|
+
This class defines the common properties that all types of form fields
|
|
201
|
+
(e.g., text fields, checkboxes, radio buttons) share. Specific field types
|
|
202
|
+
will extend this class to add their unique attributes.
|
|
203
|
+
|
|
204
|
+
Attributes:
|
|
205
|
+
name (str): The name of the form field. This is used to identify the
|
|
206
|
+
field within the PDF document.
|
|
207
|
+
page_number (int): The 1-based page number on which the field is located.
|
|
208
|
+
x (float): The x-coordinate of the field's position on the page.
|
|
209
|
+
y (float): The y-coordinate of the field's position on the page.
|
|
210
|
+
required (Optional[bool]): Indicates whether the field is required to be
|
|
211
|
+
filled by the user. Defaults to None, meaning not explicitly set.
|
|
212
|
+
tooltip (Optional[str]): A tooltip message that appears when the user
|
|
213
|
+
hovers over the field. Defaults to None.
|
|
214
|
+
"""
|
|
215
|
+
|
|
216
|
+
name: str
|
|
217
|
+
page_number: int
|
|
218
|
+
x: float
|
|
219
|
+
y: float
|
|
220
|
+
required: Optional[bool] = None
|
|
221
|
+
tooltip: Optional[str] = None
|
|
File without changes
|
|
@@ -16,35 +16,6 @@ from typing import Optional, Tuple
|
|
|
16
16
|
from .base import Field, Widget
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
@dataclass
|
|
20
|
-
class CheckBoxField(Field):
|
|
21
|
-
"""
|
|
22
|
-
Represents a checkbox field in a PDF document.
|
|
23
|
-
|
|
24
|
-
This dataclass extends the `Field` base class and defines the specific
|
|
25
|
-
attributes that can be configured for a checkbox field.
|
|
26
|
-
|
|
27
|
-
Attributes:
|
|
28
|
-
_field_type (str): The type of the field, fixed as "checkbox".
|
|
29
|
-
size (Optional[float]): The size of the checkbox.
|
|
30
|
-
button_style (Optional[str]): The visual style of the checkbox button
|
|
31
|
-
(e.g., "check", "circle", "cross").
|
|
32
|
-
tick_color (Optional[Tuple[float, ...]]): The color of the checkmark or tick.
|
|
33
|
-
bg_color (Optional[Tuple[float, ...]]): The background color of the checkbox.
|
|
34
|
-
border_color (Optional[Tuple[float, ...]]): The color of the checkbox's border.
|
|
35
|
-
border_width (Optional[float]): The width of the checkbox's border.
|
|
36
|
-
"""
|
|
37
|
-
|
|
38
|
-
_field_type: str = "checkbox"
|
|
39
|
-
|
|
40
|
-
size: Optional[float] = None
|
|
41
|
-
button_style: Optional[str] = None
|
|
42
|
-
tick_color: Optional[Tuple[float, ...]] = None
|
|
43
|
-
bg_color: Optional[Tuple[float, ...]] = None
|
|
44
|
-
border_color: Optional[Tuple[float, ...]] = None
|
|
45
|
-
border_width: Optional[float] = None
|
|
46
|
-
|
|
47
|
-
|
|
48
19
|
class CheckBoxWidget(Widget):
|
|
49
20
|
"""
|
|
50
21
|
Represents a checkbox widget in a PDF form.
|
|
@@ -74,3 +45,32 @@ class CheckBoxWidget(Widget):
|
|
|
74
45
|
COLOR_PARAMS = ["tick_color", "bg_color", "border_color"]
|
|
75
46
|
ALLOWED_HOOK_PARAMS = ["size"]
|
|
76
47
|
ACRO_FORM_FUNC = "checkbox"
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
@dataclass
|
|
51
|
+
class CheckBoxField(Field):
|
|
52
|
+
"""
|
|
53
|
+
Represents a checkbox field in a PDF document.
|
|
54
|
+
|
|
55
|
+
This dataclass extends the `Field` base class and defines the specific
|
|
56
|
+
attributes that can be configured for a checkbox field.
|
|
57
|
+
|
|
58
|
+
Attributes:
|
|
59
|
+
_field_type (str): The type of the field, fixed as "checkbox".
|
|
60
|
+
size (Optional[float]): The size of the checkbox.
|
|
61
|
+
button_style (Optional[str]): The visual style of the checkbox button
|
|
62
|
+
(e.g., "check", "circle", "cross").
|
|
63
|
+
tick_color (Optional[Tuple[float, ...]]): The color of the checkmark or tick.
|
|
64
|
+
bg_color (Optional[Tuple[float, ...]]): The background color of the checkbox.
|
|
65
|
+
border_color (Optional[Tuple[float, ...]]): The color of the checkbox's border.
|
|
66
|
+
border_width (Optional[float]): The width of the checkbox's border.
|
|
67
|
+
"""
|
|
68
|
+
|
|
69
|
+
_field_type: str = "checkbox"
|
|
70
|
+
|
|
71
|
+
size: Optional[float] = None
|
|
72
|
+
button_style: Optional[str] = None
|
|
73
|
+
tick_color: Optional[Tuple[float, ...]] = None
|
|
74
|
+
bg_color: Optional[Tuple[float, ...]] = None
|
|
75
|
+
border_color: Optional[Tuple[float, ...]] = None
|
|
76
|
+
border_width: Optional[float] = None
|
|
@@ -17,43 +17,6 @@ from .base import Field
|
|
|
17
17
|
from .text import TextWidget
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
@dataclass
|
|
21
|
-
class DropdownField(Field):
|
|
22
|
-
"""
|
|
23
|
-
Represents a dropdown field in a PDF document.
|
|
24
|
-
|
|
25
|
-
This dataclass extends the `Field` base class and defines the specific
|
|
26
|
-
attributes that can be configured for a dropdown selection field.
|
|
27
|
-
|
|
28
|
-
Attributes:
|
|
29
|
-
_field_type (str): The type of the field, fixed as "dropdown".
|
|
30
|
-
options (Optional[List[Union[str, Tuple[str, str]]]]): A list of options
|
|
31
|
-
available in the dropdown. Each option can be a string (display value)
|
|
32
|
-
or a tuple of strings (display value, export value).
|
|
33
|
-
width (Optional[float]): The width of the dropdown field.
|
|
34
|
-
height (Optional[float]): The height of the dropdown field.
|
|
35
|
-
font (Optional[str]): The font to use for the dropdown text.
|
|
36
|
-
font_size (Optional[float]): The font size for the dropdown text.
|
|
37
|
-
font_color (Optional[Tuple[float, ...]]): The color of the font as an RGB or RGBA tuple.
|
|
38
|
-
bg_color (Optional[Tuple[float, ...]]): The background color of the dropdown field.
|
|
39
|
-
border_color (Optional[Tuple[float, ...]]): The color of the dropdown's border.
|
|
40
|
-
border_width (Optional[float]): The width of the dropdown's border.
|
|
41
|
-
"""
|
|
42
|
-
|
|
43
|
-
_field_type: str = "dropdown"
|
|
44
|
-
|
|
45
|
-
options: Optional[List[Union[str, Tuple[str, str]]]] = None
|
|
46
|
-
width: Optional[float] = None
|
|
47
|
-
height: Optional[float] = None
|
|
48
|
-
# pylint: disable=R0801
|
|
49
|
-
font: Optional[str] = None
|
|
50
|
-
font_size: Optional[float] = None
|
|
51
|
-
font_color: Optional[Tuple[float, ...]] = None
|
|
52
|
-
bg_color: Optional[Tuple[float, ...]] = None
|
|
53
|
-
border_color: Optional[Tuple[float, ...]] = None
|
|
54
|
-
border_width: Optional[float] = None
|
|
55
|
-
|
|
56
|
-
|
|
57
20
|
class DropdownWidget(TextWidget):
|
|
58
21
|
"""
|
|
59
22
|
Represents a dropdown widget in a PDF form.
|
|
@@ -94,3 +57,40 @@ class DropdownWidget(TextWidget):
|
|
|
94
57
|
super().__init__(name, page_number, x, y, **kwargs)
|
|
95
58
|
self.acro_form_params["wkind"] = "choice"
|
|
96
59
|
self.acro_form_params["value"] = self.acro_form_params["options"][0]
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
@dataclass
|
|
63
|
+
class DropdownField(Field):
|
|
64
|
+
"""
|
|
65
|
+
Represents a dropdown field in a PDF document.
|
|
66
|
+
|
|
67
|
+
This dataclass extends the `Field` base class and defines the specific
|
|
68
|
+
attributes that can be configured for a dropdown selection field.
|
|
69
|
+
|
|
70
|
+
Attributes:
|
|
71
|
+
_field_type (str): The type of the field, fixed as "dropdown".
|
|
72
|
+
options (Optional[List[Union[str, Tuple[str, str]]]]): A list of options
|
|
73
|
+
available in the dropdown. Each option can be a string (display value)
|
|
74
|
+
or a tuple of strings (display value, export value).
|
|
75
|
+
width (Optional[float]): The width of the dropdown field.
|
|
76
|
+
height (Optional[float]): The height of the dropdown field.
|
|
77
|
+
font (Optional[str]): The font to use for the dropdown text.
|
|
78
|
+
font_size (Optional[float]): The font size for the dropdown text.
|
|
79
|
+
font_color (Optional[Tuple[float, ...]]): The color of the font as an RGB or RGBA tuple.
|
|
80
|
+
bg_color (Optional[Tuple[float, ...]]): The background color of the dropdown field.
|
|
81
|
+
border_color (Optional[Tuple[float, ...]]): The color of the dropdown's border.
|
|
82
|
+
border_width (Optional[float]): The width of the dropdown's border.
|
|
83
|
+
"""
|
|
84
|
+
|
|
85
|
+
_field_type: str = "dropdown"
|
|
86
|
+
|
|
87
|
+
options: Optional[List[Union[str, Tuple[str, str]]]] = None
|
|
88
|
+
width: Optional[float] = None
|
|
89
|
+
height: Optional[float] = None
|
|
90
|
+
# pylint: disable=R0801
|
|
91
|
+
font: Optional[str] = None
|
|
92
|
+
font_size: Optional[float] = None
|
|
93
|
+
font_color: Optional[Tuple[float, ...]] = None
|
|
94
|
+
bg_color: Optional[Tuple[float, ...]] = None
|
|
95
|
+
border_color: Optional[Tuple[float, ...]] = None
|
|
96
|
+
border_width: Optional[float] = None
|
|
@@ -16,22 +16,6 @@ from dataclasses import dataclass
|
|
|
16
16
|
from .signature import SignatureField, SignatureWidget
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
@dataclass
|
|
20
|
-
class ImageField(SignatureField):
|
|
21
|
-
"""
|
|
22
|
-
Represents an image field in a PDF document.
|
|
23
|
-
|
|
24
|
-
This dataclass extends the `SignatureField` base class and defines the
|
|
25
|
-
specific attributes for an image input field. It inherits `width` and
|
|
26
|
-
`height` from `SignatureField` as images also have dimensions.
|
|
27
|
-
|
|
28
|
-
Attributes:
|
|
29
|
-
_field_type (str): The type of the field, fixed as "image".
|
|
30
|
-
"""
|
|
31
|
-
|
|
32
|
-
_field_type: str = "image"
|
|
33
|
-
|
|
34
|
-
|
|
35
19
|
class ImageWidget(SignatureWidget):
|
|
36
20
|
"""
|
|
37
21
|
Represents an image widget in a PDF form.
|
|
@@ -47,3 +31,19 @@ class ImageWidget(SignatureWidget):
|
|
|
47
31
|
"""
|
|
48
32
|
|
|
49
33
|
BEDROCK_WIDGET_TO_COPY = "image"
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
@dataclass
|
|
37
|
+
class ImageField(SignatureField):
|
|
38
|
+
"""
|
|
39
|
+
Represents an image field in a PDF document.
|
|
40
|
+
|
|
41
|
+
This dataclass extends the `SignatureField` base class and defines the
|
|
42
|
+
specific attributes for an image input field. It inherits `width` and
|
|
43
|
+
`height` from `SignatureField` as images also have dimensions.
|
|
44
|
+
|
|
45
|
+
Attributes:
|
|
46
|
+
_field_type (str): The type of the field, fixed as "image".
|
|
47
|
+
"""
|
|
48
|
+
|
|
49
|
+
_field_type: str = "image"
|
|
@@ -18,31 +18,6 @@ from reportlab.pdfgen.canvas import Canvas
|
|
|
18
18
|
from .checkbox import CheckBoxField, CheckBoxWidget
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
@dataclass
|
|
22
|
-
class RadioGroup(CheckBoxField):
|
|
23
|
-
"""
|
|
24
|
-
Represents a group of radio buttons in a PDF document.
|
|
25
|
-
|
|
26
|
-
This dataclass extends the `CheckBoxField` base class and defines the specific
|
|
27
|
-
attributes that can be configured for a radio button group. Unlike a single
|
|
28
|
-
checkbox, a radio group allows for multiple positions (x, y coordinates)
|
|
29
|
-
where individual radio buttons can be placed, but only one can be selected.
|
|
30
|
-
|
|
31
|
-
Attributes:
|
|
32
|
-
_field_type (str): The type of the field, fixed as "radio".
|
|
33
|
-
x (List[float]): A list of x-coordinates for each radio button in the group.
|
|
34
|
-
y (List[float]): A list of y-coordinates for each radio button in the group.
|
|
35
|
-
shape (Optional[str]): The shape of the radio button. Valid values are
|
|
36
|
-
"circle" or "square". Defaults to None, which typically means a default circle shape.
|
|
37
|
-
"""
|
|
38
|
-
|
|
39
|
-
_field_type: str = "radio"
|
|
40
|
-
|
|
41
|
-
x: List[float]
|
|
42
|
-
y: List[float]
|
|
43
|
-
shape: Optional[str] = None
|
|
44
|
-
|
|
45
|
-
|
|
46
21
|
class RadioWidget(CheckBoxWidget):
|
|
47
22
|
"""
|
|
48
23
|
Represents a radio button widget in a PDF form.
|
|
@@ -97,3 +72,28 @@ class RadioWidget(CheckBoxWidget):
|
|
|
97
72
|
new_acro_form_params["y"] = y
|
|
98
73
|
new_acro_form_params["value"] = str(i)
|
|
99
74
|
getattr(canvas.acroForm, self.ACRO_FORM_FUNC)(**new_acro_form_params)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
@dataclass
|
|
78
|
+
class RadioGroup(CheckBoxField):
|
|
79
|
+
"""
|
|
80
|
+
Represents a group of radio buttons in a PDF document.
|
|
81
|
+
|
|
82
|
+
This dataclass extends the `CheckBoxField` base class and defines the specific
|
|
83
|
+
attributes that can be configured for a radio button group. Unlike a single
|
|
84
|
+
checkbox, a radio group allows for multiple positions (x, y coordinates)
|
|
85
|
+
where individual radio buttons can be placed, but only one can be selected.
|
|
86
|
+
|
|
87
|
+
Attributes:
|
|
88
|
+
_field_type (str): The type of the field, fixed as "radio".
|
|
89
|
+
x (List[float]): A list of x-coordinates for each radio button in the group.
|
|
90
|
+
y (List[float]): A list of y-coordinates for each radio button in the group.
|
|
91
|
+
shape (Optional[str]): The shape of the radio button. Valid values are
|
|
92
|
+
"circle" or "square". Defaults to None, which typically means a default circle shape.
|
|
93
|
+
"""
|
|
94
|
+
|
|
95
|
+
_field_type: str = "radio"
|
|
96
|
+
|
|
97
|
+
x: List[float]
|
|
98
|
+
y: List[float]
|
|
99
|
+
shape: Optional[str] = None
|
|
@@ -26,26 +26,6 @@ from .base import Field
|
|
|
26
26
|
from .bedrock import BEDROCK_PDF
|
|
27
27
|
|
|
28
28
|
|
|
29
|
-
@dataclass
|
|
30
|
-
class SignatureField(Field):
|
|
31
|
-
"""
|
|
32
|
-
Represents a signature field in a PDF document.
|
|
33
|
-
|
|
34
|
-
This dataclass extends the `Field` base class and defines the specific
|
|
35
|
-
attributes that can be configured for a signature input field.
|
|
36
|
-
|
|
37
|
-
Attributes:
|
|
38
|
-
_field_type (str): The type of the field, fixed as "signature".
|
|
39
|
-
width (Optional[float]): The width of the signature field.
|
|
40
|
-
height (Optional[float]): The height of the signature field.
|
|
41
|
-
"""
|
|
42
|
-
|
|
43
|
-
_field_type: str = "signature"
|
|
44
|
-
|
|
45
|
-
width: Optional[float] = None
|
|
46
|
-
height: Optional[float] = None
|
|
47
|
-
|
|
48
|
-
|
|
49
29
|
class SignatureWidget:
|
|
50
30
|
"""
|
|
51
31
|
Represents a signature widget in a PDF form.
|
|
@@ -151,3 +131,23 @@ class SignatureWidget:
|
|
|
151
131
|
f.read() if i == self.page_number - 1 else b""
|
|
152
132
|
for i in range(page_count)
|
|
153
133
|
]
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
@dataclass
|
|
137
|
+
class SignatureField(Field):
|
|
138
|
+
"""
|
|
139
|
+
Represents a signature field in a PDF document.
|
|
140
|
+
|
|
141
|
+
This dataclass extends the `Field` base class and defines the specific
|
|
142
|
+
attributes that can be configured for a signature input field.
|
|
143
|
+
|
|
144
|
+
Attributes:
|
|
145
|
+
_field_type (str): The type of the field, fixed as "signature".
|
|
146
|
+
width (Optional[float]): The width of the signature field.
|
|
147
|
+
height (Optional[float]): The height of the signature field.
|
|
148
|
+
"""
|
|
149
|
+
|
|
150
|
+
_field_type: str = "signature"
|
|
151
|
+
|
|
152
|
+
width: Optional[float] = None
|
|
153
|
+
height: Optional[float] = None
|
|
@@ -16,6 +16,43 @@ from typing import Optional, Tuple
|
|
|
16
16
|
from .base import Field, Widget
|
|
17
17
|
|
|
18
18
|
|
|
19
|
+
class TextWidget(Widget):
|
|
20
|
+
"""
|
|
21
|
+
Represents a text widget in a PDF form.
|
|
22
|
+
|
|
23
|
+
This class inherits from the base Widget class and provides specific
|
|
24
|
+
parameters for text field styling, such as width, height, font size,
|
|
25
|
+
font color, background color, border color, border width, and maximum
|
|
26
|
+
length.
|
|
27
|
+
|
|
28
|
+
Attributes:
|
|
29
|
+
USER_PARAMS (list): A list of tuples, where each tuple contains the
|
|
30
|
+
user-facing parameter name and the corresponding AcroForm parameter name.
|
|
31
|
+
COLOR_PARAMS (list): A list of user-facing parameter names that represent colors.
|
|
32
|
+
ALLOWED_HOOK_PARAMS (list): A list of allowed hook parameters.
|
|
33
|
+
NONE_DEFAULTS (list): A list of parameters that default to None.
|
|
34
|
+
ACRO_FORM_FUNC (str): The name of the AcroForm function to use for
|
|
35
|
+
creating the text field.
|
|
36
|
+
"""
|
|
37
|
+
|
|
38
|
+
USER_PARAMS = [
|
|
39
|
+
("required", "required"),
|
|
40
|
+
("tooltip", "tooltip"),
|
|
41
|
+
("width", "width"),
|
|
42
|
+
("height", "height"),
|
|
43
|
+
("font_size", "fontSize"),
|
|
44
|
+
("font_color", "textColor"),
|
|
45
|
+
("bg_color", "fillColor"),
|
|
46
|
+
("border_color", "borderColor"),
|
|
47
|
+
("border_width", "borderWidth"),
|
|
48
|
+
("max_length", "maxlen"),
|
|
49
|
+
]
|
|
50
|
+
COLOR_PARAMS = ["font_color", "bg_color", "border_color"]
|
|
51
|
+
ALLOWED_HOOK_PARAMS = ["alignment", "multiline", "comb", "font"]
|
|
52
|
+
NONE_DEFAULTS = ["max_length"]
|
|
53
|
+
ACRO_FORM_FUNC = "textfield"
|
|
54
|
+
|
|
55
|
+
|
|
19
56
|
@dataclass
|
|
20
57
|
class TextField(Field):
|
|
21
58
|
"""
|
|
@@ -55,40 +92,3 @@ class TextField(Field):
|
|
|
55
92
|
border_width: Optional[float] = None
|
|
56
93
|
alignment: Optional[int] = None
|
|
57
94
|
multiline: Optional[bool] = None
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
class TextWidget(Widget):
|
|
61
|
-
"""
|
|
62
|
-
Represents a text widget in a PDF form.
|
|
63
|
-
|
|
64
|
-
This class inherits from the base Widget class and provides specific
|
|
65
|
-
parameters for text field styling, such as width, height, font size,
|
|
66
|
-
font color, background color, border color, border width, and maximum
|
|
67
|
-
length.
|
|
68
|
-
|
|
69
|
-
Attributes:
|
|
70
|
-
USER_PARAMS (list): A list of tuples, where each tuple contains the
|
|
71
|
-
user-facing parameter name and the corresponding AcroForm parameter name.
|
|
72
|
-
COLOR_PARAMS (list): A list of user-facing parameter names that represent colors.
|
|
73
|
-
ALLOWED_HOOK_PARAMS (list): A list of allowed hook parameters.
|
|
74
|
-
NONE_DEFAULTS (list): A list of parameters that default to None.
|
|
75
|
-
ACRO_FORM_FUNC (str): The name of the AcroForm function to use for
|
|
76
|
-
creating the text field.
|
|
77
|
-
"""
|
|
78
|
-
|
|
79
|
-
USER_PARAMS = [
|
|
80
|
-
("required", "required"),
|
|
81
|
-
("tooltip", "tooltip"),
|
|
82
|
-
("width", "width"),
|
|
83
|
-
("height", "height"),
|
|
84
|
-
("font_size", "fontSize"),
|
|
85
|
-
("font_color", "textColor"),
|
|
86
|
-
("bg_color", "fillColor"),
|
|
87
|
-
("border_color", "borderColor"),
|
|
88
|
-
("border_width", "borderWidth"),
|
|
89
|
-
("max_length", "maxlen"),
|
|
90
|
-
]
|
|
91
|
-
COLOR_PARAMS = ["font_color", "bg_color", "border_color"]
|
|
92
|
-
ALLOWED_HOOK_PARAMS = ["alignment", "multiline", "comb", "font"]
|
|
93
|
-
NONE_DEFAULTS = ["max_length"]
|
|
94
|
-
ACRO_FORM_FUNC = "textfield"
|
|
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
|