Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/pypdf/constants.py: 93%
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1"""Various constants, enums, and flags to aid readability."""
3import sys
4from enum import Enum, IntFlag, auto, unique
5from typing import Any
7from ._utils import deprecate_with_replacement
9if sys.version_info >= (3, 11):
10 from enum import StrEnum
11else:
12 class StrEnum(str, Enum):
13 def __str__(self) -> str:
14 return str(self.value)
17class Core:
18 """Keywords that don't quite belong anywhere else."""
20 OUTLINES = "/Outlines"
21 THREADS = "/Threads"
22 PAGE = "/Page"
23 PAGES = "/Pages"
24 CATALOG = "/Catalog"
27class TrailerKeys:
28 SIZE = "/Size"
29 PREV = "/Prev"
30 ROOT = "/Root"
31 ENCRYPT = "/Encrypt"
32 INFO = "/Info"
33 ID = "/ID"
36class CatalogAttributes:
37 """§7.7.2 of the 1.7 and 2.0 references."""
38 TYPE = "/Type" # name, required; must be /Catalog
39 VERSION = "/Version" # name
40 EXTENSIONS = "/Extensions" # dictionary, optional; ISO 32000-1
41 PAGES = "/Pages" # dictionary, required
42 PAGE_LABELS = "/PageLabels" # number tree, optional
43 NAMES = "/Names" # dictionary, optional
44 DESTS = "/Dests" # dictionary, optional
45 VIEWER_PREFERENCES = "/ViewerPreferences" # dictionary, optional
46 PAGE_LAYOUT = "/PageLayout" # name, optional
47 PAGE_MODE = "/PageMode" # name, optional
48 OUTLINES = "/Outlines" # dictionary, optional
49 THREADS = "/Threads" # array, optional
50 OPEN_ACTION = "/OpenAction" # array or dictionary or name, optional
51 AA = "/AA" # dictionary, optional
52 URI = "/URI" # dictionary, optional
53 ACRO_FORM = "/AcroForm" # dictionary, optional
54 METADATA = "/Metadata" # stream, optional
55 STRUCT_TREE_ROOT = "/StructTreeRoot" # dictionary, optional
56 MARK_INFO = "/MarkInfo" # dictionary, optional
57 LANG = "/Lang" # text string, optional
58 SPIDER_INFO = "/SpiderInfo" # dictionary, optional
59 OUTPUT_INTENTS = "/OutputIntents" # array, optional
60 PIECE_INFO = "/PieceInfo" # dictionary, optional
61 OC_PROPERTIES = "/OCProperties" # dictionary, optional
62 PERMS = "/Perms" # dictionary, optional
63 LEGAL = "/Legal" # dictionary, optional
64 REQUIREMENTS = "/Requirements" # array, optional
65 COLLECTION = "/Collection" # dictionary, optional
66 NEEDS_RENDERING = "/NeedsRendering" # boolean, optional
67 DSS = "/DSS" # dictionary, optional
68 AF = "/AF" # array of dictionaries, optional
69 D_PART_ROOT = "/DPartRoot" # dictionary, optional
72class EncryptionDictAttributes:
73 """
74 Additional encryption dictionary entries for the standard security handler.
76 Table 3.19, Page 122.
77 Table 21 of the 2.0 manual.
78 """
80 R = "/R" # number, required; revision of the standard security handler
81 O = "/O" # 32-byte string, required # noqa: E741
82 U = "/U" # 32-byte string, required
83 P = "/P" # integer flag, required; permitted operations
84 ENCRYPT_METADATA = "/EncryptMetadata" # boolean flag, optional
87class UserAccessPermissions(IntFlag):
88 """
89 Table 3.20 User access permissions.
90 Table 22 of the 2.0 manual.
91 """
93 R1 = 1
94 R2 = 2
95 PRINT = 4
96 MODIFY = 8
97 EXTRACT = 16
98 ADD_OR_MODIFY = 32
99 R7 = 64
100 R8 = 128
101 FILL_FORM_FIELDS = 256
102 EXTRACT_TEXT_AND_GRAPHICS = 512
103 ASSEMBLE_DOC = 1024
104 PRINT_TO_REPRESENTATION = 2048
105 R13 = 2**12
106 R14 = 2**13
107 R15 = 2**14
108 R16 = 2**15
109 R17 = 2**16
110 R18 = 2**17
111 R19 = 2**18
112 R20 = 2**19
113 R21 = 2**20
114 R22 = 2**21
115 R23 = 2**22
116 R24 = 2**23
117 R25 = 2**24
118 R26 = 2**25
119 R27 = 2**26
120 R28 = 2**27
121 R29 = 2**28
122 R30 = 2**29
123 R31 = 2**30
124 R32 = 2**31
126 @classmethod
127 def _is_reserved(cls, name: str) -> bool:
128 """Check if the given name corresponds to a reserved flag entry."""
129 return name.startswith("R") and name[1:].isdigit()
131 @classmethod
132 def _is_active(cls, name: str) -> bool:
133 """Check if the given reserved name defaults to 1 = active."""
134 return name not in {"R1", "R2"}
136 def to_dict(self) -> dict[str, bool]:
137 """Convert the given flag value to a corresponding verbose name mapping."""
138 result: dict[str, bool] = {}
139 for name, flag in UserAccessPermissions.__members__.items():
140 if UserAccessPermissions._is_reserved(name):
141 continue
142 result[name.lower()] = (self & flag) == flag
143 return result
145 @classmethod
146 def from_dict(cls, value: dict[str, bool]) -> "UserAccessPermissions":
147 """Convert the verbose name mapping to the corresponding flag value."""
148 value_copy = value.copy()
149 result = cls(0)
150 for name, flag in cls.__members__.items():
151 if cls._is_reserved(name):
152 # Reserved names have a required value. Use it.
153 if cls._is_active(name):
154 result |= flag
155 continue
156 is_active = value_copy.pop(name.lower(), False)
157 if is_active:
158 result |= flag
159 if value_copy:
160 raise ValueError(f"Unknown dictionary keys: {value_copy!r}")
161 return result
163 @classmethod
164 def all(cls) -> "UserAccessPermissions":
165 return cls((2**32 - 1) - cls.R1 - cls.R2)
168class Resources:
169 """
170 Table 3.30 Entries in a resource dictionary.
171 Table 34 in the 2.0 reference.
172 """
174 EXT_G_STATE = "/ExtGState" # dictionary, optional
175 COLOR_SPACE = "/ColorSpace" # dictionary, optional
176 PATTERN = "/Pattern" # dictionary, optional
177 SHADING = "/Shading" # dictionary, optional
178 XOBJECT = "/XObject" # dictionary, optional
179 FONT = "/Font" # dictionary, optional
180 PROC_SET = "/ProcSet" # array, optional
181 PROPERTIES = "/Properties" # dictionary, optional
184class PagesAttributes:
185 """§7.7.3.2 of the 1.7 and 2.0 reference."""
187 TYPE = "/Type" # name, required; must be /Pages
188 PARENT = "/Parent" # dictionary, required; indirect reference to pages object
189 KIDS = "/Kids" # array, required; List of indirect references
190 COUNT = "/Count"
191 # integer, required; the number of leaf nodes (page objects)
192 # that are descendants of this node within the page tree
195class PageAttributes:
196 """§7.7.3.3 of the 1.7 and 2.0 reference."""
198 TYPE = "/Type" # name, required; must be /Page
199 PARENT = "/Parent" # dictionary, required; a pages object
200 LAST_MODIFIED = (
201 "/LastModified" # date, optional; date and time of last modification
202 )
203 RESOURCES = "/Resources" # dictionary, required if there are any
204 MEDIABOX = "/MediaBox" # rectangle, required; rectangle specifying page size
205 CROPBOX = "/CropBox" # rectangle, optional
206 BLEEDBOX = "/BleedBox" # rectangle, optional
207 TRIMBOX = "/TrimBox" # rectangle, optional
208 ARTBOX = "/ArtBox" # rectangle, optional
209 BOX_COLOR_INFO = "/BoxColorInfo" # dictionary, optional
210 CONTENTS = "/Contents" # stream or array, optional
211 ROTATE = "/Rotate" # integer, optional; page rotation in degrees
212 GROUP = "/Group" # dictionary, optional; page group
213 THUMB = "/Thumb" # stream, optional; indirect reference to image of the page
214 B = "/B" # array, optional
215 DUR = "/Dur" # number, optional
216 TRANS = "/Trans" # dictionary, optional
217 ANNOTS = "/Annots" # array, optional; an array of annotations
218 AA = "/AA" # dictionary, optional
219 METADATA = "/Metadata" # stream, optional
220 PIECE_INFO = "/PieceInfo" # dictionary, optional
221 STRUCT_PARENTS = "/StructParents" # integer, optional
222 ID = "/ID" # byte string, optional
223 PZ = "/PZ" # number, optional
224 SEPARATION_INFO = "/SeparationInfo" # dictionary, optional
225 TABS = "/Tabs" # name, optional
226 TEMPLATE_INSTANTIATED = "/TemplateInstantiated" # name, optional
227 PRES_STEPS = "/PresSteps" # dictionary, optional
228 USER_UNIT = "/UserUnit" # number, optional
229 VP = "/VP" # dictionary, optional
230 AF = "/AF" # array of dictionaries, optional
231 OUTPUT_INTENTS = "/OutputIntents" # array, optional
232 D_PART = "/DPart" # dictionary, required, if this page is within the range of a DPart, not permitted otherwise
235class FileSpecificationDictionaryEntries:
236 """Table 3.41 Entries in a file specification dictionary."""
238 Type = "/Type"
239 FS = "/FS" # The name of the file system to be used to interpret this file specification
240 F = "/F" # A file specification string of the form described in §3.10.1
241 UF = "/UF" # A Unicode string of the file as described in §3.10.1
242 DOS = "/DOS"
243 Mac = "/Mac"
244 Unix = "/Unix"
245 ID = "/ID"
246 V = "/V"
247 EF = "/EF" # dictionary, containing a subset of the keys F, UF, DOS, Mac, and Unix
248 RF = "/RF" # dictionary, containing arrays of /EmbeddedFile
249 DESC = "/Desc" # description of the file
250 Cl = "/Cl"
253class StreamAttributes:
254 """
255 Table 4.2.
256 Table 5 in the 2.0 reference.
257 """
259 LENGTH = "/Length" # integer, required
260 FILTER = "/Filter" # name or array of names, optional
261 DECODE_PARMS = "/DecodeParms" # variable, optional; /DecodeParams is wrong
264@unique
265class FilterTypes(StrEnum):
266 """§7.4 of the 1.7 and 2.0 references."""
268 ASCII_HEX_DECODE = "/ASCIIHexDecode" # abbreviation: AHx
269 ASCII_85_DECODE = "/ASCII85Decode" # abbreviation: A85
270 LZW_DECODE = "/LZWDecode" # abbreviation: LZW
271 FLATE_DECODE = "/FlateDecode" # abbreviation: Fl
272 RUN_LENGTH_DECODE = "/RunLengthDecode" # abbreviation: RL
273 CCITT_FAX_DECODE = "/CCITTFaxDecode" # abbreviation: CCF
274 DCT_DECODE = "/DCTDecode" # abbreviation: DCT
275 JPX_DECODE = "/JPXDecode"
276 JBIG2_DECODE = "/JBIG2Decode"
279class FilterTypeAbbreviations:
280 """§8.9.7 of the 1.7 and 2.0 references."""
282 AHx = "/AHx"
283 A85 = "/A85"
284 LZW = "/LZW"
285 FL = "/Fl"
286 RL = "/RL"
287 CCF = "/CCF"
288 DCT = "/DCT"
291class LzwFilterParameters:
292 """
293 Table 4.4.
294 Table 8 in the 2.0 reference.
295 """
297 PREDICTOR = "/Predictor" # integer
298 COLORS = "/Colors" # integer
299 BITS_PER_COMPONENT = "/BitsPerComponent" # integer
300 COLUMNS = "/Columns" # integer
301 EARLY_CHANGE = "/EarlyChange" # integer
304class CcittFaxDecodeParameters:
305 """
306 Table 4.5.
307 Table 11 in the 2.0 reference.
308 """
310 K = "/K" # integer
311 END_OF_LINE = "/EndOfLine" # boolean
312 ENCODED_BYTE_ALIGN = "/EncodedByteAlign" # boolean
313 COLUMNS = "/Columns" # integer
314 ROWS = "/Rows" # integer
315 END_OF_BLOCK = "/EndOfBlock" # boolean
316 BLACK_IS_1 = "/BlackIs1" # boolean
317 DAMAGED_ROWS_BEFORE_ERROR = "/DamagedRowsBeforeError" # integer
320class ImageAttributes:
321 """§11.6.5 of the 1.7 and 2.0 references."""
323 TYPE = "/Type" # name, required; must be /XObject
324 SUBTYPE = "/Subtype" # name, required; must be /Image
325 NAME = "/Name" # name, required
326 WIDTH = "/Width" # integer, required
327 HEIGHT = "/Height" # integer, required
328 BITS_PER_COMPONENT = "/BitsPerComponent" # integer, required
329 COLOR_SPACE = "/ColorSpace" # name, required
330 DECODE = "/Decode" # array, optional
331 INTENT = "/Intent" # string, optional
332 INTERPOLATE = "/Interpolate" # boolean, optional
333 IMAGE_MASK = "/ImageMask" # boolean, optional
334 MASK = "/Mask" # 1-bit image mask stream
335 S_MASK = "/SMask" # dictionary or name, optional
338class ColorSpaces:
339 DEVICE_RGB = "/DeviceRGB"
340 DEVICE_CMYK = "/DeviceCMYK"
341 DEVICE_GRAY = "/DeviceGray"
344class TypArguments:
345 """Table 8.2 of the PDF 1.7 reference."""
347 LEFT = "/Left"
348 RIGHT = "/Right"
349 BOTTOM = "/Bottom"
350 TOP = "/Top"
353class TypFitArguments:
354 """Table 8.2 of the PDF 1.7 reference."""
356 XYZ = "/XYZ"
357 FIT = "/Fit"
358 FIT_H = "/FitH"
359 FIT_V = "/FitV"
360 FIT_R = "/FitR"
361 FIT_B = "/FitB"
362 FIT_BH = "/FitBH"
363 FIT_BV = "/FitBV"
366class GoToActionArguments:
367 S = "/S" # name, required: type of action
368 D = "/D" # name, byte string, or array, required: destination to jump to
369 SD = "/SD" # array, optional: structure destination to jump to
372class AnnotationDictionaryAttributes:
373 """Table 8.15 Entries common to all annotation dictionaries."""
375 Type = "/Type"
376 Subtype = "/Subtype"
377 Rect = "/Rect"
378 Contents = "/Contents"
379 P = "/P"
380 NM = "/NM"
381 M = "/M"
382 F = "/F"
383 AP = "/AP"
384 AS = "/AS"
385 DA = "/DA"
386 Border = "/Border"
387 C = "/C"
388 StructParent = "/StructParent"
389 OC = "/OC"
392class InteractiveFormDictEntries:
393 Fields = "/Fields"
394 NeedAppearances = "/NeedAppearances"
395 SigFlags = "/SigFlags"
396 CO = "/CO"
397 DR = "/DR"
398 DA = "/DA"
399 Q = "/Q"
400 XFA = "/XFA"
403class FieldDictionaryAttributes:
404 """
405 Entries common to all field dictionaries (Table 8.69 PDF 1.7 reference)
406 (*very partially documented here*).
408 FFBits provides the constants used for `/Ff` from Table 8.70/8.75/8.77/8.79
409 """
411 FT = "/FT" # name, required for terminal fields
412 Parent = "/Parent" # dictionary, required for children
413 Kids = "/Kids" # array, sometimes required
414 T = "/T" # text string, optional
415 TU = "/TU" # text string, optional
416 TM = "/TM" # text string, optional
417 Ff = "/Ff" # integer, optional
418 V = "/V" # text string or array, optional
419 DV = "/DV" # text string, optional
420 AA = "/AA" # dictionary, optional
421 Opt = "/Opt" # array, optional
423 class FfBits(IntFlag):
424 """
425 Ease building /Ff flags
426 Some entries may be specific to:
428 * Text (Tx) (Table 8.75 PDF 1.7 reference)
429 * Buttons (Btn) (Table 8.77 PDF 1.7 reference)
430 * Choice (Ch) (Table 8.79 PDF 1.7 reference)
431 """
433 ReadOnly = 1 << 0
434 """common to Tx/Btn/Ch in Table 8.70"""
435 Required = 1 << 1
436 """common to Tx/Btn/Ch in Table 8.70"""
437 NoExport = 1 << 2
438 """common to Tx/Btn/Ch in Table 8.70"""
440 Multiline = 1 << 12
441 """Tx"""
442 Password = 1 << 13
443 """Tx"""
445 NoToggleToOff = 1 << 14
446 """Btn"""
447 Radio = 1 << 15
448 """Btn"""
449 Pushbutton = 1 << 16
450 """Btn"""
452 Combo = 1 << 17
453 """Ch"""
454 Edit = 1 << 18
455 """Ch"""
456 Sort = 1 << 19
457 """Ch"""
459 FileSelect = 1 << 20
460 """Tx"""
462 MultiSelect = 1 << 21
463 """Tx"""
465 DoNotSpellCheck = 1 << 22
466 """Tx/Ch"""
467 DoNotScroll = 1 << 23
468 """Tx"""
469 Comb = 1 << 24
470 """Tx"""
472 RadiosInUnison = 1 << 25
473 """Btn"""
475 RichText = 1 << 25
476 """Tx"""
478 CommitOnSelChange = 1 << 26
479 """Ch"""
481 @classmethod
482 def attributes(cls) -> tuple[str, ...]:
483 """
484 Get a tuple of all the attributes present in a Field Dictionary.
486 This method returns a tuple of all the attribute constants defined in
487 the FieldDictionaryAttributes class. These attributes correspond to the
488 entries that are common to all field dictionaries as specified in the
489 PDF 1.7 reference.
491 Returns:
492 A tuple containing all the attribute constants.
494 """
495 return (
496 cls.TM,
497 cls.T,
498 cls.FT,
499 cls.Parent,
500 cls.TU,
501 cls.Ff,
502 cls.V,
503 cls.DV,
504 cls.Kids,
505 cls.AA,
506 )
508 @classmethod
509 def attributes_dict(cls) -> dict[str, str]:
510 """
511 Get a dictionary of attribute keys and their human-readable names.
513 This method returns a dictionary where the keys are the attribute
514 constants defined in the FieldDictionaryAttributes class and the values
515 are their corresponding human-readable names. These attributes
516 correspond to the entries that are common to all field dictionaries as
517 specified in the PDF 1.7 reference.
519 Returns:
520 A dictionary containing attribute keys and their names.
522 """
523 return {
524 cls.FT: "Field Type",
525 cls.Parent: "Parent",
526 cls.T: "Field Name",
527 cls.TU: "Alternate Field Name",
528 cls.TM: "Mapping Name",
529 cls.Ff: "Field Flags",
530 cls.V: "Value",
531 cls.DV: "Default Value",
532 }
535class CheckboxRadioButtonAttributes:
536 """Table 8.76 Field flags common to all field types."""
538 Opt = "/Opt" # Options, Optional
540 @classmethod
541 def attributes(cls) -> tuple[str, ...]:
542 """
543 Get a tuple of all the attributes present in a Field Dictionary.
545 This method returns a tuple of all the attribute constants defined in
546 the CheckboxRadioButtonAttributes class. These attributes correspond to
547 the entries that are common to all field dictionaries as specified in
548 the PDF 1.7 reference.
550 Returns:
551 A tuple containing all the attribute constants.
553 """
554 return (cls.Opt,)
556 @classmethod
557 def attributes_dict(cls) -> dict[str, str]:
558 """
559 Get a dictionary of attribute keys and their human-readable names.
561 This method returns a dictionary where the keys are the attribute
562 constants defined in the CheckboxRadioButtonAttributes class and the
563 values are their corresponding human-readable names. These attributes
564 correspond to the entries that are common to all field dictionaries as
565 specified in the PDF 1.7 reference.
567 Returns:
568 A dictionary containing attribute keys and their names.
570 """
571 return {
572 cls.Opt: "Options",
573 }
576class FieldFlag(IntFlag):
577 """Table 8.70 Field flags common to all field types."""
579 READ_ONLY = 1
580 REQUIRED = 2
581 NO_EXPORT = 4
584class DocumentInformationAttributes:
585 """Table 10.2 Entries in the document information dictionary."""
587 TITLE = "/Title" # text string, optional
588 AUTHOR = "/Author" # text string, optional
589 SUBJECT = "/Subject" # text string, optional
590 KEYWORDS = "/Keywords" # text string, optional
591 CREATOR = "/Creator" # text string, optional
592 PRODUCER = "/Producer" # text string, optional
593 CREATION_DATE = "/CreationDate" # date, optional
594 MOD_DATE = "/ModDate" # date, optional
595 TRAPPED = "/Trapped" # name, optional
598class PageLayouts:
599 """
600 Page 84, PDF 1.4 reference.
601 Page 115, PDF 2.0 reference.
602 """
604 SINGLE_PAGE = "/SinglePage"
605 ONE_COLUMN = "/OneColumn"
606 TWO_COLUMN_LEFT = "/TwoColumnLeft"
607 TWO_COLUMN_RIGHT = "/TwoColumnRight"
608 TWO_PAGE_LEFT = "/TwoPageLeft" # (PDF 1.5)
609 TWO_PAGE_RIGHT = "/TwoPageRight" # (PDF 1.5)
612class GraphicsStateParameters:
613 """Table 58 – Entries in a Graphics State Parameter Dictionary"""
615 TYPE = "/Type" # name, optional
616 LW = "/LW" # number, optional
617 LC = "/LC" # integer, optional
618 LJ = "/LJ" # integer, optional
619 ML = "/ML" # number, optional
620 D = "/D" # array, optional
621 RI = "/RI" # name, optional
622 OP = "/OP"
623 op = "/op"
624 OPM = "/OPM"
625 FONT = "/Font" # array, optional
626 BG = "/BG"
627 BG2 = "/BG2"
628 UCR = "/UCR"
629 UCR2 = "/UCR2"
630 TR = "/TR"
631 TR2 = "/TR2"
632 HT = "/HT"
633 FL = "/FL"
634 SM = "/SM"
635 SA = "/SA"
636 BM = "/BM"
637 S_MASK = "/SMask" # dictionary or name, optional
638 CA = "/CA"
639 ca = "/ca"
640 AIS = "/AIS"
641 TK = "/TK"
644class _CatalogDictionaryMeta(type):
645 def __getattribute__(cls, name: str) -> Any:
646 value = super().__getattribute__(name)
648 if not name.startswith("__"):
649 deprecate_with_replacement("CatalogDictionary", "CatalogAttributes", "7.0.0")
650 return value
653class CatalogDictionary(CatalogAttributes, metaclass=_CatalogDictionaryMeta):
654 def __init__(self) -> None:
655 deprecate_with_replacement("CatalogDictionary", "CatalogAttributes", "7.0.0")
658class OutlineFontFlag(IntFlag):
659 """A class used as an enumerable flag for formatting an outline font."""
661 italic = 1
662 bold = 2
665class PageLabelStyle(StrEnum):
666 """
667 Table 8.10 in the 1.7 reference.
668 Table 161 in the 2.0 reference.
669 """
671 DECIMAL = "/D" # Decimal Arabic numerals
672 UPPERCASE_ROMAN = "/R" # Uppercase Roman numerals
673 LOWERCASE_ROMAN = "/r" # Lowercase Roman numerals
674 UPPERCASE_LETTER = "/A" # Uppercase letters
675 LOWERCASE_LETTER = "/a" # Lowercase letters
678class AnnotationFlag(IntFlag):
679 """See §12.5.3 "Annotation Flags"."""
681 INVISIBLE = 1
682 HIDDEN = 2
683 PRINT = 4
684 NO_ZOOM = 8
685 NO_ROTATE = 16
686 NO_VIEW = 32
687 READ_ONLY = 64
688 LOCKED = 128
689 TOGGLE_NO_VIEW = 256
690 LOCKED_CONTENTS = 512
693PDF_KEYS = (
694 AnnotationDictionaryAttributes,
695 CatalogAttributes,
696 CatalogDictionary,
697 CcittFaxDecodeParameters,
698 CheckboxRadioButtonAttributes,
699 ColorSpaces,
700 Core,
701 DocumentInformationAttributes,
702 EncryptionDictAttributes,
703 FieldDictionaryAttributes,
704 FileSpecificationDictionaryEntries,
705 FilterTypeAbbreviations,
706 FilterTypes,
707 GoToActionArguments,
708 GraphicsStateParameters,
709 ImageAttributes,
710 InteractiveFormDictEntries,
711 LzwFilterParameters,
712 PageAttributes,
713 PageLayouts,
714 PagesAttributes,
715 Resources,
716 StreamAttributes,
717 TrailerKeys,
718 TypArguments,
719 TypFitArguments,
720)
723class ImageType(IntFlag):
724 NONE = 0
725 XOBJECT_IMAGES = auto()
726 INLINE_IMAGES = auto()
727 DRAWING_IMAGES = auto()
728 ALL = XOBJECT_IMAGES | INLINE_IMAGES | DRAWING_IMAGES
729 IMAGES = ALL # for consistency with ObjectDeletionFlag
732_INLINE_IMAGE_VALUE_MAPPING = {
733 "/G": "/DeviceGray",
734 "/RGB": "/DeviceRGB",
735 "/CMYK": "/DeviceCMYK",
736 "/I": "/Indexed",
737 "/AHx": "/ASCIIHexDecode",
738 "/A85": "/ASCII85Decode",
739 "/LZW": "/LZWDecode",
740 "/Fl": "/FlateDecode",
741 "/RL": "/RunLengthDecode",
742 "/CCF": "/CCITTFaxDecode",
743 "/DCT": "/DCTDecode",
744 "/DeviceGray": "/DeviceGray",
745 "/DeviceRGB": "/DeviceRGB",
746 "/DeviceCMYK": "/DeviceCMYK",
747 "/Indexed": "/Indexed",
748 "/ASCIIHexDecode": "/ASCIIHexDecode",
749 "/ASCII85Decode": "/ASCII85Decode",
750 "/LZWDecode": "/LZWDecode",
751 "/FlateDecode": "/FlateDecode",
752 "/RunLengthDecode": "/RunLengthDecode",
753 "/CCITTFaxDecode": "/CCITTFaxDecode",
754 "/DCTDecode": "/DCTDecode",
755 "/RelativeColorimetric": "/RelativeColorimetric",
756}
758_INLINE_IMAGE_KEY_MAPPING = {
759 "/BPC": "/BitsPerComponent",
760 "/CS": "/ColorSpace",
761 "/D": "/Decode",
762 "/DP": "/DecodeParms",
763 "/F": "/Filter",
764 "/H": "/Height",
765 "/W": "/Width",
766 "/I": "/Interpolate",
767 "/Intent": "/Intent",
768 "/IM": "/ImageMask",
769 "/BitsPerComponent": "/BitsPerComponent",
770 "/ColorSpace": "/ColorSpace",
771 "/Decode": "/Decode",
772 "/DecodeParms": "/DecodeParms",
773 "/Filter": "/Filter",
774 "/Height": "/Height",
775 "/Width": "/Width",
776 "/Interpolate": "/Interpolate",
777 "/ImageMask": "/ImageMask",
778}
781class AFRelationship:
782 """
783 Associated file relationship types, defining the relationship between
784 the PDF component and the associated file.
786 Defined in table 43 of the PDF 2.0 reference.
787 """
789 SOURCE = "/Source" # Original content source
790 DATA = "/Data" # Base data for visual presentation
791 ALTERNATIVE = "/Alternative" # Alternative content representation
792 SUPPLEMENT = "/Supplement" # Supplemental representation of original source/data
793 ENCRYPTED_PAYLOAD = "/EncryptedPayload" # Encrypted payload document
794 FORM_DATA = "/FormData" # Data associated with AcroForm of this PDF
795 SCHEMA = "/Schema" # Schema definition for associated object
796 UNSPECIFIED = "/Unspecified" # Not known or cannot be described with values
799class BorderStyles:
800 """
801 A class defining border styles used in PDF documents.
803 Defined in table 168 of the PDF 2.0 reference.
804 """
806 BEVELED = "/B"
807 DASHED = "/D"
808 INSET = "/I"
809 SOLID = "/S"
810 UNDERLINED = "/U"
813class FontFlags(IntFlag):
814 """
815 A class defining font flags in PDF document font descriptor resources.
817 Defined in table 121 of the PDF 2.0 reference.
818 """
820 FIXED_PITCH = 1 << 0
821 SERIF = 1 << 1
822 SYMBOLIC = 1 << 2
823 SCRIPT = 1 << 3
824 NONSYMBOLIC = 1 << 5
825 ITALIC = 1 << 6
826 ALL_CAP = 1 << 16
827 SMALL_CAP = 1 << 17
828 FORCE_BOLD = 1 << 18