pdfdancer-client-python 0.3.14__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 +77 -22
- pdfdancer/_runtime_version.py +8 -3
- pdfdancer/_version.py +2 -2
- 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} +848 -1310
- pdfdancer/text_editing.py +1472 -0
- pdfdancer/types.py +94 -399
- {pdfdancer_client_python-0.3.14.dist-info → pdfdancer_client_python-3.0.0.dist-info}/METADATA +181 -137
- pdfdancer_client_python-3.0.0.dist-info/RECORD +18 -0
- {pdfdancer_client_python-0.3.14.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.14.dist-info/RECORD +0 -19
- {pdfdancer_client_python-0.3.14.dist-info → pdfdancer_client_python-3.0.0.dist-info}/licenses/LICENSE +0 -0
- {pdfdancer_client_python-0.3.14.dist-info → pdfdancer_client_python-3.0.0.dist-info}/licenses/NOTICE +0 -0
- {pdfdancer_client_python-0.3.14.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,32 +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
|
-
|
|
59
|
-
|
|
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
|
+
)
|
|
60
89
|
|
|
61
90
|
__version__ = resolve_package_version()
|
|
62
91
|
|
|
63
92
|
__all__ = [
|
|
64
93
|
"PDFDancer",
|
|
65
|
-
"ParagraphBuilder",
|
|
66
|
-
"TextLineBuilder",
|
|
67
94
|
"PageBuilder",
|
|
68
95
|
"PathBuilder",
|
|
69
96
|
"LineBuilder",
|
|
70
97
|
"BezierBuilder",
|
|
98
|
+
"RectangleBuilder",
|
|
71
99
|
"ObjectRef",
|
|
72
100
|
"PathObjectRef",
|
|
73
101
|
"ModifyPathRequest",
|
|
@@ -81,9 +109,7 @@ __all__ = [
|
|
|
81
109
|
"ImageTransformType",
|
|
82
110
|
"Size",
|
|
83
111
|
"BoundingRect",
|
|
84
|
-
"Paragraph",
|
|
85
112
|
"FormFieldRef",
|
|
86
|
-
"TextObjectRef",
|
|
87
113
|
"PageRef",
|
|
88
114
|
"PositionMode",
|
|
89
115
|
"ShapeType",
|
|
@@ -91,7 +117,6 @@ __all__ = [
|
|
|
91
117
|
"StandardFonts",
|
|
92
118
|
"PageSize",
|
|
93
119
|
"Orientation",
|
|
94
|
-
"TextStatus",
|
|
95
120
|
"FontRecommendation",
|
|
96
121
|
"FontType",
|
|
97
122
|
"PathSegment",
|
|
@@ -100,9 +125,12 @@ __all__ = [
|
|
|
100
125
|
"Path",
|
|
101
126
|
"PathGroupInfo",
|
|
102
127
|
"PathGroupObject",
|
|
103
|
-
"
|
|
104
|
-
"
|
|
105
|
-
"
|
|
128
|
+
"PDFObjectBase",
|
|
129
|
+
"PathObject",
|
|
130
|
+
"ImageObject",
|
|
131
|
+
"FormObject",
|
|
132
|
+
"FormFieldObject",
|
|
133
|
+
"PathEditSession",
|
|
106
134
|
"PdfDancerException",
|
|
107
135
|
"FontNotFoundException",
|
|
108
136
|
"ValidationException",
|
|
@@ -111,10 +139,37 @@ __all__ = [
|
|
|
111
139
|
"SessionNotFoundException",
|
|
112
140
|
"RateLimitException",
|
|
113
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",
|
|
114
169
|
]
|
|
115
170
|
|
|
116
|
-
from . import
|
|
117
|
-
from .
|
|
171
|
+
from . import pdfdancer_v2
|
|
172
|
+
from .pdfdancer_v2 import PDFDancer
|
|
118
173
|
|
|
119
174
|
|
|
120
175
|
def set_ssl_verify(enabled: bool) -> None:
|
|
@@ -132,4 +187,4 @@ def set_ssl_verify(enabled: bool) -> None:
|
|
|
132
187
|
import pdfdancer
|
|
133
188
|
pdfdancer.set_ssl_verify(False) # Disable SSL verification
|
|
134
189
|
"""
|
|
135
|
-
|
|
190
|
+
pdfdancer_v2.DISABLE_SSL_VERIFY = not enabled
|
pdfdancer/_runtime_version.py
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
from importlib.metadata import PackageNotFoundError
|
|
3
|
+
from importlib.metadata import PackageNotFoundError
|
|
4
|
+
from importlib.metadata import version as get_package_version
|
|
4
5
|
from pathlib import Path
|
|
6
|
+
from typing import Callable, cast
|
|
5
7
|
|
|
6
8
|
|
|
7
9
|
def resolve_package_version(default: str = "0.0.0.dev0") -> str:
|
|
@@ -13,9 +15,12 @@ def resolve_package_version(default: str = "0.0.0.dev0") -> str:
|
|
|
13
15
|
pass
|
|
14
16
|
|
|
15
17
|
try:
|
|
16
|
-
from setuptools_scm import get_version
|
|
18
|
+
from setuptools_scm import get_version # type: ignore[import-not-found]
|
|
17
19
|
|
|
18
|
-
|
|
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
|
+
)
|
|
19
24
|
except Exception:
|
|
20
25
|
pass
|
|
21
26
|
|
pdfdancer/_version.py
CHANGED
|
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
|
|
|
18
18
|
commit_id: str | None
|
|
19
19
|
__commit_id__: str | None
|
|
20
20
|
|
|
21
|
-
__version__ = version = '0.
|
|
22
|
-
__version_tuple__ = version_tuple = (
|
|
21
|
+
__version__ = version = '3.0.0'
|
|
22
|
+
__version_tuple__ = version_tuple = (3, 0, 0)
|
|
23
23
|
|
|
24
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)
|