forked from pdfrest/pdfrest-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpublic.py
More file actions
221 lines (189 loc) · 5.38 KB
/
Copy pathpublic.py
File metadata and controls
221 lines (189 loc) · 5.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
"""Public type definitions for the pdfrest client."""
from __future__ import annotations
from collections.abc import Sequence
from typing import TYPE_CHECKING, Any, Literal, cast, get_args
from typing_extensions import Required, TypedDict
if TYPE_CHECKING:
from pdfrest.models import PdfRestFile
else: # pragma: no cover - used only for typing at runtime
PdfRestFile = Any
__all__ = (
"ALL_OCR_LANGUAGES",
"ALL_PDF_INFO_QUERIES",
"ALL_PDF_RESTRICTIONS",
"BmpColorModel",
"CompressionLevel",
"ExtractTextGranularity",
"FlattenQuality",
"GifColorModel",
"GraphicSmoothing",
"HtmlPageOrientation",
"HtmlPageSize",
"HtmlWebLayout",
"JpegColorModel",
"OcrLanguage",
"PdfAType",
"PdfAddTextObject",
"PdfCmykColor",
"PdfConversionCompression",
"PdfConversionDownsample",
"PdfConversionLocale",
"PdfCustomPageSize",
"PdfInfoQuery",
"PdfMergeInput",
"PdfMergeSource",
"PdfPageOrientation",
"PdfPageSelection",
"PdfPageSize",
"PdfRGBColor",
"PdfRedactionInstruction",
"PdfRedactionPreset",
"PdfRedactionType",
"PdfRestriction",
"PdfXType",
"PngColorModel",
"SummaryFormat",
"SummaryOutputFormat",
"SummaryOutputType",
"TiffColorModel",
"TranslateOutputFormat",
)
PdfInfoQuery = Literal[
"tagged",
"image_only",
"title",
"subject",
"author",
"producer",
"creator",
"creation_date",
"modified_date",
"keywords",
"custom_metadata",
"doc_language",
"page_count",
"contains_annotations",
"contains_signature",
"pdf_version",
"file_size",
"filename",
"restrict_permissions_set",
"contains_xfa",
"contains_acroforms",
"contains_javascript",
"contains_transparency",
"contains_embedded_file",
"uses_embedded_fonts",
"uses_nonembedded_fonts",
"pdfa",
"pdfua_claim",
"pdfe_claim",
"pdfx_claim",
"requires_password_to_open",
]
ALL_PDF_INFO_QUERIES: tuple[PdfInfoQuery, ...] = cast(
tuple[PdfInfoQuery, ...], get_args(PdfInfoQuery)
)
PdfRedactionType = Literal["literal", "regex", "preset"]
PdfRedactionPreset = Literal[
"email",
"phone_number",
"date",
"us_ssn",
"url",
"credit_card",
"credit_debit_pin",
"bank_routing_number",
"international_bank_account_number",
"swift_bic_number",
"ipv4",
"ipv6",
]
class PdfRedactionInstruction(TypedDict):
type: PdfRedactionType
value: PdfRedactionPreset | str
PdfRGBColor = tuple[int, int, int]
PdfCmykColor = tuple[int, int, int, int]
class PdfAddTextObject(TypedDict, total=False):
font: Required[str]
max_width: Required[float]
opacity: Required[float]
page: Required[Literal["all"] | int]
rotation: Required[float]
text: Required[str]
text_color_rgb: PdfRGBColor
text_color_cmyk: PdfCmykColor
text_size: Required[float]
x: Required[float]
y: Required[float]
is_right_to_left: bool
class PdfCustomPageSize(TypedDict):
custom_height: Required[float]
custom_width: Required[float]
PdfPageSelection = str | int | Sequence[str | int]
class PdfMergeSource(TypedDict, total=False):
file: Required[PdfRestFile]
pages: PdfPageSelection | None
PdfMergeInput = PdfRestFile | PdfMergeSource | tuple[PdfRestFile, PdfPageSelection]
PdfConversionCompression = Literal["lossy", "lossless"]
PdfConversionDownsample = Literal["off", 75, 150, 300, 600, 1200]
PdfConversionLocale = Literal["US", "Germany"]
HtmlPageSize = Literal["letter", "legal", "ledger", "A3", "A4", "A5"]
HtmlPageOrientation = Literal["portrait", "landscape"]
HtmlWebLayout = Literal["desktop", "tablet", "mobile"]
PdfAType = Literal["PDF/A-1b", "PDF/A-2b", "PDF/A-2u", "PDF/A-3b", "PDF/A-3u"]
PdfXType = Literal["PDF/X-1a", "PDF/X-3", "PDF/X-4", "PDF/X-6"]
ExtractTextGranularity = Literal["off", "by_page", "document"]
CompressionLevel = Literal["low", "medium", "high", "custom"]
FlattenQuality = Literal["low", "medium", "high"]
PngColorModel = Literal["rgb", "rgba", "gray"]
BmpColorModel = Literal["rgb", "gray"]
GifColorModel = Literal["rgb", "gray"]
JpegColorModel = Literal["rgb", "cmyk", "gray"]
TiffColorModel = Literal["rgb", "rgba", "cmyk", "lab", "gray"]
GraphicSmoothing = Literal["none", "all", "text", "line", "image"]
SummaryFormat = Literal[
"overview",
"highlight",
"abstract",
"bullet_points",
"numbered_list",
"table_of_contents",
"outline",
"question_answer",
"action_items",
]
SummaryOutputFormat = Literal["plaintext", "markdown"]
SummaryOutputType = Literal["json", "file"]
TranslateOutputFormat = Literal["plaintext", "markdown"]
OcrLanguage = Literal[
"ChineseSimplified",
"ChineseTraditional",
"Dutch",
"English",
"French",
"German",
"Italian",
"Japanese",
"Korean",
"Portuguese",
"Spanish",
]
ALL_OCR_LANGUAGES: tuple[OcrLanguage, ...] = cast(
tuple[OcrLanguage, ...], get_args(OcrLanguage)
)
PdfRestriction = Literal[
"print_low",
"print_high",
"edit_document_assembly",
"edit_fill_and_sign_form_fields",
"edit_annotations",
"edit_content",
"copy_content",
"accessibility_off",
]
ALL_PDF_RESTRICTIONS: tuple[PdfRestriction, ...] = cast(
tuple[PdfRestriction, ...], get_args(PdfRestriction)
)
PdfPageSize = Literal["letter", "legal", "ledger", "A3", "A4", "A5"] | PdfCustomPageSize
PdfPageOrientation = Literal["portrait", "landscape"]