pdfdancer-client-python 0.3.13__py3-none-any.whl → 3.0.0__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.
- pdfdancer/__init__.py +79 -22
- pdfdancer/_runtime_version.py +30 -0
- pdfdancer/_version.py +24 -0
- pdfdancer/image_builder.py +23 -3
- pdfdancer/models.py +127 -470
- pdfdancer/page_builder.py +6 -17
- pdfdancer/path_builder.py +127 -6
- pdfdancer/{pdfdancer_v1.py → pdfdancer_v2.py} +850 -1316
- pdfdancer/text_editing.py +1472 -0
- pdfdancer/types.py +94 -399
- pdfdancer_client_python-3.0.0.dist-info/METADATA +521 -0
- pdfdancer_client_python-3.0.0.dist-info/RECORD +18 -0
- {pdfdancer_client_python-0.3.13.dist-info → pdfdancer_client_python-3.0.0.dist-info}/WHEEL +1 -1
- pdfdancer/paragraph_builder.py +0 -554
- pdfdancer/text_line_builder.py +0 -290
- pdfdancer_client_python-0.3.13.dist-info/METADATA +0 -685
- pdfdancer_client_python-0.3.13.dist-info/RECORD +0 -17
- {pdfdancer_client_python-0.3.13.dist-info → pdfdancer_client_python-3.0.0.dist-info}/licenses/LICENSE +0 -0
- {pdfdancer_client_python-0.3.13.dist-info → pdfdancer_client_python-3.0.0.dist-info}/licenses/NOTICE +0 -0
- {pdfdancer_client_python-0.3.13.dist-info → pdfdancer_client_python-3.0.0.dist-info}/top_level.txt +0 -0
pdfdancer/__init__.py
CHANGED
|
@@ -6,6 +6,7 @@ Provides a clean, Pythonic interface for PDF operations that closely
|
|
|
6
6
|
mirrors the Java client structure and functionality.
|
|
7
7
|
"""
|
|
8
8
|
|
|
9
|
+
from ._runtime_version import resolve_package_version
|
|
9
10
|
from .exceptions import (
|
|
10
11
|
FontNotFoundException,
|
|
11
12
|
HttpClientException,
|
|
@@ -34,7 +35,6 @@ from .models import (
|
|
|
34
35
|
Orientation,
|
|
35
36
|
PageRef,
|
|
36
37
|
PageSize,
|
|
37
|
-
Paragraph,
|
|
38
38
|
Path,
|
|
39
39
|
PathGroupInfo,
|
|
40
40
|
PathObjectRef,
|
|
@@ -42,30 +42,60 @@ from .models import (
|
|
|
42
42
|
Point,
|
|
43
43
|
Position,
|
|
44
44
|
PositionMode,
|
|
45
|
-
RedactResponse,
|
|
46
|
-
RedactTarget,
|
|
47
|
-
ReflowPreset,
|
|
48
45
|
ShapeType,
|
|
49
46
|
Size,
|
|
50
47
|
StandardFonts,
|
|
51
|
-
TextObjectRef,
|
|
52
|
-
TextStatus,
|
|
53
48
|
)
|
|
54
|
-
from .types import PathGroupObject
|
|
55
49
|
from .page_builder import PageBuilder
|
|
56
|
-
from .
|
|
57
|
-
from .
|
|
58
|
-
|
|
50
|
+
from .path_builder import BezierBuilder, LineBuilder, PathBuilder, RectangleBuilder
|
|
51
|
+
from .text_editing import (
|
|
52
|
+
PdfAffineTransform,
|
|
53
|
+
PdfAffineTransformBuilder,
|
|
54
|
+
PdfColorRequest,
|
|
55
|
+
PdfColorSpace,
|
|
56
|
+
TextDeleteBuilder,
|
|
57
|
+
TextDeleteRequest,
|
|
58
|
+
TextEditChangeDiagnostic,
|
|
59
|
+
TextEditResponse,
|
|
60
|
+
TextInsertBuilder,
|
|
61
|
+
TextInsertCaret,
|
|
62
|
+
TextInsertRequest,
|
|
63
|
+
TextLayoutMode,
|
|
64
|
+
TextLayoutProfile,
|
|
65
|
+
TextLayoutRequest,
|
|
66
|
+
TextOperationDiagnostic,
|
|
67
|
+
TextReplaceBuilder,
|
|
68
|
+
TextReplacementImageRequest,
|
|
69
|
+
TextReplaceRequest,
|
|
70
|
+
TextSelectorRequest,
|
|
71
|
+
TextStyleBuilder,
|
|
72
|
+
TextStyleNumericFilterRequest,
|
|
73
|
+
TextStylePatchRequest,
|
|
74
|
+
TextStyleRequest,
|
|
75
|
+
TextStyleRunFilterRequest,
|
|
76
|
+
TextStyleRunsSelectorRequest,
|
|
77
|
+
TextStyleSelectorRequest,
|
|
78
|
+
TextStyleSetRequest,
|
|
79
|
+
)
|
|
80
|
+
from .types import (
|
|
81
|
+
FormFieldObject,
|
|
82
|
+
FormObject,
|
|
83
|
+
ImageObject,
|
|
84
|
+
PathEditSession,
|
|
85
|
+
PathGroupObject,
|
|
86
|
+
PathObject,
|
|
87
|
+
PDFObjectBase,
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
__version__ = resolve_package_version()
|
|
59
91
|
|
|
60
|
-
__version__ = "0.3.13"
|
|
61
92
|
__all__ = [
|
|
62
93
|
"PDFDancer",
|
|
63
|
-
"ParagraphBuilder",
|
|
64
|
-
"TextLineBuilder",
|
|
65
94
|
"PageBuilder",
|
|
66
95
|
"PathBuilder",
|
|
67
96
|
"LineBuilder",
|
|
68
97
|
"BezierBuilder",
|
|
98
|
+
"RectangleBuilder",
|
|
69
99
|
"ObjectRef",
|
|
70
100
|
"PathObjectRef",
|
|
71
101
|
"ModifyPathRequest",
|
|
@@ -79,9 +109,7 @@ __all__ = [
|
|
|
79
109
|
"ImageTransformType",
|
|
80
110
|
"Size",
|
|
81
111
|
"BoundingRect",
|
|
82
|
-
"Paragraph",
|
|
83
112
|
"FormFieldRef",
|
|
84
|
-
"TextObjectRef",
|
|
85
113
|
"PageRef",
|
|
86
114
|
"PositionMode",
|
|
87
115
|
"ShapeType",
|
|
@@ -89,7 +117,6 @@ __all__ = [
|
|
|
89
117
|
"StandardFonts",
|
|
90
118
|
"PageSize",
|
|
91
119
|
"Orientation",
|
|
92
|
-
"TextStatus",
|
|
93
120
|
"FontRecommendation",
|
|
94
121
|
"FontType",
|
|
95
122
|
"PathSegment",
|
|
@@ -98,9 +125,12 @@ __all__ = [
|
|
|
98
125
|
"Path",
|
|
99
126
|
"PathGroupInfo",
|
|
100
127
|
"PathGroupObject",
|
|
101
|
-
"
|
|
102
|
-
"
|
|
103
|
-
"
|
|
128
|
+
"PDFObjectBase",
|
|
129
|
+
"PathObject",
|
|
130
|
+
"ImageObject",
|
|
131
|
+
"FormObject",
|
|
132
|
+
"FormFieldObject",
|
|
133
|
+
"PathEditSession",
|
|
104
134
|
"PdfDancerException",
|
|
105
135
|
"FontNotFoundException",
|
|
106
136
|
"ValidationException",
|
|
@@ -109,10 +139,37 @@ __all__ = [
|
|
|
109
139
|
"SessionNotFoundException",
|
|
110
140
|
"RateLimitException",
|
|
111
141
|
"set_ssl_verify",
|
|
142
|
+
"PdfAffineTransform",
|
|
143
|
+
"PdfAffineTransformBuilder",
|
|
144
|
+
"PdfColorRequest",
|
|
145
|
+
"PdfColorSpace",
|
|
146
|
+
"TextDeleteBuilder",
|
|
147
|
+
"TextDeleteRequest",
|
|
148
|
+
"TextEditChangeDiagnostic",
|
|
149
|
+
"TextEditResponse",
|
|
150
|
+
"TextInsertBuilder",
|
|
151
|
+
"TextInsertCaret",
|
|
152
|
+
"TextInsertRequest",
|
|
153
|
+
"TextLayoutMode",
|
|
154
|
+
"TextLayoutProfile",
|
|
155
|
+
"TextLayoutRequest",
|
|
156
|
+
"TextOperationDiagnostic",
|
|
157
|
+
"TextReplaceBuilder",
|
|
158
|
+
"TextReplaceRequest",
|
|
159
|
+
"TextReplacementImageRequest",
|
|
160
|
+
"TextSelectorRequest",
|
|
161
|
+
"TextStyleBuilder",
|
|
162
|
+
"TextStyleNumericFilterRequest",
|
|
163
|
+
"TextStylePatchRequest",
|
|
164
|
+
"TextStyleRequest",
|
|
165
|
+
"TextStyleRunFilterRequest",
|
|
166
|
+
"TextStyleRunsSelectorRequest",
|
|
167
|
+
"TextStyleSelectorRequest",
|
|
168
|
+
"TextStyleSetRequest",
|
|
112
169
|
]
|
|
113
170
|
|
|
114
|
-
from . import
|
|
115
|
-
from .
|
|
171
|
+
from . import pdfdancer_v2
|
|
172
|
+
from .pdfdancer_v2 import PDFDancer
|
|
116
173
|
|
|
117
174
|
|
|
118
175
|
def set_ssl_verify(enabled: bool) -> None:
|
|
@@ -130,4 +187,4 @@ def set_ssl_verify(enabled: bool) -> None:
|
|
|
130
187
|
import pdfdancer
|
|
131
188
|
pdfdancer.set_ssl_verify(False) # Disable SSL verification
|
|
132
189
|
"""
|
|
133
|
-
|
|
190
|
+
pdfdancer_v2.DISABLE_SSL_VERIFY = not enabled
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from importlib.metadata import PackageNotFoundError
|
|
4
|
+
from importlib.metadata import version as get_package_version
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
from typing import Callable, cast
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def resolve_package_version(default: str = "0.0.0.dev0") -> str:
|
|
10
|
+
try:
|
|
11
|
+
from ._version import version
|
|
12
|
+
|
|
13
|
+
return version
|
|
14
|
+
except ImportError:
|
|
15
|
+
pass
|
|
16
|
+
|
|
17
|
+
try:
|
|
18
|
+
from setuptools_scm import get_version # type: ignore[import-not-found]
|
|
19
|
+
|
|
20
|
+
scm_get_version = cast(Callable[..., str], get_version)
|
|
21
|
+
return scm_get_version(
|
|
22
|
+
root=str(Path(__file__).resolve().parents[2]), relative_to=__file__
|
|
23
|
+
)
|
|
24
|
+
except Exception:
|
|
25
|
+
pass
|
|
26
|
+
|
|
27
|
+
try:
|
|
28
|
+
return get_package_version("pdfdancer-client-python")
|
|
29
|
+
except PackageNotFoundError:
|
|
30
|
+
return default
|
pdfdancer/_version.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# file generated by vcs-versioning
|
|
2
|
+
# don't change, don't track in version control
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
__all__ = [
|
|
6
|
+
"__version__",
|
|
7
|
+
"__version_tuple__",
|
|
8
|
+
"version",
|
|
9
|
+
"version_tuple",
|
|
10
|
+
"__commit_id__",
|
|
11
|
+
"commit_id",
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
version: str
|
|
15
|
+
__version__: str
|
|
16
|
+
__version_tuple__: tuple[int | str, ...]
|
|
17
|
+
version_tuple: tuple[int | str, ...]
|
|
18
|
+
commit_id: str | None
|
|
19
|
+
__commit_id__: str | None
|
|
20
|
+
|
|
21
|
+
__version__ = version = '3.0.0'
|
|
22
|
+
__version_tuple__ = version_tuple = (3, 0, 0)
|
|
23
|
+
|
|
24
|
+
__commit_id__ = commit_id = None
|
pdfdancer/image_builder.py
CHANGED
|
@@ -6,7 +6,7 @@ from typing import TYPE_CHECKING
|
|
|
6
6
|
from pdfdancer import Image, Position, ValidationException
|
|
7
7
|
|
|
8
8
|
if TYPE_CHECKING:
|
|
9
|
-
from .
|
|
9
|
+
from .pdfdancer_v2 import PDFDancer
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
class ImageBuilder:
|
|
@@ -25,14 +25,24 @@ class ImageBuilder:
|
|
|
25
25
|
self._image = Image()
|
|
26
26
|
|
|
27
27
|
def from_file(self, img_path: Path) -> "ImageBuilder":
|
|
28
|
+
img_path = Path(img_path)
|
|
29
|
+
if not img_path.is_file():
|
|
30
|
+
raise ValidationException(f"Image file not found: {img_path}")
|
|
28
31
|
self._image.data = img_path.read_bytes()
|
|
32
|
+
if not self._image.data:
|
|
33
|
+
raise ValidationException("Image file cannot be empty")
|
|
34
|
+
self._image.format = img_path.suffix.lstrip(".").upper() or None
|
|
29
35
|
return self
|
|
30
36
|
|
|
31
|
-
def at(self, page, x, y) -> "ImageBuilder":
|
|
37
|
+
def at(self, page: int, x: float, y: float) -> "ImageBuilder":
|
|
32
38
|
self._image.position = Position.at_page_coordinates(page, x, y)
|
|
33
39
|
return self
|
|
34
40
|
|
|
35
41
|
def add(self) -> bool:
|
|
42
|
+
if self._image.data is None:
|
|
43
|
+
raise ValidationException("Call from_file() before add()")
|
|
44
|
+
if self._image.position is None:
|
|
45
|
+
raise ValidationException("Call at() before add()")
|
|
36
46
|
# noinspection PyProtectedMember
|
|
37
47
|
return self._client._add_image(self._image, self._image.position)
|
|
38
48
|
|
|
@@ -54,13 +64,23 @@ class ImageOnPageBuilder:
|
|
|
54
64
|
self._page_number = page_number
|
|
55
65
|
|
|
56
66
|
def from_file(self, img_path: Path) -> "ImageOnPageBuilder":
|
|
67
|
+
img_path = Path(img_path)
|
|
68
|
+
if not img_path.is_file():
|
|
69
|
+
raise ValidationException(f"Image file not found: {img_path}")
|
|
57
70
|
self._image.data = img_path.read_bytes()
|
|
71
|
+
if not self._image.data:
|
|
72
|
+
raise ValidationException("Image file cannot be empty")
|
|
73
|
+
self._image.format = img_path.suffix.lstrip(".").upper() or None
|
|
58
74
|
return self
|
|
59
75
|
|
|
60
|
-
def at(self, x, y) -> "ImageOnPageBuilder":
|
|
76
|
+
def at(self, x: float, y: float) -> "ImageOnPageBuilder":
|
|
61
77
|
self._image.position = Position.at_page_coordinates(self._page_number, x, y)
|
|
62
78
|
return self
|
|
63
79
|
|
|
64
80
|
def add(self) -> bool:
|
|
81
|
+
if self._image.data is None:
|
|
82
|
+
raise ValidationException("Call from_file() before add()")
|
|
83
|
+
if self._image.position is None:
|
|
84
|
+
raise ValidationException("Call at() before add()")
|
|
65
85
|
# noinspection PyProtectedMember
|
|
66
86
|
return self._client._add_image(self._image, self._image.position)
|