PyPDFForm 4.7.9__tar.gz → 4.7.10__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.
- {pypdfform-4.7.9 → pypdfform-4.7.10}/PKG-INFO +2 -2
- {pypdfform-4.7.9 → pypdfform-4.7.10}/PyPDFForm/__init__.py +1 -1
- {pypdfform-4.7.9 → pypdfform-4.7.10}/PyPDFForm/cli/__init__.py +9 -3
- pypdfform-4.7.10/PyPDFForm/cli/coordinate.py +80 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/PyPDFForm/cli/update.py +7 -8
- {pypdfform-4.7.9 → pypdfform-4.7.10}/PyPDFForm/lib/middleware/base.py +1 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/PyPDFForm/lib/template.py +13 -5
- {pypdfform-4.7.9 → pypdfform-4.7.10}/PyPDFForm.egg-info/PKG-INFO +2 -2
- {pypdfform-4.7.9 → pypdfform-4.7.10}/PyPDFForm.egg-info/SOURCES.txt +1 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/PyPDFForm.egg-info/requires.txt +1 -1
- {pypdfform-4.7.9 → pypdfform-4.7.10}/pyproject.toml +2 -1
- {pypdfform-4.7.9 → pypdfform-4.7.10}/tests/test_bulk_create_fields.py +15 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/tests/test_cli.py +13 -1
- {pypdfform-4.7.9 → pypdfform-4.7.10}/tests/test_functional.py +6 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/LICENSE +0 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/PyPDFForm/lib/__init__.py +0 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/PyPDFForm/lib/adapter.py +0 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/PyPDFForm/lib/annotations/__init__.py +0 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/PyPDFForm/lib/annotations/base.py +0 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/PyPDFForm/lib/annotations/link.py +0 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/PyPDFForm/lib/annotations/stamp.py +0 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/PyPDFForm/lib/annotations/text.py +0 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/PyPDFForm/lib/annotations/text_markup.py +0 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/PyPDFForm/lib/assets/__init__.py +0 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/PyPDFForm/lib/assets/bedrock.py +0 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/PyPDFForm/lib/assets/blank.py +0 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/PyPDFForm/lib/constants.py +0 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/PyPDFForm/lib/coordinate.py +0 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/PyPDFForm/lib/deprecation.py +0 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/PyPDFForm/lib/egress.py +0 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/PyPDFForm/lib/filler.py +0 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/PyPDFForm/lib/font.py +0 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/PyPDFForm/lib/hooks.py +0 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/PyPDFForm/lib/image.py +0 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/PyPDFForm/lib/middleware/__init__.py +0 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/PyPDFForm/lib/middleware/checkbox.py +0 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/PyPDFForm/lib/middleware/dropdown.py +0 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/PyPDFForm/lib/middleware/image.py +0 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/PyPDFForm/lib/middleware/radio.py +0 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/PyPDFForm/lib/middleware/signature.py +0 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/PyPDFForm/lib/middleware/text.py +0 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/PyPDFForm/lib/patterns.py +0 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/PyPDFForm/lib/raw/__init__.py +0 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/PyPDFForm/lib/raw/circle.py +0 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/PyPDFForm/lib/raw/ellipse.py +0 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/PyPDFForm/lib/raw/image.py +0 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/PyPDFForm/lib/raw/line.py +0 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/PyPDFForm/lib/raw/rect.py +0 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/PyPDFForm/lib/raw/text.py +0 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/PyPDFForm/lib/types.py +0 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/PyPDFForm/lib/utils.py +0 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/PyPDFForm/lib/watermark.py +0 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/PyPDFForm/lib/widgets/__init__.py +0 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/PyPDFForm/lib/widgets/base.py +0 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/PyPDFForm/lib/widgets/checkbox.py +0 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/PyPDFForm/lib/widgets/dropdown.py +0 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/PyPDFForm/lib/widgets/image.py +0 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/PyPDFForm/lib/widgets/radio.py +0 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/PyPDFForm/lib/widgets/signature.py +0 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/PyPDFForm/lib/widgets/text.py +0 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/PyPDFForm/lib/wrapper.py +0 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/PyPDFForm.egg-info/dependency_links.txt +0 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/PyPDFForm.egg-info/entry_points.txt +0 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/PyPDFForm.egg-info/top_level.txt +0 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/README.md +0 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/setup.cfg +0 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/tests/test_create_widget.py +0 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/tests/test_draw_elements.py +0 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/tests/test_dropdown.py +0 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/tests/test_extract_middleware_attributes.py +0 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/tests/test_fill_max_length_text_field.py +0 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/tests/test_font_widths.py +0 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/tests/test_generate_appearance_streams.py +0 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/tests/test_js.py +0 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/tests/test_need_appearances.py +0 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/tests/test_paragraph.py +0 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/tests/test_signature.py +0 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/tests/test_use_full_widget_name.py +0 -0
- {pypdfform-4.7.9 → pypdfform-4.7.10}/tests/test_widget_attr_trigger.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: PyPDFForm
|
|
3
|
-
Version: 4.7.
|
|
3
|
+
Version: 4.7.10
|
|
4
4
|
Summary: The Python library for PDF forms.
|
|
5
5
|
Author: Jinge Li
|
|
6
6
|
License-Expression: MIT
|
|
@@ -24,7 +24,7 @@ Requires-Dist: cryptography<47.0.0,>=46.0.3
|
|
|
24
24
|
Requires-Dist: fonttools<5.0.0,>=4.60.1
|
|
25
25
|
Requires-Dist: pikepdf<11.0.0,>=10.5.0
|
|
26
26
|
Requires-Dist: pillow<13.0.0,>=12.0.0
|
|
27
|
-
Requires-Dist: pypdf<
|
|
27
|
+
Requires-Dist: pypdf<6.10.0,>=6.9.0
|
|
28
28
|
Requires-Dist: reportlab<5.0.0,>=4.4.6
|
|
29
29
|
Provides-Extra: cli
|
|
30
30
|
Requires-Dist: typer<1.0.0,>=0.24.1; extra == "cli"
|
|
@@ -11,11 +11,17 @@ from typing import Annotated
|
|
|
11
11
|
import typer
|
|
12
12
|
|
|
13
13
|
from .. import __version__
|
|
14
|
+
from .coordinate import coordinate_cli
|
|
14
15
|
from .update import update_cli
|
|
15
16
|
|
|
16
17
|
cli_app = typer.Typer(
|
|
17
18
|
context_settings={"help_option_names": ["--help", "-h"]}, no_args_is_help=True
|
|
18
19
|
)
|
|
20
|
+
cli_app.add_typer(
|
|
21
|
+
coordinate_cli,
|
|
22
|
+
name="coordinate",
|
|
23
|
+
help="Subcommands for interacting with PDF coordinates and dimensions.",
|
|
24
|
+
)
|
|
19
25
|
cli_app.add_typer(
|
|
20
26
|
update_cli,
|
|
21
27
|
name="update",
|
|
@@ -114,7 +120,7 @@ def use_full_widget_name_callback(ctx: typer.Context, value: bool) -> None:
|
|
|
114
120
|
ctx.obj["use_full_widget_name"] = value
|
|
115
121
|
|
|
116
122
|
|
|
117
|
-
@cli_app.callback(invoke_without_command=True, help="
|
|
123
|
+
@cli_app.callback(invoke_without_command=True, help="PyPDFForm command-line interface.")
|
|
118
124
|
def main(
|
|
119
125
|
version: Annotated[ # pylint: disable=W0613
|
|
120
126
|
bool,
|
|
@@ -123,7 +129,7 @@ def main(
|
|
|
123
129
|
"-v",
|
|
124
130
|
callback=version_callback,
|
|
125
131
|
is_eager=True,
|
|
126
|
-
help="Show current version of the CLI and exit.",
|
|
132
|
+
help="Show the current version of the CLI and exit.",
|
|
127
133
|
),
|
|
128
134
|
] = False,
|
|
129
135
|
need_appearances: Annotated[ # pylint: disable=W0613
|
|
@@ -147,7 +153,7 @@ def main(
|
|
|
147
153
|
typer.Option(
|
|
148
154
|
"--preserve-metadata",
|
|
149
155
|
callback=preserve_metadata_callback,
|
|
150
|
-
help="Preserve PDF metadata in output.",
|
|
156
|
+
help="Preserve PDF metadata in the output.",
|
|
151
157
|
),
|
|
152
158
|
] = False,
|
|
153
159
|
use_full_widget_name: Annotated[ # pylint: disable=W0613
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""
|
|
3
|
+
CLI commands for interacting with PDF coordinates.
|
|
4
|
+
|
|
5
|
+
This module provides command-line interface commands for working with
|
|
6
|
+
PDF coordinates and dimensions, such as generating a coordinate grid view.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from typing import Annotated
|
|
10
|
+
|
|
11
|
+
import typer
|
|
12
|
+
|
|
13
|
+
from .. import PdfWrapper
|
|
14
|
+
|
|
15
|
+
coordinate_cli = typer.Typer(
|
|
16
|
+
context_settings={"help_option_names": ["--help", "-h"]}, no_args_is_help=True
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@coordinate_cli.command(no_args_is_help=True)
|
|
21
|
+
def grid(
|
|
22
|
+
ctx: typer.Context,
|
|
23
|
+
pdf: Annotated[str, typer.Argument(help="Path to the input PDF file.")],
|
|
24
|
+
output: Annotated[
|
|
25
|
+
str,
|
|
26
|
+
typer.Option(
|
|
27
|
+
"--output",
|
|
28
|
+
"-o",
|
|
29
|
+
help="Path to save the output PDF. Defaults to the original path if not specified.",
|
|
30
|
+
),
|
|
31
|
+
] = None,
|
|
32
|
+
red: Annotated[
|
|
33
|
+
float,
|
|
34
|
+
typer.Option(
|
|
35
|
+
"--red",
|
|
36
|
+
"-r",
|
|
37
|
+
help="Red channel of the RGB color.",
|
|
38
|
+
),
|
|
39
|
+
] = None,
|
|
40
|
+
green: Annotated[
|
|
41
|
+
float,
|
|
42
|
+
typer.Option(
|
|
43
|
+
"--green",
|
|
44
|
+
"-g",
|
|
45
|
+
help="Green channel of the RGB color.",
|
|
46
|
+
),
|
|
47
|
+
] = None,
|
|
48
|
+
blue: Annotated[
|
|
49
|
+
float,
|
|
50
|
+
typer.Option(
|
|
51
|
+
"--blue",
|
|
52
|
+
"-b",
|
|
53
|
+
help="Blue channel of the RGB color.",
|
|
54
|
+
),
|
|
55
|
+
] = None,
|
|
56
|
+
margin: Annotated[
|
|
57
|
+
float,
|
|
58
|
+
typer.Option(
|
|
59
|
+
"--margin",
|
|
60
|
+
"-m",
|
|
61
|
+
help="Margin of the grid view in points.",
|
|
62
|
+
),
|
|
63
|
+
] = None,
|
|
64
|
+
) -> None:
|
|
65
|
+
"""
|
|
66
|
+
Generate a coordinate grid view for a PDF.
|
|
67
|
+
"""
|
|
68
|
+
params = {}
|
|
69
|
+
if any(
|
|
70
|
+
[
|
|
71
|
+
red is not None,
|
|
72
|
+
green is not None,
|
|
73
|
+
blue is not None,
|
|
74
|
+
]
|
|
75
|
+
):
|
|
76
|
+
params["color"] = (red or 0, green or 0, blue or 0)
|
|
77
|
+
|
|
78
|
+
if margin is not None:
|
|
79
|
+
params["margin"] = int(margin) if margin.is_integer() else margin
|
|
80
|
+
PdfWrapper(pdf, **ctx.obj).generate_coordinate_grid(**params).write(output or pdf)
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
|
-
# TODO: fix this docstring
|
|
3
2
|
"""
|
|
4
|
-
CLI commands for updating
|
|
3
|
+
CLI commands for updating PDFs.
|
|
5
4
|
|
|
6
5
|
This module provides command-line interface commands for modifying
|
|
7
|
-
PDF
|
|
6
|
+
PDF files, such as updating metadata or other elements.
|
|
8
7
|
These commands allow users to update PDF documents directly from
|
|
9
|
-
the terminal without needing to
|
|
8
|
+
the terminal without needing to write Python code.
|
|
10
9
|
|
|
11
10
|
The commands in this module wrap the functionality provided by
|
|
12
11
|
the PdfWrapper class, exposing it through a Typer-based CLI for
|
|
@@ -27,20 +26,20 @@ update_cli = typer.Typer(
|
|
|
27
26
|
@update_cli.command(no_args_is_help=True)
|
|
28
27
|
def title(
|
|
29
28
|
ctx: typer.Context,
|
|
30
|
-
pdf: Annotated[str, typer.Argument(help="
|
|
29
|
+
pdf: Annotated[str, typer.Argument(help="Path to the input PDF file.")],
|
|
31
30
|
new_title: Annotated[
|
|
32
|
-
str, typer.Option("--title", "-t", help="The new title for the PDF.")
|
|
31
|
+
str, typer.Option("--title", "-t", help="The new title for the PDF file.")
|
|
33
32
|
],
|
|
34
33
|
output: Annotated[
|
|
35
34
|
str,
|
|
36
35
|
typer.Option(
|
|
37
36
|
"--output",
|
|
38
37
|
"-o",
|
|
39
|
-
help="
|
|
38
|
+
help="Path to save the output PDF. Defaults to the original path if not specified.",
|
|
40
39
|
),
|
|
41
40
|
] = None,
|
|
42
41
|
) -> None:
|
|
43
42
|
"""
|
|
44
|
-
Update the title of a PDF.
|
|
43
|
+
Update the title of a PDF file.
|
|
45
44
|
"""
|
|
46
45
|
PdfWrapper(pdf, title=new_title, **ctx.obj).write(output or pdf)
|
|
@@ -62,6 +62,7 @@ class Widget:
|
|
|
62
62
|
self.hooks_to_trigger: list = []
|
|
63
63
|
|
|
64
64
|
# coordinate & dimension
|
|
65
|
+
self.page_number: Optional[int] = None
|
|
65
66
|
self.x: Optional[float | List[float]] = None
|
|
66
67
|
self.y: Optional[float | List[float]] = None
|
|
67
68
|
self.width: Optional[float | List[float]] = None
|
|
@@ -73,28 +73,32 @@ def build_widgets(
|
|
|
73
73
|
"""
|
|
74
74
|
results = {}
|
|
75
75
|
|
|
76
|
-
for widgets in get_widgets_by_page(pdf_stream).
|
|
76
|
+
for page_num, widgets in get_widgets_by_page(pdf_stream).items():
|
|
77
77
|
for widget in widgets:
|
|
78
|
-
_process_widget(widget, use_full_widget_name, results)
|
|
78
|
+
_process_widget(widget, page_num, use_full_widget_name, results)
|
|
79
79
|
|
|
80
80
|
return results
|
|
81
81
|
|
|
82
82
|
|
|
83
83
|
def _process_widget(
|
|
84
|
-
widget: dict,
|
|
84
|
+
widget: dict,
|
|
85
|
+
page_number: int,
|
|
86
|
+
use_full_widget_name: bool,
|
|
87
|
+
results: Dict[str, WIDGET_TYPES],
|
|
85
88
|
) -> None:
|
|
86
89
|
"""
|
|
87
90
|
Processes a single widget and adds it to the results dictionary.
|
|
88
91
|
|
|
89
92
|
Args:
|
|
90
93
|
widget (dict): The widget dictionary from the PDF.
|
|
94
|
+
page_number (int): The 1-indexed page number the widget appears on.
|
|
91
95
|
use_full_widget_name (bool): Whether to use the full widget name.
|
|
92
96
|
results (Dict[str, WIDGET_TYPES]): The dictionary of widgets being built.
|
|
93
97
|
"""
|
|
94
98
|
key = get_widget_key(widget, use_full_widget_name)
|
|
95
99
|
_widget = construct_widget(widget, key)
|
|
96
100
|
if _widget is not None:
|
|
97
|
-
_populate_common_properties(widget, _widget)
|
|
101
|
+
_populate_common_properties(widget, page_number, _widget)
|
|
98
102
|
|
|
99
103
|
if isinstance(_widget, Text):
|
|
100
104
|
_populate_text_properties(widget, _widget)
|
|
@@ -111,15 +115,19 @@ def _process_widget(
|
|
|
111
115
|
results[key] = _widget
|
|
112
116
|
|
|
113
117
|
|
|
114
|
-
def _populate_common_properties(
|
|
118
|
+
def _populate_common_properties(
|
|
119
|
+
widget: dict, page_number: int, _widget: WIDGET_TYPES
|
|
120
|
+
) -> None:
|
|
115
121
|
"""
|
|
116
122
|
Populates common properties for a widget.
|
|
117
123
|
|
|
118
124
|
Args:
|
|
119
125
|
widget (dict): The widget dictionary from the PDF.
|
|
126
|
+
page_number (int): The 1-indexed page number the widget appears on.
|
|
120
127
|
_widget (WIDGET_TYPES): The widget object to populate.
|
|
121
128
|
"""
|
|
122
129
|
# widget property extractions don't trigger hooks in this function
|
|
130
|
+
_widget.__dict__["page_number"] = page_number
|
|
123
131
|
_widget.__dict__["tooltip"] = extract_widget_property(
|
|
124
132
|
widget, WIDGET_DESCRIPTION_PATTERNS, None, str
|
|
125
133
|
)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: PyPDFForm
|
|
3
|
-
Version: 4.7.
|
|
3
|
+
Version: 4.7.10
|
|
4
4
|
Summary: The Python library for PDF forms.
|
|
5
5
|
Author: Jinge Li
|
|
6
6
|
License-Expression: MIT
|
|
@@ -24,7 +24,7 @@ Requires-Dist: cryptography<47.0.0,>=46.0.3
|
|
|
24
24
|
Requires-Dist: fonttools<5.0.0,>=4.60.1
|
|
25
25
|
Requires-Dist: pikepdf<11.0.0,>=10.5.0
|
|
26
26
|
Requires-Dist: pillow<13.0.0,>=12.0.0
|
|
27
|
-
Requires-Dist: pypdf<
|
|
27
|
+
Requires-Dist: pypdf<6.10.0,>=6.9.0
|
|
28
28
|
Requires-Dist: reportlab<5.0.0,>=4.4.6
|
|
29
29
|
Provides-Extra: cli
|
|
30
30
|
Requires-Dist: typer<1.0.0,>=0.24.1; extra == "cli"
|
|
@@ -29,7 +29,7 @@ dependencies = [
|
|
|
29
29
|
"fonttools>=4.60.1,<5.0.0",
|
|
30
30
|
"pikepdf>=10.5.0,<11.0.0",
|
|
31
31
|
"pillow>=12.0.0,<13.0.0",
|
|
32
|
-
"pypdf>=6.9.0,<
|
|
32
|
+
"pypdf>=6.9.0,<6.10.0", # TODO: revert this
|
|
33
33
|
"reportlab>=4.4.6,<5.0.0",
|
|
34
34
|
]
|
|
35
35
|
|
|
@@ -139,4 +139,5 @@ include = ["PyPDFForm*"]
|
|
|
139
139
|
[tool.pytest.ini_options]
|
|
140
140
|
markers = [
|
|
141
141
|
"posix_only", # mainly because of zlib vs zlib-ng
|
|
142
|
+
"cli_test",
|
|
142
143
|
]
|
|
@@ -62,6 +62,21 @@ def test_bulk_create_fields_stress_max(pdf_samples, request):
|
|
|
62
62
|
obj += PdfWrapper(os.path.join(pdf_samples, "dummy.pdf"))
|
|
63
63
|
obj.bulk_create_fields(fields)
|
|
64
64
|
|
|
65
|
+
prefix_to_page = {
|
|
66
|
+
"text_": 1,
|
|
67
|
+
"check_": 2,
|
|
68
|
+
"dropdown_": 3,
|
|
69
|
+
"radio_": 4,
|
|
70
|
+
"image_": 5,
|
|
71
|
+
"signature_": 6,
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
for k, v in obj.widgets.items():
|
|
75
|
+
for each, page in prefix_to_page.items():
|
|
76
|
+
if k.startswith(each):
|
|
77
|
+
assert v.page_number == page
|
|
78
|
+
break
|
|
79
|
+
|
|
65
80
|
request.config.results["expected_path"] = expected_path
|
|
66
81
|
request.config.results["stream"] = obj.read()
|
|
67
82
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
2
|
|
|
3
|
+
import pytest
|
|
3
4
|
from typer.testing import CliRunner
|
|
4
5
|
|
|
5
6
|
from PyPDFForm import __version__
|
|
@@ -8,15 +9,17 @@ from PyPDFForm.cli import cli_app
|
|
|
8
9
|
runner = CliRunner()
|
|
9
10
|
|
|
10
11
|
|
|
12
|
+
@pytest.mark.cli_test
|
|
11
13
|
def test_root_command():
|
|
12
14
|
result = runner.invoke(cli_app)
|
|
13
15
|
assert result.exit_code == 2
|
|
14
16
|
|
|
15
|
-
assert "
|
|
17
|
+
assert "PyPDFForm command-line interface." in result.output
|
|
16
18
|
assert "Usage:" in result.output
|
|
17
19
|
assert "main" not in result.output
|
|
18
20
|
|
|
19
21
|
|
|
22
|
+
@pytest.mark.cli_test
|
|
20
23
|
def test_root_command_with_version():
|
|
21
24
|
long = runner.invoke(cli_app, ["--version"])
|
|
22
25
|
short = runner.invoke(cli_app, ["-v"])
|
|
@@ -28,6 +31,15 @@ def test_root_command_with_version():
|
|
|
28
31
|
assert long.output == short.output
|
|
29
32
|
|
|
30
33
|
|
|
34
|
+
@pytest.mark.cli_test
|
|
35
|
+
def test_coordinate_command():
|
|
36
|
+
result = runner.invoke(cli_app, ["coordinate"])
|
|
37
|
+
assert result.exit_code == 2
|
|
38
|
+
|
|
39
|
+
assert "Usage:" in result.output
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
@pytest.mark.cli_test
|
|
31
43
|
def test_update_command():
|
|
32
44
|
result = runner.invoke(cli_app, ["update"])
|
|
33
45
|
assert result.exit_code == 2
|
|
@@ -747,31 +747,37 @@ def test_widget_coord_resolution():
|
|
|
747
747
|
]
|
|
748
748
|
)
|
|
749
749
|
|
|
750
|
+
assert obj.widgets["text"].page_number == 1
|
|
750
751
|
assert obj.widgets["text"].x == 50
|
|
751
752
|
assert obj.widgets["text"].y == 100
|
|
752
753
|
assert obj.widgets["text"].width == 200
|
|
753
754
|
assert obj.widgets["text"].height == 150
|
|
754
755
|
|
|
756
|
+
assert obj.widgets["check"].page_number == 1
|
|
755
757
|
assert obj.widgets["check"].x == 150
|
|
756
758
|
assert obj.widgets["check"].y == 200
|
|
757
759
|
assert obj.widgets["check"].width == 60
|
|
758
760
|
assert obj.widgets["check"].height == 60
|
|
759
761
|
|
|
762
|
+
assert obj.widgets["radio"].page_number == 1
|
|
760
763
|
assert obj.widgets["radio"].x == [400, 500, 600]
|
|
761
764
|
assert obj.widgets["radio"].y == [450, 550, 650]
|
|
762
765
|
assert obj.widgets["radio"].width == 10
|
|
763
766
|
assert obj.widgets["radio"].height == 10
|
|
764
767
|
|
|
768
|
+
assert obj.widgets["dropdown"].page_number == 1
|
|
765
769
|
assert obj.widgets["dropdown"].x == 400
|
|
766
770
|
assert obj.widgets["dropdown"].y == 100
|
|
767
771
|
assert obj.widgets["dropdown"].width == 250
|
|
768
772
|
assert obj.widgets["dropdown"].height == 200
|
|
769
773
|
|
|
774
|
+
assert obj.widgets["image"].page_number == 1
|
|
770
775
|
assert obj.widgets["image"].x == 300
|
|
771
776
|
assert obj.widgets["image"].y == 400
|
|
772
777
|
assert obj.widgets["image"].width == 400
|
|
773
778
|
assert obj.widgets["image"].height == 300
|
|
774
779
|
|
|
780
|
+
assert obj.widgets["signature"].page_number == 1
|
|
775
781
|
assert obj.widgets["signature"].x == 500
|
|
776
782
|
assert obj.widgets["signature"].y == 600
|
|
777
783
|
assert obj.widgets["signature"].width == 600
|
|
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
|
|
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
|