Skip to content

Commit a3e90e5

Browse files
types: Add PdfSignaturePoint and enhance API docstrings
- Introduced `PdfSignaturePoint` to the public API for handling signature placement coordinates in PDF documents. - Enhanced docstrings for `PdfSignatureLocation`, `PdfSignatureDisplay`, `PdfNewSignatureConfiguration`, and related types with detailed attribute descriptions for improved clarity. - Updated `mkdocs.yml` to include the `autorefs` plugin for better cross-referencing in documentation. Assisted-by: Codex
1 parent e207714 commit a3e90e5

3 files changed

Lines changed: 81 additions & 3 deletions

File tree

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ theme:
1212

1313
plugins:
1414
- search
15+
- autorefs
1516
- mkdocstrings:
1617
handlers:
1718
python:

src/pdfrest/types/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
PdfSignatureCredentials,
4141
PdfSignatureDisplay,
4242
PdfSignatureLocation,
43+
PdfSignaturePoint,
4344
PdfTextColor,
4445
PdfXType,
4546
PngColorModel,
@@ -92,6 +93,7 @@
9293
"PdfSignatureCredentials",
9394
"PdfSignatureDisplay",
9495
"PdfSignatureLocation",
96+
"PdfSignaturePoint",
9597
"PdfTextColor",
9698
"PdfXType",
9799
"PngColorModel",

src/pdfrest/types/public.py

Lines changed: 78 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
"PdfSignatureCredentials",
5353
"PdfSignatureDisplay",
5454
"PdfSignatureLocation",
55+
"PdfSignaturePoint",
5556
"PdfTextColor",
5657
"PdfXType",
5758
"PngColorModel",
@@ -64,8 +65,9 @@
6465
"WatermarkVerticalAlignment",
6566
)
6667

67-
#: Supported query keys for :meth:`pdfrest.PdfRestClient.query_pdf_info` and
68-
#: :meth:`pdfrest.AsyncPdfRestClient.query_pdf_info`.
68+
#: Supported query keys for
69+
#: [PdfRestClient.query_pdf_info][pdfrest.PdfRestClient.query_pdf_info] and
70+
#: [AsyncPdfRestClient.query_pdf_info][pdfrest.AsyncPdfRestClient.query_pdf_info].
6971
PdfInfoQuery = Literal[
7072
"tagged",
7173
"image_only",
@@ -104,7 +106,7 @@
104106
tuple[PdfInfoQuery, ...], get_args(PdfInfoQuery)
105107
)
106108

107-
#: Redaction match mode used by :class:`PdfRedactionInstruction`.
109+
#: Redaction match mode used by [PdfRedactionInstruction][].
108110
PdfRedactionType = Literal["literal", "regex", "preset"]
109111

110112
#: Built-in redaction presets accepted by pdfRest.
@@ -169,6 +171,13 @@ class PdfAddTextObject(TypedDict, total=False):
169171

170172

171173
class PdfCustomPageSize(TypedDict):
174+
"""Custom page dimensions for page-size aware conversions.
175+
176+
Attributes:
177+
custom_height: Page height in points.
178+
custom_width: Page width in points.
179+
"""
180+
172181
custom_height: Required[float]
173182
custom_width: Required[float]
174183

@@ -196,17 +205,43 @@ class PdfMergeSource(TypedDict, total=False):
196205

197206

198207
class PdfSignaturePoint(TypedDict):
208+
"""Coordinate point used for signature placement in PDF points.
209+
210+
Attributes:
211+
x: Horizontal position in points.
212+
y: Vertical position in points.
213+
"""
214+
199215
x: float
200216
y: float
201217

202218

203219
class PdfSignatureLocation(TypedDict):
220+
"""Bounding box and page where a signature field should be rendered.
221+
222+
Attributes:
223+
bottom_left: Bottom-left [PdfSignaturePoint][pdfrest.types.PdfSignaturePoint] of the signature rectangle.
224+
top_right: Top-right [PdfSignaturePoint][pdfrest.types.PdfSignaturePoint] of the signature rectangle.
225+
page: One-based page index or ``"all"``.
226+
"""
227+
204228
bottom_left: Required[PdfSignaturePoint]
205229
top_right: Required[PdfSignaturePoint]
206230
page: Required[str | int]
207231

208232

209233
class PdfSignatureDisplay(TypedDict, total=False):
234+
"""Optional text fields included in visible signature appearances.
235+
236+
Attributes:
237+
include_distinguished_name: Whether to include signer DN text.
238+
include_datetime: Whether to include signing date/time text.
239+
contact: Contact text shown in the visible signature.
240+
location: Location text shown in the visible signature.
241+
name: Signer name text shown in the visible signature.
242+
reason: Signing reason text shown in the visible signature.
243+
"""
244+
210245
include_distinguished_name: bool
211246
include_datetime: bool
212247
contact: str
@@ -216,6 +251,16 @@ class PdfSignatureDisplay(TypedDict, total=False):
216251

217252

218253
class PdfNewSignatureConfiguration(TypedDict, total=False):
254+
"""Configuration for creating and signing a new signature field.
255+
256+
Attributes:
257+
type: Must be ``"new"``.
258+
location: Placement rectangle and page as [PdfSignatureLocation][pdfrest.types.PdfSignatureLocation].
259+
name: Optional name for the signature field.
260+
logo_opacity: Optional logo opacity in the range ``(0, 1]``.
261+
display: Optional visible-signature settings as [PdfSignatureDisplay][pdfrest.types.PdfSignatureDisplay].
262+
"""
263+
219264
type: Required[Literal["new"]]
220265
location: Required[PdfSignatureLocation]
221266
name: str
@@ -224,28 +269,58 @@ class PdfNewSignatureConfiguration(TypedDict, total=False):
224269

225270

226271
class PdfExistingSignatureConfiguration(TypedDict, total=False):
272+
"""Configuration for signing an existing signature field.
273+
274+
Attributes:
275+
type: Must be ``"existing"``.
276+
location: Optional placement override as [PdfSignatureLocation][pdfrest.types.PdfSignatureLocation].
277+
name: Optional existing signature field name.
278+
logo_opacity: Optional logo opacity in the range ``(0, 1]``.
279+
display: Optional visible-signature settings as [PdfSignatureDisplay][pdfrest.types.PdfSignatureDisplay].
280+
"""
281+
227282
type: Required[Literal["existing"]]
228283
location: PdfSignatureLocation
229284
name: str
230285
logo_opacity: float
231286
display: PdfSignatureDisplay
232287

233288

289+
#: Signature placement configuration accepted by
290+
#: [PdfRestClient.sign_pdf][pdfrest.PdfRestClient.sign_pdf] and
291+
#: [AsyncPdfRestClient.sign_pdf][pdfrest.AsyncPdfRestClient.sign_pdf].
234292
PdfSignatureConfiguration = (
235293
PdfNewSignatureConfiguration | PdfExistingSignatureConfiguration
236294
)
237295

238296

239297
class PdfPfxCredentials(TypedDict):
298+
"""Credentials bundle using a PFX/P12 file plus passphrase file.
299+
300+
Attributes:
301+
pfx: Uploaded credentials archive as a [PdfRestFile][pdfrest.models.PdfRestFile].
302+
passphrase: Uploaded text passphrase as a [PdfRestFile][pdfrest.models.PdfRestFile].
303+
"""
304+
240305
pfx: Required[PdfRestFile]
241306
passphrase: Required[PdfRestFile]
242307

243308

244309
class PdfPemCredentials(TypedDict):
310+
"""Credentials bundle using certificate and private key uploads.
311+
312+
Attributes:
313+
certificate: Uploaded certificate as a [PdfRestFile][pdfrest.models.PdfRestFile].
314+
private_key: Uploaded private key as a [PdfRestFile][pdfrest.models.PdfRestFile].
315+
"""
316+
245317
certificate: Required[PdfRestFile]
246318
private_key: Required[PdfRestFile]
247319

248320

321+
#: Credentials accepted by
322+
#: [PdfRestClient.sign_pdf][pdfrest.PdfRestClient.sign_pdf] and
323+
#: [AsyncPdfRestClient.sign_pdf][pdfrest.AsyncPdfRestClient.sign_pdf].
249324
PdfSignatureCredentials = PdfPfxCredentials | PdfPemCredentials
250325

251326
#: PDF/A conformance targets accepted by ``convert_to_pdfa``.

0 commit comments

Comments
 (0)