PyPDFForm 3.1.1__py3-none-any.whl → 3.1.3__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 +3 -1
- PyPDFForm/font.py +8 -4
- PyPDFForm/middleware/base.py +3 -3
- PyPDFForm/middleware/checkbox.py +1 -1
- PyPDFForm/middleware/dropdown.py +4 -2
- PyPDFForm/middleware/image.py +1 -1
- PyPDFForm/middleware/radio.py +1 -1
- PyPDFForm/middleware/signature.py +1 -1
- PyPDFForm/middleware/text.py +8 -8
- PyPDFForm/patterns.py +1 -10
- PyPDFForm/template.py +1 -1
- PyPDFForm/utils.py +0 -2
- {pypdfform-3.1.1.dist-info → pypdfform-3.1.3.dist-info}/METADATA +1 -1
- {pypdfform-3.1.1.dist-info → pypdfform-3.1.3.dist-info}/RECORD +18 -18
- {pypdfform-3.1.1.dist-info → pypdfform-3.1.3.dist-info}/WHEEL +0 -0
- {pypdfform-3.1.1.dist-info → pypdfform-3.1.3.dist-info}/licenses/LICENSE +0 -0
- {pypdfform-3.1.1.dist-info → pypdfform-3.1.3.dist-info}/top_level.txt +0 -0
PyPDFForm/__init__.py
CHANGED
|
@@ -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.1.
|
|
23
|
+
__version__ = "3.1.3"
|
|
24
24
|
|
|
25
25
|
from .middleware.text import Text # exposing for setting global font attrs
|
|
26
26
|
from .wrapper import PdfWrapper
|
PyPDFForm/constants.py
CHANGED
|
@@ -67,9 +67,9 @@ Opt = "/Opt"
|
|
|
67
67
|
AS = "/AS"
|
|
68
68
|
Yes = "/Yes"
|
|
69
69
|
Off = "/Off"
|
|
70
|
-
XObject = "/XObject"
|
|
71
70
|
|
|
72
71
|
# Font dict
|
|
72
|
+
Length = "/Length"
|
|
73
73
|
Length1 = "/Length1"
|
|
74
74
|
Type = "/Type"
|
|
75
75
|
FontDescriptor = "/FontDescriptor"
|
|
@@ -79,6 +79,8 @@ Font = "/Font"
|
|
|
79
79
|
Subtype = "/Subtype"
|
|
80
80
|
TrueType = "/TrueType"
|
|
81
81
|
BaseFont = "/BaseFont"
|
|
82
|
+
Filter = "/Filter"
|
|
83
|
+
FlateDecode = "/FlateDecode"
|
|
82
84
|
Encoding = "/Encoding"
|
|
83
85
|
WinAnsiEncoding = "/WinAnsiEncoding"
|
|
84
86
|
|
PyPDFForm/font.py
CHANGED
|
@@ -9,6 +9,7 @@ for extracting font information from TTF streams and managing font names within
|
|
|
9
9
|
|
|
10
10
|
from functools import lru_cache
|
|
11
11
|
from io import BytesIO
|
|
12
|
+
from zlib import compress
|
|
12
13
|
|
|
13
14
|
from pypdf import PdfReader, PdfWriter
|
|
14
15
|
from pypdf.generic import (ArrayObject, DictionaryObject, NameObject,
|
|
@@ -17,9 +18,9 @@ from reportlab.pdfbase.pdfmetrics import registerFont
|
|
|
17
18
|
from reportlab.pdfbase.ttfonts import TTFError, TTFont
|
|
18
19
|
|
|
19
20
|
from .constants import (DR, FONT_NAME_PREFIX, AcroForm, BaseFont, Encoding,
|
|
20
|
-
Fields,
|
|
21
|
-
|
|
22
|
-
WinAnsiEncoding)
|
|
21
|
+
Fields, Filter, FlateDecode, Font, FontDescriptor,
|
|
22
|
+
FontFile2, FontName, Length, Length1, Resources,
|
|
23
|
+
Subtype, TrueType, Type, WinAnsiEncoding)
|
|
23
24
|
from .utils import stream_to_io
|
|
24
25
|
|
|
25
26
|
|
|
@@ -119,10 +120,13 @@ def register_font_acroform(pdf: bytes, ttf_stream: bytes, adobe_mode: bool) -> t
|
|
|
119
120
|
)
|
|
120
121
|
|
|
121
122
|
font_file_stream = StreamObject()
|
|
122
|
-
|
|
123
|
+
compressed_ttf = compress(ttf_stream)
|
|
124
|
+
font_file_stream.set_data(compressed_ttf)
|
|
123
125
|
font_file_stream.update(
|
|
124
126
|
{
|
|
125
127
|
NameObject(Length1): NumberObject(len(ttf_stream)),
|
|
128
|
+
NameObject(Length): NumberObject(len(compressed_ttf)),
|
|
129
|
+
NameObject(Filter): NameObject(FlateDecode),
|
|
126
130
|
}
|
|
127
131
|
)
|
|
128
132
|
font_file_ref = writer._add_object(font_file_stream) # type: ignore # noqa: SLF001 # # pylint: disable=W0212
|
PyPDFForm/middleware/base.py
CHANGED
|
@@ -40,9 +40,9 @@ class Widget:
|
|
|
40
40
|
super().__init__()
|
|
41
41
|
self._name = name
|
|
42
42
|
self._value = value
|
|
43
|
-
self.desc = None
|
|
44
|
-
self.readonly = None
|
|
45
|
-
self.hooks_to_trigger = []
|
|
43
|
+
self.desc: str = None
|
|
44
|
+
self.readonly: bool = None
|
|
45
|
+
self.hooks_to_trigger: list = []
|
|
46
46
|
|
|
47
47
|
def __setattr__(self, name: str, value: Any) -> None:
|
|
48
48
|
"""
|
PyPDFForm/middleware/checkbox.py
CHANGED
PyPDFForm/middleware/dropdown.py
CHANGED
|
@@ -6,6 +6,8 @@ This module defines the Dropdown class, which is a subclass of the
|
|
|
6
6
|
Widget class. It represents a dropdown form field in a PDF document.
|
|
7
7
|
"""
|
|
8
8
|
|
|
9
|
+
from typing import Union
|
|
10
|
+
|
|
9
11
|
from .base import Widget
|
|
10
12
|
|
|
11
13
|
|
|
@@ -50,8 +52,8 @@ class Dropdown(Widget):
|
|
|
50
52
|
)
|
|
51
53
|
super().__init__(name, value)
|
|
52
54
|
|
|
53
|
-
self.font = None
|
|
54
|
-
self.choices = None
|
|
55
|
+
self.font: str = None
|
|
56
|
+
self.choices: Union[tuple, list] = None
|
|
55
57
|
|
|
56
58
|
@property
|
|
57
59
|
def schema_definition(self) -> dict:
|
PyPDFForm/middleware/image.py
CHANGED
PyPDFForm/middleware/radio.py
CHANGED
PyPDFForm/middleware/text.py
CHANGED
|
@@ -55,14 +55,14 @@ class Text(Widget):
|
|
|
55
55
|
)
|
|
56
56
|
super().__init__(name, value)
|
|
57
57
|
|
|
58
|
-
self.font = None
|
|
59
|
-
self.font_size = None
|
|
60
|
-
self.font_color = None
|
|
61
|
-
self.comb = None
|
|
62
|
-
self.alignment = None
|
|
63
|
-
self.multiline = None
|
|
64
|
-
|
|
65
|
-
self.max_length = None
|
|
58
|
+
self.font: str = None
|
|
59
|
+
self.font_size: float = None
|
|
60
|
+
self.font_color: tuple = None
|
|
61
|
+
self.comb: bool = None
|
|
62
|
+
self.alignment: int = None
|
|
63
|
+
self.multiline: bool = None
|
|
64
|
+
|
|
65
|
+
self.max_length: int = None
|
|
66
66
|
|
|
67
67
|
@property
|
|
68
68
|
def value(self) -> str:
|
PyPDFForm/patterns.py
CHANGED
|
@@ -14,8 +14,7 @@ from pypdf.generic import (ArrayObject, DictionaryObject, NameObject,
|
|
|
14
14
|
NumberObject, TextStringObject)
|
|
15
15
|
|
|
16
16
|
from .constants import (AP, AS, DV, FT, IMAGE_FIELD_IDENTIFIER, JS, SLASH, TU,
|
|
17
|
-
A, Btn, Ch, I, N, Off, Opt, Parent,
|
|
18
|
-
Tx, V, XObject, Yes)
|
|
17
|
+
A, Btn, Ch, I, N, Off, Opt, Parent, Sig, T, Tx, V, Yes)
|
|
19
18
|
from .middleware.checkbox import Checkbox
|
|
20
19
|
from .middleware.dropdown import Dropdown
|
|
21
20
|
from .middleware.image import Image
|
|
@@ -24,14 +23,6 @@ from .middleware.signature import Signature
|
|
|
24
23
|
from .middleware.text import Text
|
|
25
24
|
|
|
26
25
|
WIDGET_TYPE_PATTERNS = [
|
|
27
|
-
# barcode? see pdf_samples/scenario/issues/1087.pdf
|
|
28
|
-
(
|
|
29
|
-
(
|
|
30
|
-
{FT: Tx},
|
|
31
|
-
{AP: {N: {Resources: {XObject: True}}}},
|
|
32
|
-
),
|
|
33
|
-
None,
|
|
34
|
-
),
|
|
35
26
|
(
|
|
36
27
|
({A: {JS: IMAGE_FIELD_IDENTIFIER}},),
|
|
37
28
|
Image,
|
PyPDFForm/template.py
CHANGED
|
@@ -182,7 +182,7 @@ def construct_widget(widget: dict, key: str) -> Union[WIDGET_TYPES, None]:
|
|
|
182
182
|
for pattern in patterns:
|
|
183
183
|
check = check and find_pattern_match(pattern, widget)
|
|
184
184
|
if check:
|
|
185
|
-
result = _type(key)
|
|
185
|
+
result = _type(key)
|
|
186
186
|
break
|
|
187
187
|
return result
|
|
188
188
|
|
PyPDFForm/utils.py
CHANGED
|
@@ -222,8 +222,6 @@ def find_pattern_match(pattern: dict, widget: Union[dict, DictionaryObject]) ->
|
|
|
222
222
|
result = value in pattern[key]
|
|
223
223
|
if not result and SLASH in pattern[key] and value.startswith(SLASH):
|
|
224
224
|
result = True
|
|
225
|
-
elif pattern[key] is True:
|
|
226
|
-
result = True
|
|
227
225
|
else:
|
|
228
226
|
result = pattern[key] == value
|
|
229
227
|
if result:
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
PyPDFForm/__init__.py,sha256=
|
|
1
|
+
PyPDFForm/__init__.py,sha256=Si2S1NESLXeTXj-HLtHdFCntkfhCP3WIG8wCgLdWkbk,925
|
|
2
2
|
PyPDFForm/adapter.py,sha256=8E_PZlXU1ALWez_pWF_U52cynzowK_NQFYzMJoH9VUk,2428
|
|
3
|
-
PyPDFForm/constants.py,sha256=
|
|
3
|
+
PyPDFForm/constants.py,sha256=GU0LcNbN-ttYQVVoFGQLysKByJYF4lKoMideU65z_wI,2523
|
|
4
4
|
PyPDFForm/coordinate.py,sha256=VMVkqa-VAGJSGVvetZwOxeMzIgQtQdvtn_DI_qSecCE,3876
|
|
5
5
|
PyPDFForm/filler.py,sha256=KwStL6YzrNBcDd919ig83MnAxopi8Vnz3QNJzN_CjNM,7272
|
|
6
|
-
PyPDFForm/font.py,sha256=
|
|
6
|
+
PyPDFForm/font.py,sha256=Nyk1dHgC9NBkXDTYiGz9eyCwHadpU-JjR-xOM604cpA,9053
|
|
7
7
|
PyPDFForm/hooks.py,sha256=A8p67ubWvCvzRt346Q7BjOvbi4_NXBcynXmq6fJTadY,11679
|
|
8
8
|
PyPDFForm/image.py,sha256=CAC69jEfSbWbyNJcjLhjWVSNJuFh7frMI70eaiFayHw,3823
|
|
9
|
-
PyPDFForm/patterns.py,sha256=
|
|
10
|
-
PyPDFForm/template.py,sha256=
|
|
11
|
-
PyPDFForm/utils.py,sha256=
|
|
9
|
+
PyPDFForm/patterns.py,sha256=RiQKqsOMrB9u4KWj5Kv6GUmcuGI77xMvdOcOcHy_9qE,8717
|
|
10
|
+
PyPDFForm/template.py,sha256=lKkja_8Sx6vun1tOklSpdNT1pdelhfVl10kX-G4sLlA,9673
|
|
11
|
+
PyPDFForm/utils.py,sha256=hLSVUG6qnE0iTMB-yPNQQIhmm3R69X7fcnbCTDvSUQs,11001
|
|
12
12
|
PyPDFForm/watermark.py,sha256=9p1tjaIqicXngTNai_iOEkCoXRYnR66azB4s7wNsZUw,9349
|
|
13
13
|
PyPDFForm/wrapper.py,sha256=Ysd1mkvE5OfDkjUI6mNFIt16-JUKwj2ifbp1MioWPUo,25257
|
|
14
14
|
PyPDFForm/middleware/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
15
|
-
PyPDFForm/middleware/base.py,sha256=
|
|
16
|
-
PyPDFForm/middleware/checkbox.py,sha256=
|
|
17
|
-
PyPDFForm/middleware/dropdown.py,sha256=
|
|
18
|
-
PyPDFForm/middleware/image.py,sha256=
|
|
19
|
-
PyPDFForm/middleware/radio.py,sha256=
|
|
20
|
-
PyPDFForm/middleware/signature.py,sha256=
|
|
21
|
-
PyPDFForm/middleware/text.py,sha256=
|
|
15
|
+
PyPDFForm/middleware/base.py,sha256=zBO9YP01dAEfFKoHKDg10XcpXEuYdFd-pb5wSFmJJj0,3091
|
|
16
|
+
PyPDFForm/middleware/checkbox.py,sha256=OCSZEFD8wQG_Y9qO7Os6VXTaxJCpkRYTxI4wDgG0GZc,1870
|
|
17
|
+
PyPDFForm/middleware/dropdown.py,sha256=4HkVNHoYzH0isdBIdjNtViBx263j4KmYtW0SYzER5zQ,2412
|
|
18
|
+
PyPDFForm/middleware/image.py,sha256=eKM7anU56jbaECnK6rq0jGsBRY3HW_fM86fgA3hq7xA,585
|
|
19
|
+
PyPDFForm/middleware/radio.py,sha256=PuGDJ8RN1C-MkL9Jf14ABWYV67cN18R66dI4nR-03DU,2211
|
|
20
|
+
PyPDFForm/middleware/signature.py,sha256=a2IfD36zpEWXWNNWRvtJ6nG6TszkF6Wil82Szsbjfns,2149
|
|
21
|
+
PyPDFForm/middleware/text.py,sha256=GLKuYvG4BUtNvj-3NkDeIlV1jcouhn7gAqfm9TBWduQ,3936
|
|
22
22
|
PyPDFForm/widgets/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
23
23
|
PyPDFForm/widgets/base.py,sha256=kOfxV8HSmwXoy0vFYPgJKKDQ7RUNMACWfX6T4HeJeOU,5177
|
|
24
24
|
PyPDFForm/widgets/bedrock.py,sha256=j6beU04kaQzpAIFZHI5VJLaDT5RVAAa6LzkU1luJpN8,137660
|
|
@@ -28,8 +28,8 @@ PyPDFForm/widgets/image.py,sha256=aSD-3MEZFIRL7HYVuO6Os8irfSUOLHA_rHGkqcEIPPA,85
|
|
|
28
28
|
PyPDFForm/widgets/radio.py,sha256=nWSQQp06kRISO7Q7FVFeB3PXYvMOSc0SMhRs1bHTxeQ,2261
|
|
29
29
|
PyPDFForm/widgets/signature.py,sha256=EqIRIuKSQEg8LJZ_Mu859eEvs0dwO-mzkMNuhHG1Vsg,4034
|
|
30
30
|
PyPDFForm/widgets/text.py,sha256=gtheE6_w0vQPRJJ9oj_l9FaMDEGnPtvVR6_axsrmxKI,1540
|
|
31
|
-
pypdfform-3.1.
|
|
32
|
-
pypdfform-3.1.
|
|
33
|
-
pypdfform-3.1.
|
|
34
|
-
pypdfform-3.1.
|
|
35
|
-
pypdfform-3.1.
|
|
31
|
+
pypdfform-3.1.3.dist-info/licenses/LICENSE,sha256=43awmYkI6opyTpg19me731iO1WfXZwViqb67oWtCsFY,1065
|
|
32
|
+
pypdfform-3.1.3.dist-info/METADATA,sha256=2CB-pD0wqfNYa7yfdRcwCsxqzv2nfXE7asKLaSkyT20,4587
|
|
33
|
+
pypdfform-3.1.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
34
|
+
pypdfform-3.1.3.dist-info/top_level.txt,sha256=GQQKuWqPUjT9YZqwK95NlAQzxjwoQrsxQ8ureM8lWOY,10
|
|
35
|
+
pypdfform-3.1.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|