PyPDFForm 1.4.27__tar.gz → 1.4.28__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-1.4.27 → pypdfform-1.4.28}/PKG-INFO +1 -17
- pypdfform-1.4.28/PyPDFForm/__init__.py +6 -0
- {pypdfform-1.4.27 → pypdfform-1.4.28}/PyPDFForm/filler.py +0 -1
- {pypdfform-1.4.27 → pypdfform-1.4.28}/PyPDFForm/wrapper.py +1 -51
- {pypdfform-1.4.27 → pypdfform-1.4.28}/PyPDFForm.egg-info/PKG-INFO +1 -17
- {pypdfform-1.4.27 → pypdfform-1.4.28}/README.md +0 -16
- {pypdfform-1.4.27 → pypdfform-1.4.28}/tests/test_adobe_mode.py +52 -0
- {pypdfform-1.4.27 → pypdfform-1.4.28}/tests/test_functional.py +1 -26
- pypdfform-1.4.27/PyPDFForm/__init__.py +0 -6
- {pypdfform-1.4.27 → pypdfform-1.4.28}/LICENSE +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.28}/PyPDFForm/adapter.py +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.28}/PyPDFForm/constants.py +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.28}/PyPDFForm/coordinate.py +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.28}/PyPDFForm/font.py +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.28}/PyPDFForm/image.py +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.28}/PyPDFForm/middleware/__init__.py +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.28}/PyPDFForm/middleware/base.py +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.28}/PyPDFForm/middleware/checkbox.py +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.28}/PyPDFForm/middleware/dropdown.py +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.28}/PyPDFForm/middleware/image.py +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.28}/PyPDFForm/middleware/radio.py +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.28}/PyPDFForm/middleware/signature.py +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.28}/PyPDFForm/middleware/text.py +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.28}/PyPDFForm/patterns.py +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.28}/PyPDFForm/template.py +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.28}/PyPDFForm/utils.py +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.28}/PyPDFForm/watermark.py +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.28}/PyPDFForm/widgets/__init__.py +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.28}/PyPDFForm/widgets/base.py +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.28}/PyPDFForm/widgets/checkbox.py +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.28}/PyPDFForm/widgets/dropdown.py +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.28}/PyPDFForm/widgets/text.py +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.28}/PyPDFForm.egg-info/SOURCES.txt +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.28}/PyPDFForm.egg-info/dependency_links.txt +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.28}/PyPDFForm.egg-info/requires.txt +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.28}/PyPDFForm.egg-info/top_level.txt +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.28}/setup.cfg +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.28}/setup.py +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.28}/tests/test_create_widget.py +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.28}/tests/test_dropdown.py +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.28}/tests/test_dropdown_simple.py +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.28}/tests/test_fill_max_length_text_field.py +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.28}/tests/test_fill_max_length_text_field_simple.py +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.28}/tests/test_functional_simple.py +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.28}/tests/test_paragraph.py +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.28}/tests/test_paragraph_simple.py +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.28}/tests/test_preview.py +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.28}/tests/test_signature.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: PyPDFForm
|
|
3
|
-
Version: 1.4.
|
|
3
|
+
Version: 1.4.28
|
|
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
|
|
@@ -5,12 +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
|
-
|
|
13
|
-
VERSION_IDENTIFIERS)
|
|
11
|
+
VERSION_IDENTIFIER_PREFIX, VERSION_IDENTIFIERS)
|
|
14
12
|
from .coordinate import generate_coordinate_grid
|
|
15
13
|
from .filler import fill, simple_fill
|
|
16
14
|
from .font import register_font
|
|
@@ -90,21 +88,6 @@ class PdfWrapper(FormWrapper):
|
|
|
90
88
|
each.font_size = self.global_font_size
|
|
91
89
|
each.font_color = self.global_font_color
|
|
92
90
|
|
|
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
91
|
@property
|
|
109
92
|
def sample_data(self) -> dict:
|
|
110
93
|
"""Returns a valid sample data that can be filled into the PDF form."""
|
|
@@ -314,20 +297,6 @@ class PdfWrapper(FormWrapper):
|
|
|
314
297
|
|
|
315
298
|
return result
|
|
316
299
|
|
|
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
300
|
@classmethod
|
|
332
301
|
def register_font(
|
|
333
302
|
cls, font_name: str, ttf_file: Union[bytes, str, BinaryIO]
|
|
@@ -337,22 +306,3 @@ class PdfWrapper(FormWrapper):
|
|
|
337
306
|
ttf_file = fp_or_f_obj_or_stream_to_stream(ttf_file)
|
|
338
307
|
|
|
339
308
|
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.28
|
|
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
|
|
@@ -8,22 +8,6 @@
|
|
|
8
8
|
<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>
|
|
9
9
|
</p>
|
|
10
10
|
|
|
11
|
-
## Important API Changes
|
|
12
|
-
|
|
13
|
-
Happy new year fellow developers! We start the year 2024 with a new release of v1.4.0 and
|
|
14
|
-
there are some important changes I'm making to the APIs of the library.
|
|
15
|
-
|
|
16
|
-
* The PDF object that gets instantiated is now `PyPDFForm.PdfWrapper`, changed from `PyPDFForm.PyPDFForm`.
|
|
17
|
-
* Form widgets are now accessed via the `PdfWrapper.widgets` attribute, changed from `PdfWrapper.elements`.
|
|
18
|
-
* The JSON schema of the form data is now accessed via a new attribute called `PdfWrapper.schema`,
|
|
19
|
-
changed from the old method of `PdfWrapper.generate_schema()`.
|
|
20
|
-
|
|
21
|
-
All the old APIs will be persisted for half a year and then fully deprecated. Each of them
|
|
22
|
-
will emit a `DeprecationWarning` when invoked, so it is advised that you make the switch before they are
|
|
23
|
-
removed and start breaking your code.
|
|
24
|
-
|
|
25
|
-
Happy hacking!
|
|
26
|
-
|
|
27
11
|
## Introduction
|
|
28
12
|
|
|
29
13
|
PyPDFForm is a free and open source pure-Python 3 library for PDF form processing. It contains the essential
|
|
@@ -5,6 +5,34 @@ import os
|
|
|
5
5
|
from PyPDFForm import FormWrapper
|
|
6
6
|
|
|
7
7
|
|
|
8
|
+
def test_dropdown_one(sample_template_with_dropdown, pdf_samples, request):
|
|
9
|
+
expected_path = os.path.join(
|
|
10
|
+
pdf_samples, "adobe_mode", "dropdown", "dropdown_one.pdf"
|
|
11
|
+
)
|
|
12
|
+
with open(expected_path, "rb+") as f:
|
|
13
|
+
obj = FormWrapper(sample_template_with_dropdown).fill(
|
|
14
|
+
{
|
|
15
|
+
"test_1": "test_1",
|
|
16
|
+
"test_2": "test_2",
|
|
17
|
+
"test_3": "test_3",
|
|
18
|
+
"check_1": True,
|
|
19
|
+
"check_2": True,
|
|
20
|
+
"check_3": True,
|
|
21
|
+
"radio_1": 1,
|
|
22
|
+
"dropdown_1": 0,
|
|
23
|
+
},
|
|
24
|
+
adobe_mode=True,
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
request.config.results["expected_path"] = expected_path
|
|
28
|
+
request.config.results["stream"] = obj.read()
|
|
29
|
+
|
|
30
|
+
expected = f.read()
|
|
31
|
+
|
|
32
|
+
assert len(obj.read()) == len(expected)
|
|
33
|
+
assert obj.stream == expected
|
|
34
|
+
|
|
35
|
+
|
|
8
36
|
def test_fill_sejda_complex(sejda_template_complex, pdf_samples, request):
|
|
9
37
|
expected_path = os.path.join(
|
|
10
38
|
pdf_samples, "adobe_mode", "paragraph", "sample_filled_sejda_complex.pdf"
|
|
@@ -43,3 +71,27 @@ def test_fill_sejda_complex(sejda_template_complex, pdf_samples, request):
|
|
|
43
71
|
|
|
44
72
|
assert len(obj.read()) == len(expected)
|
|
45
73
|
assert obj.stream == expected
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def test_issue_613(pdf_samples, request):
|
|
77
|
+
expected_path = os.path.join(
|
|
78
|
+
pdf_samples, "adobe_mode", "issues", "613_expected.pdf"
|
|
79
|
+
)
|
|
80
|
+
with open(expected_path, "rb+") as f:
|
|
81
|
+
obj = FormWrapper(
|
|
82
|
+
os.path.join(pdf_samples, "scenario", "issues", "613.pdf")
|
|
83
|
+
).fill(
|
|
84
|
+
{
|
|
85
|
+
"301 Full name": "John Smith",
|
|
86
|
+
"301 Address Street": "1234 road number 6",
|
|
87
|
+
},
|
|
88
|
+
adobe_mode=True,
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
request.config.results["expected_path"] = expected_path
|
|
92
|
+
request.config.results["stream"] = obj.read()
|
|
93
|
+
|
|
94
|
+
expected = f.read()
|
|
95
|
+
|
|
96
|
+
assert len(obj.read()) == len(expected)
|
|
97
|
+
assert obj.stream == expected
|
|
@@ -2,10 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
import os
|
|
4
4
|
|
|
5
|
-
import pytest
|
|
6
5
|
from jsonschema import ValidationError, validate
|
|
7
6
|
|
|
8
|
-
from PyPDFForm import PdfWrapper,
|
|
7
|
+
from PyPDFForm import PdfWrapper, constants, template
|
|
9
8
|
from PyPDFForm.middleware.base import Widget
|
|
10
9
|
from PyPDFForm.middleware.text import Text
|
|
11
10
|
|
|
@@ -18,30 +17,6 @@ def test_base_schema_definition():
|
|
|
18
17
|
pass
|
|
19
18
|
|
|
20
19
|
|
|
21
|
-
def test_elements_deprecation_notice(template_stream):
|
|
22
|
-
with pytest.warns(DeprecationWarning) as r:
|
|
23
|
-
obj = PdfWrapper(template_stream)
|
|
24
|
-
assert not r
|
|
25
|
-
assert obj.elements is obj.widgets
|
|
26
|
-
obj.elements["test"].font_size = 20
|
|
27
|
-
assert obj.widgets["test"].font_size == 20
|
|
28
|
-
assert r
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
def test_generate_schema_deprecation_notice(template_stream):
|
|
32
|
-
with pytest.warns(DeprecationWarning) as r:
|
|
33
|
-
obj = PdfWrapper(template_stream)
|
|
34
|
-
assert not r
|
|
35
|
-
assert obj.generate_schema() == obj.schema
|
|
36
|
-
assert r
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
def test_pypdfform_deprecation_notice(template_stream):
|
|
40
|
-
with pytest.warns(DeprecationWarning) as r:
|
|
41
|
-
assert PyPDFForm(template_stream)
|
|
42
|
-
assert r
|
|
43
|
-
|
|
44
|
-
|
|
45
20
|
def test_fill(template_stream, pdf_samples, data_dict, request):
|
|
46
21
|
expected_path = os.path.join(pdf_samples, "sample_filled.pdf")
|
|
47
22
|
with open(expected_path, "rb+") as f:
|
|
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
|