PyPDFForm 1.4.27__py3-none-any.whl → 1.4.29__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 +2 -2
- PyPDFForm/filler.py +0 -1
- PyPDFForm/wrapper.py +4 -50
- {PyPDFForm-1.4.27.dist-info → PyPDFForm-1.4.29.dist-info}/METADATA +2 -24
- {PyPDFForm-1.4.27.dist-info → PyPDFForm-1.4.29.dist-info}/RECORD +8 -8
- {PyPDFForm-1.4.27.dist-info → PyPDFForm-1.4.29.dist-info}/WHEEL +1 -1
- {PyPDFForm-1.4.27.dist-info → PyPDFForm-1.4.29.dist-info}/LICENSE +0 -0
- {PyPDFForm-1.4.27.dist-info → PyPDFForm-1.4.29.dist-info}/top_level.txt +0 -0
PyPDFForm/__init__.py
CHANGED
PyPDFForm/filler.py
CHANGED
PyPDFForm/wrapper.py
CHANGED
|
@@ -5,11 +5,10 @@ from __future__ import annotations
|
|
|
5
5
|
|
|
6
6
|
from functools import cached_property
|
|
7
7
|
from typing import BinaryIO, Dict, List, Tuple, Union
|
|
8
|
-
from warnings import warn
|
|
9
8
|
|
|
10
9
|
from .adapter import fp_or_f_obj_or_stream_to_stream
|
|
11
10
|
from .constants import (DEFAULT_FONT, DEFAULT_FONT_COLOR, DEFAULT_FONT_SIZE,
|
|
12
|
-
|
|
11
|
+
NEW_LINE_SYMBOL, VERSION_IDENTIFIER_PREFIX,
|
|
13
12
|
VERSION_IDENTIFIERS)
|
|
14
13
|
from .coordinate import generate_coordinate_grid
|
|
15
14
|
from .filler import fill, simple_fill
|
|
@@ -90,21 +89,6 @@ class PdfWrapper(FormWrapper):
|
|
|
90
89
|
each.font_size = self.global_font_size
|
|
91
90
|
each.font_color = self.global_font_color
|
|
92
91
|
|
|
93
|
-
@property
|
|
94
|
-
def elements(self) -> dict:
|
|
95
|
-
"""ToDo: deprecate this."""
|
|
96
|
-
|
|
97
|
-
warn(
|
|
98
|
-
DEPRECATION_NOTICE.format(
|
|
99
|
-
f"{self.__class__.__name__}.elements",
|
|
100
|
-
f"{self.__class__.__name__}.widgets",
|
|
101
|
-
),
|
|
102
|
-
DeprecationWarning,
|
|
103
|
-
stacklevel=2,
|
|
104
|
-
)
|
|
105
|
-
|
|
106
|
-
return self.widgets
|
|
107
|
-
|
|
108
92
|
@property
|
|
109
93
|
def sample_data(self) -> dict:
|
|
110
94
|
"""Returns a valid sample data that can be filled into the PDF form."""
|
|
@@ -261,6 +245,9 @@ class PdfWrapper(FormWrapper):
|
|
|
261
245
|
new_widget.font_size = kwargs.get("font_size", DEFAULT_FONT_SIZE)
|
|
262
246
|
new_widget.font_color = kwargs.get("font_color", DEFAULT_FONT_COLOR)
|
|
263
247
|
|
|
248
|
+
if NEW_LINE_SYMBOL in text:
|
|
249
|
+
new_widget.text_lines = text.split(NEW_LINE_SYMBOL)
|
|
250
|
+
|
|
264
251
|
watermarks = create_watermarks_and_draw(
|
|
265
252
|
self.stream,
|
|
266
253
|
page_number,
|
|
@@ -314,20 +301,6 @@ class PdfWrapper(FormWrapper):
|
|
|
314
301
|
|
|
315
302
|
return result
|
|
316
303
|
|
|
317
|
-
def generate_schema(self) -> dict:
|
|
318
|
-
"""ToDo: deprecate this."""
|
|
319
|
-
|
|
320
|
-
warn(
|
|
321
|
-
DEPRECATION_NOTICE.format(
|
|
322
|
-
f"{self.__class__.__name__}.generate_schema()",
|
|
323
|
-
f"{self.__class__.__name__}.schema",
|
|
324
|
-
),
|
|
325
|
-
DeprecationWarning,
|
|
326
|
-
stacklevel=2,
|
|
327
|
-
)
|
|
328
|
-
|
|
329
|
-
return self.schema
|
|
330
|
-
|
|
331
304
|
@classmethod
|
|
332
305
|
def register_font(
|
|
333
306
|
cls, font_name: str, ttf_file: Union[bytes, str, BinaryIO]
|
|
@@ -337,22 +310,3 @@ class PdfWrapper(FormWrapper):
|
|
|
337
310
|
ttf_file = fp_or_f_obj_or_stream_to_stream(ttf_file)
|
|
338
311
|
|
|
339
312
|
return register_font(font_name, ttf_file) if ttf_file is not None else False
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
class PyPDFForm(PdfWrapper):
|
|
343
|
-
"""ToDo: deprecate this."""
|
|
344
|
-
|
|
345
|
-
def __init__(
|
|
346
|
-
self,
|
|
347
|
-
template: Union[bytes, str, BinaryIO] = b"",
|
|
348
|
-
**kwargs,
|
|
349
|
-
):
|
|
350
|
-
"""Only extra thing is the deprecation notice."""
|
|
351
|
-
|
|
352
|
-
warn(
|
|
353
|
-
DEPRECATION_NOTICE.format("PyPDFForm.PyPDFForm", "PyPDFForm.PdfWrapper"),
|
|
354
|
-
DeprecationWarning,
|
|
355
|
-
stacklevel=2,
|
|
356
|
-
)
|
|
357
|
-
|
|
358
|
-
super().__init__(template, **kwargs)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: PyPDFForm
|
|
3
|
-
Version: 1.4.
|
|
3
|
+
Version: 1.4.29
|
|
4
4
|
Summary: The Python library for PDF forms.
|
|
5
5
|
Home-page: https://github.com/chinapandaman/PyPDFForm
|
|
6
6
|
Author: Jinge Li
|
|
@@ -34,22 +34,6 @@ Requires-Dist: reportlab
|
|
|
34
34
|
<a href="https://pypistats.org/packages/pypdfform"><img src="https://img.shields.io/pypi/dm/pypdfform?logo=pypi&logoColor=white&label=downloads&labelColor=black&color=blue&style=for-the-badge"></a>
|
|
35
35
|
</p>
|
|
36
36
|
|
|
37
|
-
## Important API Changes
|
|
38
|
-
|
|
39
|
-
Happy new year fellow developers! We start the year 2024 with a new release of v1.4.0 and
|
|
40
|
-
there are some important changes I'm making to the APIs of the library.
|
|
41
|
-
|
|
42
|
-
* The PDF object that gets instantiated is now `PyPDFForm.PdfWrapper`, changed from `PyPDFForm.PyPDFForm`.
|
|
43
|
-
* Form widgets are now accessed via the `PdfWrapper.widgets` attribute, changed from `PdfWrapper.elements`.
|
|
44
|
-
* The JSON schema of the form data is now accessed via a new attribute called `PdfWrapper.schema`,
|
|
45
|
-
changed from the old method of `PdfWrapper.generate_schema()`.
|
|
46
|
-
|
|
47
|
-
All the old APIs will be persisted for half a year and then fully deprecated. Each of them
|
|
48
|
-
will emit a `DeprecationWarning` when invoked, so it is advised that you make the switch before they are
|
|
49
|
-
removed and start breaking your code.
|
|
50
|
-
|
|
51
|
-
Happy hacking!
|
|
52
|
-
|
|
53
37
|
## Introduction
|
|
54
38
|
|
|
55
39
|
PyPDFForm is a free and open source pure-Python 3 library for PDF form processing. It contains the essential
|
|
@@ -99,12 +83,6 @@ and it should look like [this](https://github.com/chinapandaman/PyPDFForm/raw/ma
|
|
|
99
83
|
|
|
100
84
|
The official documentation can be found on [the GitHub page](https://chinapandaman.github.io/PyPDFForm/) of this repository.
|
|
101
85
|
|
|
102
|
-
##
|
|
86
|
+
## Other Resources
|
|
103
87
|
|
|
104
88
|
[Chicago Python User Group - Dec 14, 2023](https://youtu.be/8t1RdAKwr9w?si=TLgumBNXv9H8szSn)
|
|
105
|
-
|
|
106
|
-
## How to Contribute
|
|
107
|
-
|
|
108
|
-
It is difficult to make sure that the library supports all the PDF form creating tools out
|
|
109
|
-
there. So if you run into a case where the library does not work for certain PDF forms created by certain tools, feel free to open an issue with the problematic PDF form attached. I will seek
|
|
110
|
-
to make the library support the attached PDF form as well as the tool used to create it.
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
PyPDFForm/__init__.py,sha256=
|
|
1
|
+
PyPDFForm/__init__.py,sha256=7PqqRfPhC05fsbxMhlPBXIs5vnUxIuZeSrivp55uw94,138
|
|
2
2
|
PyPDFForm/adapter.py,sha256=OgAIwcmukpBqHFBLymd3I7wA7wIdipRqgURZA2Y0Hgo,885
|
|
3
3
|
PyPDFForm/constants.py,sha256=Y-WINNe5GoOPfBFQroWuzzLELhAl-Fj_d7_3b1QodW0,1767
|
|
4
4
|
PyPDFForm/coordinate.py,sha256=V_ZZQ1pXtVPAyfMJCX7fKoEimK7XwX6bU3VQ0nKOhQA,7314
|
|
5
|
-
PyPDFForm/filler.py,sha256=
|
|
5
|
+
PyPDFForm/filler.py,sha256=pgMA7EC8axKUganmbk7X1uDdsb4OQQFoiI85td3pOO4,7486
|
|
6
6
|
PyPDFForm/font.py,sha256=DCaKN6WIfNeMpP6ud17q1FOVRQXqrdevLycIQ9kItXQ,5711
|
|
7
7
|
PyPDFForm/image.py,sha256=0GV8PFgY5oLJFHmhPD1fG-_5SBEO7jVLLtxCc_Uodfo,1143
|
|
8
8
|
PyPDFForm/patterns.py,sha256=Ylfe6s9UV2X7cRAFQjaGoEa4nVSpEn-MLrH7IROp_aY,4332
|
|
9
9
|
PyPDFForm/template.py,sha256=u3QxYdsT8HhoUBlhmChYaTJeFWI-SSrhICtUYsTTrow,13141
|
|
10
10
|
PyPDFForm/utils.py,sha256=gDeRDszZ5Q59RjZjJYnikS2pQ_hc78osQH2Oy1TuLsY,4269
|
|
11
11
|
PyPDFForm/watermark.py,sha256=clYdRqCuWEE25IL-BUHnSo4HgLkHPSOl7FUJLhbAfGg,4755
|
|
12
|
-
PyPDFForm/wrapper.py,sha256=
|
|
12
|
+
PyPDFForm/wrapper.py,sha256=nwmaBkcnd0wt53s9SHHWFCvSJX4J2f7MU3ktt3105WU,9496
|
|
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
|
|
@@ -23,8 +23,8 @@ PyPDFForm/widgets/base.py,sha256=Stq-oQt-cfwQ6nilQ4NqpO5udFSKDNb1mAwryrWggZA,207
|
|
|
23
23
|
PyPDFForm/widgets/checkbox.py,sha256=MGB6NGI-XMBz4j2erykgYOCd1pswvthuQ6UFowQOd4o,503
|
|
24
24
|
PyPDFForm/widgets/dropdown.py,sha256=2_R5xcLUWAL0G4raVgWWtE7TJdiWJITay-Gtl8YI2QI,705
|
|
25
25
|
PyPDFForm/widgets/text.py,sha256=x8EglZLYoI9osN9wORLRYoR7lebrpj-wx38QiRH7H1A,629
|
|
26
|
-
PyPDFForm-1.4.
|
|
27
|
-
PyPDFForm-1.4.
|
|
28
|
-
PyPDFForm-1.4.
|
|
29
|
-
PyPDFForm-1.4.
|
|
30
|
-
PyPDFForm-1.4.
|
|
26
|
+
PyPDFForm-1.4.29.dist-info/LICENSE,sha256=43awmYkI6opyTpg19me731iO1WfXZwViqb67oWtCsFY,1065
|
|
27
|
+
PyPDFForm-1.4.29.dist-info/METADATA,sha256=XpWnZIbenPQtjTIZKAovCTQP7HX0vobgn70b5kc_Tms,4151
|
|
28
|
+
PyPDFForm-1.4.29.dist-info/WHEEL,sha256=mguMlWGMX-VHnMpKOjjQidIo1ssRlCFu4a4mBpz1s2M,91
|
|
29
|
+
PyPDFForm-1.4.29.dist-info/top_level.txt,sha256=GQQKuWqPUjT9YZqwK95NlAQzxjwoQrsxQ8ureM8lWOY,10
|
|
30
|
+
PyPDFForm-1.4.29.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|