PyPDFForm 1.4.27__tar.gz → 1.4.29__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.29}/PKG-INFO +2 -24
- pypdfform-1.4.29/PyPDFForm/__init__.py +6 -0
- {pypdfform-1.4.27 → pypdfform-1.4.29}/PyPDFForm/filler.py +0 -1
- {pypdfform-1.4.27 → pypdfform-1.4.29}/PyPDFForm/wrapper.py +4 -50
- {pypdfform-1.4.27 → pypdfform-1.4.29}/PyPDFForm.egg-info/PKG-INFO +2 -24
- {pypdfform-1.4.27 → pypdfform-1.4.29}/README.md +1 -23
- {pypdfform-1.4.27 → pypdfform-1.4.29}/tests/test_adobe_mode.py +52 -0
- {pypdfform-1.4.27 → pypdfform-1.4.29}/tests/test_functional.py +22 -26
- pypdfform-1.4.27/PyPDFForm/__init__.py +0 -6
- {pypdfform-1.4.27 → pypdfform-1.4.29}/LICENSE +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.29}/PyPDFForm/adapter.py +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.29}/PyPDFForm/constants.py +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.29}/PyPDFForm/coordinate.py +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.29}/PyPDFForm/font.py +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.29}/PyPDFForm/image.py +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.29}/PyPDFForm/middleware/__init__.py +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.29}/PyPDFForm/middleware/base.py +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.29}/PyPDFForm/middleware/checkbox.py +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.29}/PyPDFForm/middleware/dropdown.py +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.29}/PyPDFForm/middleware/image.py +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.29}/PyPDFForm/middleware/radio.py +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.29}/PyPDFForm/middleware/signature.py +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.29}/PyPDFForm/middleware/text.py +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.29}/PyPDFForm/patterns.py +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.29}/PyPDFForm/template.py +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.29}/PyPDFForm/utils.py +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.29}/PyPDFForm/watermark.py +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.29}/PyPDFForm/widgets/__init__.py +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.29}/PyPDFForm/widgets/base.py +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.29}/PyPDFForm/widgets/checkbox.py +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.29}/PyPDFForm/widgets/dropdown.py +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.29}/PyPDFForm/widgets/text.py +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.29}/PyPDFForm.egg-info/SOURCES.txt +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.29}/PyPDFForm.egg-info/dependency_links.txt +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.29}/PyPDFForm.egg-info/requires.txt +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.29}/PyPDFForm.egg-info/top_level.txt +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.29}/setup.cfg +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.29}/setup.py +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.29}/tests/test_create_widget.py +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.29}/tests/test_dropdown.py +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.29}/tests/test_dropdown_simple.py +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.29}/tests/test_fill_max_length_text_field.py +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.29}/tests/test_fill_max_length_text_field_simple.py +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.29}/tests/test_functional_simple.py +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.29}/tests/test_paragraph.py +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.29}/tests/test_paragraph_simple.py +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.29}/tests/test_preview.py +0 -0
- {pypdfform-1.4.27 → pypdfform-1.4.29}/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.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.
|
|
@@ -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.
|
|
@@ -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
|
|
@@ -73,12 +57,6 @@ and it should look like [this](https://github.com/chinapandaman/PyPDFForm/raw/ma
|
|
|
73
57
|
|
|
74
58
|
The official documentation can be found on [the GitHub page](https://chinapandaman.github.io/PyPDFForm/) of this repository.
|
|
75
59
|
|
|
76
|
-
##
|
|
60
|
+
## Other Resources
|
|
77
61
|
|
|
78
62
|
[Chicago Python User Group - Dec 14, 2023](https://youtu.be/8t1RdAKwr9w?si=TLgumBNXv9H8szSn)
|
|
79
|
-
|
|
80
|
-
## How to Contribute
|
|
81
|
-
|
|
82
|
-
It is difficult to make sure that the library supports all the PDF form creating tools out
|
|
83
|
-
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
|
|
84
|
-
to make the library support the attached PDF form as well as the tool used to create it.
|
|
@@ -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:
|
|
@@ -247,6 +222,27 @@ def test_draw_text_on_one_page(template_stream, pdf_samples, request):
|
|
|
247
222
|
assert obj.stream == expected
|
|
248
223
|
|
|
249
224
|
|
|
225
|
+
def test_draw_text_new_line_symbol(template_stream, pdf_samples, request):
|
|
226
|
+
expected_path = os.path.join(
|
|
227
|
+
pdf_samples, "sample_pdf_with_drawn_text_new_line_symbol.pdf"
|
|
228
|
+
)
|
|
229
|
+
with open(expected_path, "rb+") as f:
|
|
230
|
+
obj = PdfWrapper(template_stream).draw_text(
|
|
231
|
+
"test\ntest\ntest",
|
|
232
|
+
1,
|
|
233
|
+
300,
|
|
234
|
+
225,
|
|
235
|
+
)
|
|
236
|
+
|
|
237
|
+
request.config.results["expected_path"] = expected_path
|
|
238
|
+
request.config.results["stream"] = obj.read()
|
|
239
|
+
|
|
240
|
+
expected = f.read()
|
|
241
|
+
|
|
242
|
+
assert len(obj.stream) == len(expected)
|
|
243
|
+
assert obj.stream == expected
|
|
244
|
+
|
|
245
|
+
|
|
250
246
|
def test_draw_image_on_one_page(template_stream, image_samples, pdf_samples, request):
|
|
251
247
|
expected_path = os.path.join(pdf_samples, "sample_pdf_with_image.pdf")
|
|
252
248
|
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
|