PyPDFForm 1.4.20__py3-none-any.whl → 1.4.22__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 +1 -1
- PyPDFForm/constants.py +6 -1
- PyPDFForm/coordinate.py +2 -2
- PyPDFForm/filler.py +6 -3
- PyPDFForm/middleware/image.py +8 -0
- PyPDFForm/patterns.py +8 -2
- PyPDFForm/wrapper.py +2 -1
- {PyPDFForm-1.4.20.dist-info → PyPDFForm-1.4.22.dist-info}/METADATA +2 -3
- {PyPDFForm-1.4.20.dist-info → PyPDFForm-1.4.22.dist-info}/RECORD +12 -11
- {PyPDFForm-1.4.20.dist-info → PyPDFForm-1.4.22.dist-info}/LICENSE +0 -0
- {PyPDFForm-1.4.20.dist-info → PyPDFForm-1.4.22.dist-info}/WHEEL +0 -0
- {PyPDFForm-1.4.20.dist-info → PyPDFForm-1.4.22.dist-info}/top_level.txt +0 -0
PyPDFForm/__init__.py
CHANGED
PyPDFForm/constants.py
CHANGED
|
@@ -5,6 +5,7 @@ from typing import Union
|
|
|
5
5
|
|
|
6
6
|
from .middleware.checkbox import Checkbox
|
|
7
7
|
from .middleware.dropdown import Dropdown
|
|
8
|
+
from .middleware.image import Image
|
|
8
9
|
from .middleware.radio import Radio
|
|
9
10
|
from .middleware.signature import Signature
|
|
10
11
|
from .middleware.text import Text
|
|
@@ -22,11 +23,13 @@ VERSION_IDENTIFIERS = [
|
|
|
22
23
|
]
|
|
23
24
|
VERSION_IDENTIFIER_PREFIX = b"%PDF-"
|
|
24
25
|
|
|
25
|
-
WIDGET_TYPES = Union[Text, Checkbox, Radio, Dropdown, Signature]
|
|
26
|
+
WIDGET_TYPES = Union[Text, Checkbox, Radio, Dropdown, Signature, Image]
|
|
26
27
|
|
|
27
28
|
DEPRECATION_NOTICE = "{} will be deprecated soon. Use {} instead."
|
|
28
29
|
|
|
29
30
|
Annots = "/Annots"
|
|
31
|
+
A = "/A"
|
|
32
|
+
JS = "/JS"
|
|
30
33
|
T = "/T"
|
|
31
34
|
Rect = "/Rect"
|
|
32
35
|
Subtype = "/Subtype"
|
|
@@ -64,6 +67,8 @@ PREVIEW_FONT_COLOR = (1, 0, 0)
|
|
|
64
67
|
|
|
65
68
|
NEW_LINE_SYMBOL = "\n"
|
|
66
69
|
|
|
70
|
+
IMAGE_FIELD_IDENTIFIER = "event.target.buttonImportIcon();"
|
|
71
|
+
|
|
67
72
|
DEFAULT_CHECKBOX_STYLE = "\u2713"
|
|
68
73
|
DEFAULT_RADIO_STYLE = "\u25CF"
|
|
69
74
|
BUTTON_STYLES = {
|
PyPDFForm/coordinate.py
CHANGED
|
@@ -38,11 +38,11 @@ def get_draw_checkbox_radio_coordinates(
|
|
|
38
38
|
)
|
|
39
39
|
|
|
40
40
|
|
|
41
|
-
def
|
|
41
|
+
def get_draw_image_coordinates_resolutions(
|
|
42
42
|
widget: dict,
|
|
43
43
|
) -> Tuple[float, float, float, float]:
|
|
44
44
|
"""
|
|
45
|
-
Returns coordinates and resolutions to draw
|
|
45
|
+
Returns coordinates and resolutions to draw image at given a PDF form signature/image widget.
|
|
46
46
|
"""
|
|
47
47
|
|
|
48
48
|
x = float(widget[Rect][0])
|
PyPDFForm/filler.py
CHANGED
|
@@ -9,13 +9,14 @@ from pypdf.generic import DictionaryObject
|
|
|
9
9
|
|
|
10
10
|
from .constants import WIDGET_TYPES, Annots
|
|
11
11
|
from .coordinate import (get_draw_checkbox_radio_coordinates,
|
|
12
|
-
|
|
12
|
+
get_draw_image_coordinates_resolutions,
|
|
13
13
|
get_draw_text_coordinates,
|
|
14
14
|
get_text_line_x_coordinates)
|
|
15
15
|
from .font import checkbox_radio_font_size
|
|
16
16
|
from .image import any_image_to_jpg
|
|
17
17
|
from .middleware.checkbox import Checkbox
|
|
18
18
|
from .middleware.dropdown import Dropdown
|
|
19
|
+
from .middleware.image import Image
|
|
19
20
|
from .middleware.radio import Radio
|
|
20
21
|
from .middleware.signature import Signature
|
|
21
22
|
from .middleware.text import Text
|
|
@@ -69,12 +70,14 @@ def fill(
|
|
|
69
70
|
radio_button_tracker[key] += 1
|
|
70
71
|
if widgets[key].value == radio_button_tracker[key] - 1:
|
|
71
72
|
text_needs_to_be_drawn = True
|
|
72
|
-
elif isinstance(widgets[key], Signature):
|
|
73
|
+
elif isinstance(widgets[key], (Signature, Image)):
|
|
73
74
|
stream = widgets[key].stream
|
|
74
75
|
if stream is not None:
|
|
75
76
|
any_image_to_draw = True
|
|
76
77
|
stream = any_image_to_jpg(stream)
|
|
77
|
-
x, y, width, height =
|
|
78
|
+
x, y, width, height = get_draw_image_coordinates_resolutions(
|
|
79
|
+
_widget
|
|
80
|
+
)
|
|
78
81
|
images_to_draw[page].append(
|
|
79
82
|
[
|
|
80
83
|
stream,
|
PyPDFForm/patterns.py
CHANGED
|
@@ -4,15 +4,21 @@
|
|
|
4
4
|
from pypdf.generic import (DictionaryObject, NameObject, NumberObject,
|
|
5
5
|
TextStringObject)
|
|
6
6
|
|
|
7
|
-
from .constants import (AP, AS, CA, DA, FT,
|
|
8
|
-
|
|
7
|
+
from .constants import (AP, AS, CA, DA, FT, IMAGE_FIELD_IDENTIFIER, JS, MK,
|
|
8
|
+
READ_ONLY, A, Btn, Ch, D, Ff, Off, Opt, Parent, Q, Sig,
|
|
9
|
+
Subtype, T, Tx, V, Widget)
|
|
9
10
|
from .middleware.checkbox import Checkbox
|
|
10
11
|
from .middleware.dropdown import Dropdown
|
|
12
|
+
from .middleware.image import Image
|
|
11
13
|
from .middleware.radio import Radio
|
|
12
14
|
from .middleware.signature import Signature
|
|
13
15
|
from .middleware.text import Text
|
|
14
16
|
|
|
15
17
|
WIDGET_TYPE_PATTERNS = [
|
|
18
|
+
(
|
|
19
|
+
({A: {JS: IMAGE_FIELD_IDENTIFIER}},),
|
|
20
|
+
Image,
|
|
21
|
+
),
|
|
16
22
|
(
|
|
17
23
|
({FT: Sig},),
|
|
18
24
|
Signature,
|
PyPDFForm/wrapper.py
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
from __future__ import annotations
|
|
5
5
|
|
|
6
|
+
from functools import cached_property
|
|
6
7
|
from typing import BinaryIO, Dict, List, Tuple, Union
|
|
7
8
|
from warnings import warn
|
|
8
9
|
|
|
@@ -117,7 +118,7 @@ class PdfWrapper(FormWrapper):
|
|
|
117
118
|
|
|
118
119
|
return None
|
|
119
120
|
|
|
120
|
-
@
|
|
121
|
+
@cached_property
|
|
121
122
|
def pages(self) -> List[PdfWrapper]:
|
|
122
123
|
"""Returns a list of pdf wrapper objects where each is a page of the PDF form."""
|
|
123
124
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: PyPDFForm
|
|
3
|
-
Version: 1.4.
|
|
3
|
+
Version: 1.4.22
|
|
4
4
|
Summary: The Python library for PDF forms.
|
|
5
5
|
Home-page: https://github.com/chinapandaman/PyPDFForm
|
|
6
6
|
Author: Jinge Li
|
|
@@ -8,7 +8,6 @@ Classifier: Development Status :: 5 - Production/Stable
|
|
|
8
8
|
Classifier: Intended Audience :: Developers
|
|
9
9
|
Classifier: Programming Language :: Python :: 3
|
|
10
10
|
Classifier: Programming Language :: Python :: 3 :: Only
|
|
11
|
-
Classifier: Programming Language :: Python :: 3.7
|
|
12
11
|
Classifier: Programming Language :: Python :: 3.8
|
|
13
12
|
Classifier: Programming Language :: Python :: 3.9
|
|
14
13
|
Classifier: Programming Language :: Python :: 3.10
|
|
@@ -17,7 +16,7 @@ Classifier: Programming Language :: Python :: 3.12
|
|
|
17
16
|
Classifier: License :: OSI Approved :: MIT License
|
|
18
17
|
Classifier: Operating System :: OS Independent
|
|
19
18
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
20
|
-
Requires-Python: >=3.
|
|
19
|
+
Requires-Python: >=3.8
|
|
21
20
|
Description-Content-Type: text/markdown
|
|
22
21
|
License-File: LICENSE
|
|
23
22
|
Requires-Dist: cryptography
|
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
PyPDFForm/__init__.py,sha256=
|
|
1
|
+
PyPDFForm/__init__.py,sha256=uOJ2Qv-iFKP_cD4QsBVtIo-QweqFJRxBjZleu2TXyY8,149
|
|
2
2
|
PyPDFForm/adapter.py,sha256=OgAIwcmukpBqHFBLymd3I7wA7wIdipRqgURZA2Y0Hgo,885
|
|
3
|
-
PyPDFForm/constants.py,sha256=
|
|
4
|
-
PyPDFForm/coordinate.py,sha256=
|
|
5
|
-
PyPDFForm/filler.py,sha256=
|
|
3
|
+
PyPDFForm/constants.py,sha256=EPEU_CN5MwyRZHFn-BIyaFNpd2yiJXS92v7ValxYts8,1563
|
|
4
|
+
PyPDFForm/coordinate.py,sha256=V_ZZQ1pXtVPAyfMJCX7fKoEimK7XwX6bU3VQ0nKOhQA,7314
|
|
5
|
+
PyPDFForm/filler.py,sha256=KY7qAKm1JSXCiFInfQBWUw8K8lCK2p7ZQgBb8fP3bdo,6484
|
|
6
6
|
PyPDFForm/font.py,sha256=y9vNvoaBfgkd5vz9EDp04ul8KDM2jY7J61-VWFng6GY,4155
|
|
7
7
|
PyPDFForm/image.py,sha256=0GV8PFgY5oLJFHmhPD1fG-_5SBEO7jVLLtxCc_Uodfo,1143
|
|
8
|
-
PyPDFForm/patterns.py,sha256=
|
|
8
|
+
PyPDFForm/patterns.py,sha256=fg8jarqa3fMuNwwOAUKxBkTUdBLi1eTrPzRAPuTB2MI,4193
|
|
9
9
|
PyPDFForm/template.py,sha256=fuoqiYD_4xQXrBgw8XC677EMxJzHaXb9NcVVYbf0r-0,11782
|
|
10
10
|
PyPDFForm/utils.py,sha256=_gskLLNmwhfGF16gfMP00twVY6iYADYYAYWHMvKCDrg,4140
|
|
11
11
|
PyPDFForm/watermark.py,sha256=clYdRqCuWEE25IL-BUHnSo4HgLkHPSOl7FUJLhbAfGg,4755
|
|
12
|
-
PyPDFForm/wrapper.py,sha256=
|
|
12
|
+
PyPDFForm/wrapper.py,sha256=tJNN4ODQAoZx7niOje4OYkj6j0_NA6jdqM-7LIt89ag,10506
|
|
13
13
|
PyPDFForm/middleware/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
14
14
|
PyPDFForm/middleware/base.py,sha256=TmoO8XpjFa5NerAumrAGm_kUt2eFP3DyyF-Vx0uXloM,724
|
|
15
15
|
PyPDFForm/middleware/checkbox.py,sha256=Z92awlKjceMd_ryb9Fhrtyd4fLkU84Ii6fSum60rHcA,1305
|
|
16
16
|
PyPDFForm/middleware/dropdown.py,sha256=BpRh2YPndhhaLY-s-3gqck64d5FoC719-ARgvfV3_N0,674
|
|
17
|
+
PyPDFForm/middleware/image.py,sha256=xjPxRiGBWFEU3EQGGqJXY1iMX1kmr0jO8O9iVUC5rcc,177
|
|
17
18
|
PyPDFForm/middleware/radio.py,sha256=ehaJoehEzZqxDVb5A6fJkYludeBmtV2Z5GZUPPfUWng,700
|
|
18
19
|
PyPDFForm/middleware/signature.py,sha256=m7tNvGZ7fQ0yuVKzSlLbNQ2IILo1GDnjzMDzMnYCKVM,1104
|
|
19
20
|
PyPDFForm/middleware/text.py,sha256=-ETNQoLvgu5cLkpIQtNYHtq75Ou3P7ezYur-E1yb9-k,1057
|
|
@@ -22,8 +23,8 @@ PyPDFForm/widgets/base.py,sha256=Stq-oQt-cfwQ6nilQ4NqpO5udFSKDNb1mAwryrWggZA,207
|
|
|
22
23
|
PyPDFForm/widgets/checkbox.py,sha256=MGB6NGI-XMBz4j2erykgYOCd1pswvthuQ6UFowQOd4o,503
|
|
23
24
|
PyPDFForm/widgets/dropdown.py,sha256=NYVbtBhmaKNyBh3uTWf4lRz8F2vBfvrruFjdoPWGTb8,998
|
|
24
25
|
PyPDFForm/widgets/text.py,sha256=1-Ww1pK7IMdqBTM0AtQzSSXji4hBgj09l0ZMbFEoZAQ,629
|
|
25
|
-
PyPDFForm-1.4.
|
|
26
|
-
PyPDFForm-1.4.
|
|
27
|
-
PyPDFForm-1.4.
|
|
28
|
-
PyPDFForm-1.4.
|
|
29
|
-
PyPDFForm-1.4.
|
|
26
|
+
PyPDFForm-1.4.22.dist-info/LICENSE,sha256=43awmYkI6opyTpg19me731iO1WfXZwViqb67oWtCsFY,1065
|
|
27
|
+
PyPDFForm-1.4.22.dist-info/METADATA,sha256=9b_MNQfYKBxqwuFSaBhmCH0wsIyqJ4WlhCemAPTqQzU,5367
|
|
28
|
+
PyPDFForm-1.4.22.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
29
|
+
PyPDFForm-1.4.22.dist-info/top_level.txt,sha256=GQQKuWqPUjT9YZqwK95NlAQzxjwoQrsxQ8ureM8lWOY,10
|
|
30
|
+
PyPDFForm-1.4.22.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|