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 BROTLI_DECODE = "/BrotliDecode" # abbreviation: Br, PDF 2.0
277 JBIG2_DECODE = "/JBIG2Decode"
280class FilterTypeAbbreviations:
281 """§8.9.7 of the 1.7 and 2.0 references."""
283 AHx = "/AHx"
284 A85 = "/A85"
285 LZW = "/LZW"
286 FL = "/Fl"
287 RL = "/RL"
288 CCF = "/CCF"
289 DCT = "/DCT"
292class LzwFilterParameters:
293 """
294 Table 4.4.
295 Table 8 in the 2.0 reference.
296 """
298 PREDICTOR = "/Predictor" # integer
299 COLORS = "/Colors" # integer
300 BITS_PER_COMPONENT = "/BitsPerComponent" # integer
301 COLUMNS = "/Columns" # integer
302 EARLY_CHANGE = "/EarlyChange" # integer
305class CcittFaxDecodeParameters:
306 """
307 Table 4.5.
308 Table 11 in the 2.0 reference.
309 """
311 K = "/K" # integer
312 END_OF_LINE = "/EndOfLine" # boolean
313 ENCODED_BYTE_ALIGN = "/EncodedByteAlign" # boolean
314 COLUMNS = "/Columns" # integer
315 ROWS = "/Rows" # integer
316 END_OF_BLOCK = "/EndOfBlock" # boolean
317 BLACK_IS_1 = "/BlackIs1" # boolean
318 DAMAGED_ROWS_BEFORE_ERROR = "/DamagedRowsBeforeError" # integer
321class ImageAttributes:
322 """§11.6.5 of the 1.7 and 2.0 references."""
324 TYPE = "/Type" # name, required; must be /XObject
325 SUBTYPE = "/Subtype" # name, required; must be /Image
326 NAME = "/Name" # name, required
327 WIDTH = "/Width" # integer, required
328 HEIGHT = "/Height" # integer, required
329 BITS_PER_COMPONENT = "/BitsPerComponent" # integer, required
330 COLOR_SPACE = "/ColorSpace" # name, required
331 DECODE = "/Decode" # array, optional
332 INTENT = "/Intent" # string, optional
333 INTERPOLATE = "/Interpolate" # boolean, optional
334 IMAGE_MASK = "/ImageMask" # boolean, optional
335 MASK = "/Mask" # 1-bit image mask stream
336 S_MASK = "/SMask" # dictionary or name, optional
339class ColorSpaces:
340 DEVICE_RGB = "/DeviceRGB"
341 DEVICE_CMYK = "/DeviceCMYK"
342 DEVICE_GRAY = "/DeviceGray"
345class TypArguments:
346 """Table 8.2 of the PDF 1.7 reference."""
348 LEFT = "/Left"
349 RIGHT = "/Right"
350 BOTTOM = "/Bottom"
351 TOP = "/Top"
354class TypFitArguments:
355 """Table 8.2 of the PDF 1.7 reference."""
357 XYZ = "/XYZ"
358 FIT = "/Fit"
359 FIT_H = "/FitH"
360 FIT_V = "/FitV"
361 FIT_R = "/FitR"
362 FIT_B = "/FitB"
363 FIT_BH = "/FitBH"
364 FIT_BV = "/FitBV"
367class GoToActionArguments:
368 S = "/S" # name, required: type of action
369 D = "/D" # name, byte string, or array, required: destination to jump to
370 SD = "/SD" # array, optional: structure destination to jump to
373class AnnotationDictionaryAttributes:
374 """Table 8.15 Entries common to all annotation dictionaries."""
376 Type = "/Type"
377 Subtype = "/Subtype"
378 Rect = "/Rect"
379 Contents = "/Contents"
380 P = "/P"
381 NM = "/NM"
382 M = "/M"
383 F = "/F"
384 AP = "/AP"
385 AS = "/AS"
386 DA = "/DA"
387 Border = "/Border"
388 C = "/C"
389 StructParent = "/StructParent"
390 OC = "/OC"
393class InteractiveFormDictEntries:
394 Fields = "/Fields"
395 NeedAppearances = "/NeedAppearances"
396 SigFlags = "/SigFlags"
397 CO = "/CO"
398 DR = "/DR"
399 DA = "/DA"
400 Q = "/Q"
401 XFA = "/XFA"
404class FieldDictionaryAttributes:
405 """
406 Entries common to all field dictionaries (Table 8.69 PDF 1.7 reference)
407 (*very partially documented here*).
409 FFBits provides the constants used for `/Ff` from Table 8.70/8.75/8.77/8.79
410 """
412 FT = "/FT" # name, required for terminal fields
413 Parent = "/Parent" # dictionary, required for children
414 Kids = "/Kids" # array, sometimes required
415 T = "/T" # text string, optional
416 TU = "/TU" # text string, optional
417 TM = "/TM" # text string, optional
418 Ff = "/Ff" # integer, optional
419 V = "/V" # text string or array, optional
420 DV = "/DV" # text string, optional
421 AA = "/AA" # dictionary, optional
422 Opt = "/Opt" # array, optional
424 class FfBits(IntFlag):
425 """
426 Ease building /Ff flags
427 Some entries may be specific to:
429 * Text (Tx) (Table 8.75 PDF 1.7 reference)
430 * Buttons (Btn) (Table 8.77 PDF 1.7 reference)
431 * Choice (Ch) (Table 8.79 PDF 1.7 reference)
432 """
434 ReadOnly = 1 << 0
435 """common to Tx/Btn/Ch in Table 8.70"""
436 Required = 1 << 1
437 """common to Tx/Btn/Ch in Table 8.70"""
438 NoExport = 1 << 2
439 """common to Tx/Btn/Ch in Table 8.70"""
441 Multiline = 1 << 12
442 """Tx"""
443 Password = 1 << 13
444 """Tx"""
446 NoToggleToOff = 1 << 14
447 """Btn"""
448 Radio = 1 << 15
449 """Btn"""
450 Pushbutton = 1 << 16
451 """Btn"""
453 Combo = 1 << 17
454 """Ch"""
455 Edit = 1 << 18
456 """Ch"""
457 Sort = 1 << 19
458 """Ch"""
460 FileSelect = 1 << 20
461 """Tx"""
463 MultiSelect = 1 << 21
464 """Tx"""
466 DoNotSpellCheck = 1 << 22
467 """Tx/Ch"""
468 DoNotScroll = 1 << 23
469 """Tx"""
470 Comb = 1 << 24
471 """Tx"""
473 RadiosInUnison = 1 << 25
474 """Btn"""
476 RichText = 1 << 25
477 """Tx"""
479 CommitOnSelChange = 1 << 26
480 """Ch"""
482 @classmethod
483 def attributes(cls) -> tuple[str, ...]:
484 """
485 Get a tuple of all the attributes present in a Field Dictionary.
487 This method returns a tuple of all the attribute constants defined in
488 the FieldDictionaryAttributes class. These attributes correspond to the
489 entries that are common to all field dictionaries as specified in the
490 PDF 1.7 reference.
492 Returns:
493 A tuple containing all the attribute constants.
495 """
496 return (
497 cls.TM,
498 cls.T,
499 cls.FT,
500 cls.Parent,
501 cls.TU,
502 cls.Ff,
503 cls.V,
504 cls.DV,
505 cls.Kids,
506 cls.AA,
507 )
509 @classmethod
510 def attributes_dict(cls) -> dict[str, str]:
511 """
512 Get a dictionary of attribute keys and their human-readable names.
514 This method returns a dictionary where the keys are the attribute
515 constants defined in the FieldDictionaryAttributes class and the values
516 are their corresponding human-readable names. These attributes
517 correspond to the entries that are common to all field dictionaries as
518 specified in the PDF 1.7 reference.
520 Returns:
521 A dictionary containing attribute keys and their names.
523 """
524 return {
525 cls.FT: "Field Type",
526 cls.Parent: "Parent",
527 cls.T: "Field Name",
528 cls.TU: "Alternate Field Name",
529 cls.TM: "Mapping Name",
530 cls.Ff: "Field Flags",
531 cls.V: "Value",
532 cls.DV: "Default Value",
533 }
536class CheckboxRadioButtonAttributes:
537 """Table 8.76 Field flags common to all field types."""
539 Opt = "/Opt" # Options, Optional
541 @classmethod
542 def attributes(cls) -> tuple[str, ...]:
543 """
544 Get a tuple of all the attributes present in a Field Dictionary.
546 This method returns a tuple of all the attribute constants defined in
547 the CheckboxRadioButtonAttributes class. These attributes correspond to
548 the entries that are common to all field dictionaries as specified in
549 the PDF 1.7 reference.
551 Returns:
552 A tuple containing all the attribute constants.
554 """
555 return (cls.Opt,)
557 @classmethod
558 def attributes_dict(cls) -> dict[str, str]:
559 """
560 Get a dictionary of attribute keys and their human-readable names.
562 This method returns a dictionary where the keys are the attribute
563 constants defined in the CheckboxRadioButtonAttributes class and the
564 values are their corresponding human-readable names. These attributes
565 correspond to the entries that are common to all field dictionaries as
566 specified in the PDF 1.7 reference.
568 Returns:
569 A dictionary containing attribute keys and their names.
571 """
572 return {
573 cls.Opt: "Options",
574 }
577class FieldFlag(IntFlag):
578 """Table 8.70 Field flags common to all field types."""
580 READ_ONLY = 1
581 REQUIRED = 2
582 NO_EXPORT = 4
585class DocumentInformationAttributes:
586 """Table 10.2 Entries in the document information dictionary."""
588 TITLE = "/Title" # text string, optional
589 AUTHOR = "/Author" # text string, optional
590 SUBJECT = "/Subject" # text string, optional
591 KEYWORDS = "/Keywords" # text string, optional
592 CREATOR = "/Creator" # text string, optional
593 PRODUCER = "/Producer" # text string, optional
594 CREATION_DATE = "/CreationDate" # date, optional
595 MOD_DATE = "/ModDate" # date, optional
596 TRAPPED = "/Trapped" # name, optional
599class PageLayouts:
600 """
601 Page 84, PDF 1.4 reference.
602 Page 115, PDF 2.0 reference.
603 """
605 SINGLE_PAGE = "/SinglePage"
606 ONE_COLUMN = "/OneColumn"
607 TWO_COLUMN_LEFT = "/TwoColumnLeft"
608 TWO_COLUMN_RIGHT = "/TwoColumnRight"
609 TWO_PAGE_LEFT = "/TwoPageLeft" # (PDF 1.5)
610 TWO_PAGE_RIGHT = "/TwoPageRight" # (PDF 1.5)
613class GraphicsStateParameters:
614 """Table 58 – Entries in a Graphics State Parameter Dictionary"""
616 TYPE = "/Type" # name, optional
617 LW = "/LW" # number, optional
618 LC = "/LC" # integer, optional
619 LJ = "/LJ" # integer, optional
620 ML = "/ML" # number, optional
621 D = "/D" # array, optional
622 RI = "/RI" # name, optional
623 OP = "/OP"
624 op = "/op"
625 OPM = "/OPM"
626 FONT = "/Font" # array, optional
627 BG = "/BG"
628 BG2 = "/BG2"
629 UCR = "/UCR"
630 UCR2 = "/UCR2"
631 TR = "/TR"
632 TR2 = "/TR2"
633 HT = "/HT"
634 FL = "/FL"
635 SM = "/SM"
636 SA = "/SA"
637 BM = "/BM"
638 S_MASK = "/SMask" # dictionary or name, optional
639 CA = "/CA"
640 ca = "/ca"
641 AIS = "/AIS"
642 TK = "/TK"
645class _CatalogDictionaryMeta(type):
646 def __getattribute__(cls, name: str) -> Any:
647 value = super().__getattribute__(name)
649 if not name.startswith("__"):
650 deprecate_with_replacement("CatalogDictionary", "CatalogAttributes", "7.0.0")
651 return value
654class CatalogDictionary(CatalogAttributes, metaclass=_CatalogDictionaryMeta):
655 def __init__(self) -> None:
656 deprecate_with_replacement("CatalogDictionary", "CatalogAttributes", "7.0.0")
659class OutlineFontFlag(IntFlag):
660 """A class used as an enumerable flag for formatting an outline font."""
662 italic = 1
663 bold = 2
666class PageLabelStyle(StrEnum):
667 """
668 Table 8.10 in the 1.7 reference.
669 Table 161 in the 2.0 reference.
670 """
672 DECIMAL = "/D" # Decimal Arabic numerals
673 UPPERCASE_ROMAN = "/R" # Uppercase Roman numerals
674 LOWERCASE_ROMAN = "/r" # Lowercase Roman numerals
675 UPPERCASE_LETTER = "/A" # Uppercase letters
676 LOWERCASE_LETTER = "/a" # Lowercase letters
679class AnnotationFlag(IntFlag):
680 """See §12.5.3 "Annotation Flags"."""
682 INVISIBLE = 1
683 HIDDEN = 2
684 PRINT = 4
685 NO_ZOOM = 8
686 NO_ROTATE = 16
687 NO_VIEW = 32
688 READ_ONLY = 64
689 LOCKED = 128
690 TOGGLE_NO_VIEW = 256
691 LOCKED_CONTENTS = 512
694PDF_KEYS = (
695 AnnotationDictionaryAttributes,
696 CatalogAttributes,
697 CatalogDictionary,
698 CcittFaxDecodeParameters,
699 CheckboxRadioButtonAttributes,
700 ColorSpaces,
701 Core,
702 DocumentInformationAttributes,
703 EncryptionDictAttributes,
704 FieldDictionaryAttributes,
705 FileSpecificationDictionaryEntries,
706 FilterTypeAbbreviations,
707 FilterTypes,
708 GoToActionArguments,
709 GraphicsStateParameters,
710 ImageAttributes,
711 InteractiveFormDictEntries,
712 LzwFilterParameters,
713 PageAttributes,
714 PageLayouts,
715 PagesAttributes,
716 Resources,
717 StreamAttributes,
718 TrailerKeys,
719 TypArguments,
720 TypFitArguments,
721)
724class ImageType(IntFlag):
725 NONE = 0
726 XOBJECT_IMAGES = auto()
727 INLINE_IMAGES = auto()
728 DRAWING_IMAGES = auto()
729 ALL = XOBJECT_IMAGES | INLINE_IMAGES | DRAWING_IMAGES
730 IMAGES = ALL # for consistency with ObjectDeletionFlag
733_INLINE_IMAGE_VALUE_MAPPING = {
734 "/G": "/DeviceGray",
735 "/RGB": "/DeviceRGB",
736 "/CMYK": "/DeviceCMYK",
737 "/I": "/Indexed",
738 "/AHx": "/ASCIIHexDecode",
739 "/A85": "/ASCII85Decode",
740 "/LZW": "/LZWDecode",
741 "/Fl": "/FlateDecode",
742 "/RL": "/RunLengthDecode",
743 "/CCF": "/CCITTFaxDecode",
744 "/DCT": "/DCTDecode",
745 "/DeviceGray": "/DeviceGray",
746 "/DeviceRGB": "/DeviceRGB",
747 "/DeviceCMYK": "/DeviceCMYK",
748 "/Indexed": "/Indexed",
749 "/ASCIIHexDecode": "/ASCIIHexDecode",
750 "/ASCII85Decode": "/ASCII85Decode",
751 "/LZWDecode": "/LZWDecode",
752 "/FlateDecode": "/FlateDecode",
753 "/RunLengthDecode": "/RunLengthDecode",
754 "/CCITTFaxDecode": "/CCITTFaxDecode",
755 "/DCTDecode": "/DCTDecode",
756 "/RelativeColorimetric": "/RelativeColorimetric",
757}
759_INLINE_IMAGE_KEY_MAPPING = {
760 "/BPC": "/BitsPerComponent",
761 "/CS": "/ColorSpace",
762 "/D": "/Decode",
763 "/DP": "/DecodeParms",
764 "/F": "/Filter",
765 "/H": "/Height",
766 "/W": "/Width",
767 "/I": "/Interpolate",
768 "/Intent": "/Intent",
769 "/IM": "/ImageMask",
770 "/BitsPerComponent": "/BitsPerComponent",
771 "/ColorSpace": "/ColorSpace",
772 "/Decode": "/Decode",
773 "/DecodeParms": "/DecodeParms",
774 "/Filter": "/Filter",
775 "/Height": "/Height",
776 "/Width": "/Width",
777 "/Interpolate": "/Interpolate",
778 "/ImageMask": "/ImageMask",
779}
782class AFRelationship:
783 """
784 Associated file relationship types, defining the relationship between
785 the PDF component and the associated file.
787 Defined in table 43 of the PDF 2.0 reference.
788 """
790 SOURCE = "/Source" # Original content source
791 DATA = "/Data" # Base data for visual presentation
792 ALTERNATIVE = "/Alternative" # Alternative content representation
793 SUPPLEMENT = "/Supplement" # Supplemental representation of original source/data
794 ENCRYPTED_PAYLOAD = "/EncryptedPayload" # Encrypted payload document
795 FORM_DATA = "/FormData" # Data associated with AcroForm of this PDF
796 SCHEMA = "/Schema" # Schema definition for associated object
797 UNSPECIFIED = "/Unspecified" # Not known or cannot be described with values
800class BorderStyles:
801 """
802 A class defining border styles used in PDF documents.
804 Defined in table 168 of the PDF 2.0 reference.
805 """
807 BEVELED = "/B"
808 DASHED = "/D"
809 INSET = "/I"
810 SOLID = "/S"
811 UNDERLINED = "/U"
814class FontFlags(IntFlag):
815 """
816 A class defining font flags in PDF document font descriptor resources.
818 Defined in table 121 of the PDF 2.0 reference.
819 """
821 FIXED_PITCH = 1 << 0
822 SERIF = 1 << 1
823 SYMBOLIC = 1 << 2
824 SCRIPT = 1 << 3
825 NONSYMBOLIC = 1 << 5
826 ITALIC = 1 << 6
827 ALL_CAP = 1 << 16
828 SMALL_CAP = 1 << 17
829 FORCE_BOLD = 1 << 18