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
|
"""Helpers for working with PDF types."""
import sys
from typing import List, Union
if sys.version_info[:2] >= (3, 8):
# Python 3.8+: https://peps.python.org/pep-0586
from typing import Literal
else:
from typing_extensions import Literal
if sys.version_info[:2] >= (3, 10):
# Python 3.10+: https://www.python.org/dev/peps/pep-0484
from typing import TypeAlias
else:
from typing_extensions import TypeAlias
from .generic._base import NameObject, NullObject, NumberObject
from .generic._data_structures import ArrayObject, Destination
from .generic._outline import OutlineItem
BorderArrayType: TypeAlias = List[Union[NameObject, NumberObject, ArrayObject]]
OutlineItemType: TypeAlias = Union[OutlineItem, Destination]
FitType: TypeAlias = Literal[
"/XYZ", "/Fit", "/FitH", "/FitV", "/FitR", "/FitB", "/FitBH", "/FitBV"
]
# Those go with the FitType: They specify values for the fit
ZoomArgType: TypeAlias = Union[NumberObject, NullObject, float]
ZoomArgsType: TypeAlias = List[ZoomArgType]
# Recursive types like the following are not yet supported by mypy:
# OutlineType = List[Union[Destination, "OutlineType"]]
# See https://github.com/python/mypy/issues/731
# Hence use this for the moment:
OutlineType = List[Union[Destination, List[Union[Destination, List[Destination]]]]]
LayoutType: TypeAlias = Literal[
"/NoLayout",
"/SinglePage",
"/OneColumn",
"/TwoColumnLeft",
"/TwoColumnRight",
"/TwoPageLeft",
"/TwoPageRight",
]
PagemodeType: TypeAlias = Literal[
"/UseNone",
"/UseOutlines",
"/UseThumbs",
"/FullScreen",
"/UseOC",
"/UseAttachments",
]
AnnotationSubtype: TypeAlias = Literal[
"/Text",
"/Link",
"/FreeText",
"/Line",
"/Square",
"/Circle",
"/Polygon",
"/PolyLine",
"/Highlight",
"/Underline",
"/Squiggly",
"/StrikeOut",
"/Caret",
"/Stamp",
"/Ink",
"/Popup",
"/FileAttachment",
"/Sound",
"/Movie",
"/Screen",
"/Widget",
"/PrinterMark",
"/TrapNet",
"/Watermark",
"/3D",
"/Redact",
"/Projection",
"/RichMedia",
]
|