Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/pypdf/constants.py: 94%
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."""
3from enum import Enum, IntFlag, auto, unique
4from typing import Dict, Tuple
7class StrEnum(str, Enum): # Once we are on Python 3.11+: enum.StrEnum
8 def __str__(self) -> str:
9 return str(self.value)
12class Core:
13 """Keywords that don't quite belong anywhere else."""
15 OUTLINES = "/Outlines"
16 THREADS = "/Threads"
17 PAGE = "/Page"
18 PAGES = "/Pages"
19 CATALOG = "/Catalog"
22class TrailerKeys:
23 SIZE = "/Size"
24 PREV = "/Prev"
25 ROOT = "/Root"
26 ENCRYPT = "/Encrypt"
27 INFO = "/Info"
28 ID = "/ID"
31class CatalogAttributes:
32 NAMES = "/Names"
33 DESTS = "/Dests"
36class EncryptionDictAttributes:
37 """
38 Additional encryption dictionary entries for the standard security handler.
40 Table 3.19, Page 122.
41 Table 21 of the 2.0 manual.
42 """
44 R = "/R" # number, required; revision of the standard security handler
45 O = "/O" # 32-byte string, required # noqa: E741
46 U = "/U" # 32-byte string, required
47 P = "/P" # integer flag, required; permitted operations
48 ENCRYPT_METADATA = "/EncryptMetadata" # boolean flag, optional
51class UserAccessPermissions(IntFlag):
52 """
53 Table 3.20 User access permissions.
54 Table 22 of the 2.0 manual.
55 """
57 R1 = 1
58 R2 = 2
59 PRINT = 4
60 MODIFY = 8
61 EXTRACT = 16
62 ADD_OR_MODIFY = 32
63 R7 = 64
64 R8 = 128
65 FILL_FORM_FIELDS = 256
66 EXTRACT_TEXT_AND_GRAPHICS = 512
67 ASSEMBLE_DOC = 1024
68 PRINT_TO_REPRESENTATION = 2048
69 R13 = 2**12
70 R14 = 2**13
71 R15 = 2**14
72 R16 = 2**15
73 R17 = 2**16
74 R18 = 2**17
75 R19 = 2**18
76 R20 = 2**19
77 R21 = 2**20
78 R22 = 2**21
79 R23 = 2**22
80 R24 = 2**23
81 R25 = 2**24
82 R26 = 2**25
83 R27 = 2**26
84 R28 = 2**27
85 R29 = 2**28
86 R30 = 2**29
87 R31 = 2**30
88 R32 = 2**31
90 @classmethod
91 def _is_reserved(cls, name: str) -> bool:
92 """Check if the given name corresponds to a reserved flag entry."""
93 return name.startswith("R") and name[1:].isdigit()
95 @classmethod
96 def _is_active(cls, name: str) -> bool:
97 """Check if the given reserved name defaults to 1 = active."""
98 return name not in {"R1", "R2"}
100 def to_dict(self) -> Dict[str, bool]:
101 """Convert the given flag value to a corresponding verbose name mapping."""
102 result: Dict[str, bool] = {}
103 for name, flag in UserAccessPermissions.__members__.items():
104 if UserAccessPermissions._is_reserved(name):
105 continue
106 result[name.lower()] = (self & flag) == flag
107 return result
109 @classmethod
110 def from_dict(cls, value: Dict[str, bool]) -> "UserAccessPermissions":
111 """Convert the verbose name mapping to the corresponding flag value."""
112 value_copy = value.copy()
113 result = cls(0)
114 for name, flag in cls.__members__.items():
115 if cls._is_reserved(name):
116 # Reserved names have a required value. Use it.
117 if cls._is_active(name):
118 result |= flag
119 continue
120 is_active = value_copy.pop(name.lower(), False)
121 if is_active:
122 result |= flag
123 if value_copy:
124 raise ValueError(f"Unknown dictionary keys: {value_copy!r}")
125 return result
127 @classmethod
128 def all(cls) -> "UserAccessPermissions":
129 return cls((2**32 - 1) - cls.R1 - cls.R2)
132class Resources:
133 """
134 Table 3.30 Entries in a resource dictionary.
135 Table 34 in the 2.0 reference.
136 """
138 EXT_G_STATE = "/ExtGState" # dictionary, optional
139 COLOR_SPACE = "/ColorSpace" # dictionary, optional
140 PATTERN = "/Pattern" # dictionary, optional
141 SHADING = "/Shading" # dictionary, optional
142 XOBJECT = "/XObject" # dictionary, optional
143 FONT = "/Font" # dictionary, optional
144 PROC_SET = "/ProcSet" # array, optional
145 PROPERTIES = "/Properties" # dictionary, optional
148class Ressources: # deprecated
149 """
150 Use :class: `Resources` instead.
152 .. deprecated:: 5.0.0
153 """
156class PagesAttributes:
157 """§7.7.3.2 of the 1.7 and 2.0 reference."""
159 TYPE = "/Type" # name, required; must be /Pages
160 PARENT = "/Parent" # dictionary, required; indirect reference to pages object
161 KIDS = "/Kids" # array, required; List of indirect references
162 COUNT = "/Count"
163 # integer, required; the number of leaf nodes (page objects)
164 # that are descendants of this node within the page tree
167class PageAttributes:
168 """§7.7.3.3 of the 1.7 and 2.0 reference."""
170 TYPE = "/Type" # name, required; must be /Page
171 PARENT = "/Parent" # dictionary, required; a pages object
172 LAST_MODIFIED = (
173 "/LastModified" # date, optional; date and time of last modification
174 )
175 RESOURCES = "/Resources" # dictionary, required if there are any
176 MEDIABOX = "/MediaBox" # rectangle, required; rectangle specifying page size
177 CROPBOX = "/CropBox" # rectangle, optional
178 BLEEDBOX = "/BleedBox" # rectangle, optional
179 TRIMBOX = "/TrimBox" # rectangle, optional
180 ARTBOX = "/ArtBox" # rectangle, optional
181 BOX_COLOR_INFO = "/BoxColorInfo" # dictionary, optional
182 CONTENTS = "/Contents" # stream or array, optional
183 ROTATE = "/Rotate" # integer, optional; page rotation in degrees
184 GROUP = "/Group" # dictionary, optional; page group
185 THUMB = "/Thumb" # stream, optional; indirect reference to image of the page
186 B = "/B" # array, optional
187 DUR = "/Dur" # number, optional
188 TRANS = "/Trans" # dictionary, optional
189 ANNOTS = "/Annots" # array, optional; an array of annotations
190 AA = "/AA" # dictionary, optional
191 METADATA = "/Metadata" # stream, optional
192 PIECE_INFO = "/PieceInfo" # dictionary, optional
193 STRUCT_PARENTS = "/StructParents" # integer, optional
194 ID = "/ID" # byte string, optional
195 PZ = "/PZ" # number, optional
196 SEPARATION_INFO = "/SeparationInfo" # dictionary, optional
197 TABS = "/Tabs" # name, optional
198 TEMPLATE_INSTANTIATED = "/TemplateInstantiated" # name, optional
199 PRES_STEPS = "/PresSteps" # dictionary, optional
200 USER_UNIT = "/UserUnit" # number, optional
201 VP = "/VP" # dictionary, optional
202 AF = "/AF" # array of dictionaries, optional
203 OUTPUT_INTENTS = "/OutputIntents" # array, optional
204 D_PART = "/DPart" # dictionary, required, if this page is within the range of a DPart, not permitted otherwise
207class FileSpecificationDictionaryEntries:
208 """Table 3.41 Entries in a file specification dictionary."""
210 Type = "/Type"
211 FS = "/FS" # The name of the file system to be used to interpret this file specification
212 F = "/F" # A file specification string of the form described in §3.10.1
213 UF = "/UF" # A Unicode string of the file as described in §3.10.1
214 DOS = "/DOS"
215 Mac = "/Mac"
216 Unix = "/Unix"
217 ID = "/ID"
218 V = "/V"
219 EF = "/EF" # dictionary, containing a subset of the keys F, UF, DOS, Mac, and Unix
220 RF = "/RF" # dictionary, containing arrays of /EmbeddedFile
221 DESC = "/Desc" # description of the file
222 Cl = "/Cl"
225class StreamAttributes:
226 """
227 Table 4.2.
228 Table 5 in the 2.0 reference.
229 """
231 LENGTH = "/Length" # integer, required
232 FILTER = "/Filter" # name or array of names, optional
233 DECODE_PARMS = "/DecodeParms" # variable, optional -- 'decodeParams is wrong
236@unique
237class FilterTypes(StrEnum):
238 """§7.4 of the 1.7 and 2.0 references."""
240 ASCII_HEX_DECODE = "/ASCIIHexDecode" # abbreviation: AHx
241 ASCII_85_DECODE = "/ASCII85Decode" # abbreviation: A85
242 LZW_DECODE = "/LZWDecode" # abbreviation: LZW
243 FLATE_DECODE = "/FlateDecode" # abbreviation: Fl
244 RUN_LENGTH_DECODE = "/RunLengthDecode" # abbreviation: RL
245 CCITT_FAX_DECODE = "/CCITTFaxDecode" # abbreviation: CCF
246 DCT_DECODE = "/DCTDecode" # abbreviation: DCT
247 JPX_DECODE = "/JPXDecode"
248 JBIG2_DECODE = "/JBIG2Decode"
251class FilterTypeAbbreviations:
252 """§8.9.7 of the 1.7 and 2.0 references."""
254 AHx = "/AHx"
255 A85 = "/A85"
256 LZW = "/LZW"
257 FL = "/Fl"
258 RL = "/RL"
259 CCF = "/CCF"
260 DCT = "/DCT"
263class LzwFilterParameters:
264 """
265 Table 4.4.
266 Table 8 in the 2.0 reference.
267 """
269 PREDICTOR = "/Predictor" # integer
270 COLORS = "/Colors" # integer
271 BITS_PER_COMPONENT = "/BitsPerComponent" # integer
272 COLUMNS = "/Columns" # integer
273 EARLY_CHANGE = "/EarlyChange" # integer
276class CcittFaxDecodeParameters:
277 """
278 Table 4.5.
279 Table 11 in the 2.0 reference.
280 """
282 K = "/K" # integer
283 END_OF_LINE = "/EndOfLine" # boolean
284 ENCODED_BYTE_ALIGN = "/EncodedByteAlign" # boolean
285 COLUMNS = "/Columns" # integer
286 ROWS = "/Rows" # integer
287 END_OF_BLOCK = "/EndOfBlock" # boolean
288 BLACK_IS_1 = "/BlackIs1" # boolean
289 DAMAGED_ROWS_BEFORE_ERROR = "/DamagedRowsBeforeError" # integer
292class ImageAttributes:
293 """§11.6.5 of the 1.7 and 2.0 references."""
295 TYPE = "/Type" # name, required; must be /XObject
296 SUBTYPE = "/Subtype" # name, required; must be /Image
297 NAME = "/Name" # name, required
298 WIDTH = "/Width" # integer, required
299 HEIGHT = "/Height" # integer, required
300 BITS_PER_COMPONENT = "/BitsPerComponent" # integer, required
301 COLOR_SPACE = "/ColorSpace" # name, required
302 DECODE = "/Decode" # array, optional
303 INTENT = "/Intent" # string, optional
304 INTERPOLATE = "/Interpolate" # boolean, optional
305 IMAGE_MASK = "/ImageMask" # boolean, optional
306 MASK = "/Mask" # 1-bit image mask stream
307 S_MASK = "/SMask" # dictionary or name, optional
310class ColorSpaces:
311 DEVICE_RGB = "/DeviceRGB"
312 DEVICE_CMYK = "/DeviceCMYK"
313 DEVICE_GRAY = "/DeviceGray"
316class TypArguments:
317 """Table 8.2 of the PDF 1.7 reference."""
319 LEFT = "/Left"
320 RIGHT = "/Right"
321 BOTTOM = "/Bottom"
322 TOP = "/Top"
325class TypFitArguments:
326 """Table 8.2 of the PDF 1.7 reference."""
328 XYZ = "/XYZ"
329 FIT = "/Fit"
330 FIT_H = "/FitH"
331 FIT_V = "/FitV"
332 FIT_R = "/FitR"
333 FIT_B = "/FitB"
334 FIT_BH = "/FitBH"
335 FIT_BV = "/FitBV"
338class GoToActionArguments:
339 S = "/S" # name, required: type of action
340 D = "/D" # name, byte string, or array, required: destination to jump to
341 SD = "/SD" # array, optional: structure destination to jump to
344class AnnotationDictionaryAttributes:
345 """Table 8.15 Entries common to all annotation dictionaries."""
347 Type = "/Type"
348 Subtype = "/Subtype"
349 Rect = "/Rect"
350 Contents = "/Contents"
351 P = "/P"
352 NM = "/NM"
353 M = "/M"
354 F = "/F"
355 AP = "/AP"
356 AS = "/AS"
357 DA = "/DA"
358 Border = "/Border"
359 C = "/C"
360 StructParent = "/StructParent"
361 OC = "/OC"
364class InteractiveFormDictEntries:
365 Fields = "/Fields"
366 NeedAppearances = "/NeedAppearances"
367 SigFlags = "/SigFlags"
368 CO = "/CO"
369 DR = "/DR"
370 DA = "/DA"
371 Q = "/Q"
372 XFA = "/XFA"
375class FieldDictionaryAttributes:
376 """
377 Entries common to all field dictionaries (Table 8.69 PDF 1.7 reference)
378 (*very partially documented here*).
380 FFBits provides the constants used for `/Ff` from Table 8.70/8.75/8.77/8.79
381 """
383 FT = "/FT" # name, required for terminal fields
384 Parent = "/Parent" # dictionary, required for children
385 Kids = "/Kids" # array, sometimes required
386 T = "/T" # text string, optional
387 TU = "/TU" # text string, optional
388 TM = "/TM" # text string, optional
389 Ff = "/Ff" # integer, optional
390 V = "/V" # text string or array, optional
391 DV = "/DV" # text string, optional
392 AA = "/AA" # dictionary, optional
393 Opt = "/Opt" # array, optional
395 class FfBits(IntFlag):
396 """
397 Ease building /Ff flags
398 Some entries may be specific to:
400 * Text (Tx) (Table 8.75 PDF 1.7 reference)
401 * Buttons (Btn) (Table 8.77 PDF 1.7 reference)
402 * Choice (Ch) (Table 8.79 PDF 1.7 reference)
403 """
405 ReadOnly = 1 << 0
406 """common to Tx/Btn/Ch in Table 8.70"""
407 Required = 1 << 1
408 """common to Tx/Btn/Ch in Table 8.70"""
409 NoExport = 1 << 2
410 """common to Tx/Btn/Ch in Table 8.70"""
412 Multiline = 1 << 12
413 """Tx"""
414 Password = 1 << 13
415 """Tx"""
417 NoToggleToOff = 1 << 14
418 """Btn"""
419 Radio = 1 << 15
420 """Btn"""
421 Pushbutton = 1 << 16
422 """Btn"""
424 Combo = 1 << 17
425 """Ch"""
426 Edit = 1 << 18
427 """Ch"""
428 Sort = 1 << 19
429 """Ch"""
431 FileSelect = 1 << 20
432 """Tx"""
434 MultiSelect = 1 << 21
435 """Tx"""
437 DoNotSpellCheck = 1 << 22
438 """Tx/Ch"""
439 DoNotScroll = 1 << 23
440 """Tx"""
441 Comb = 1 << 24
442 """Tx"""
444 RadiosInUnison = 1 << 25
445 """Btn"""
447 RichText = 1 << 25
448 """Tx"""
450 CommitOnSelChange = 1 << 26
451 """Ch"""
453 @classmethod
454 def attributes(cls) -> Tuple[str, ...]:
455 """
456 Get a tuple of all the attributes present in a Field Dictionary.
458 This method returns a tuple of all the attribute constants defined in
459 the FieldDictionaryAttributes class. These attributes correspond to the
460 entries that are common to all field dictionaries as specified in the
461 PDF 1.7 reference.
463 Returns:
464 A tuple containing all the attribute constants.
466 """
467 return (
468 cls.TM,
469 cls.T,
470 cls.FT,
471 cls.Parent,
472 cls.TU,
473 cls.Ff,
474 cls.V,
475 cls.DV,
476 cls.Kids,
477 cls.AA,
478 )
480 @classmethod
481 def attributes_dict(cls) -> Dict[str, str]:
482 """
483 Get a dictionary of attribute keys and their human-readable names.
485 This method returns a dictionary where the keys are the attribute
486 constants defined in the FieldDictionaryAttributes class and the values
487 are their corresponding human-readable names. These attributes
488 correspond to the entries that are common to all field dictionaries as
489 specified in the PDF 1.7 reference.
491 Returns:
492 A dictionary containing attribute keys and their names.
494 """
495 return {
496 cls.FT: "Field Type",
497 cls.Parent: "Parent",
498 cls.T: "Field Name",
499 cls.TU: "Alternate Field Name",
500 cls.TM: "Mapping Name",
501 cls.Ff: "Field Flags",
502 cls.V: "Value",
503 cls.DV: "Default Value",
504 }
507class CheckboxRadioButtonAttributes:
508 """Table 8.76 Field flags common to all field types."""
510 Opt = "/Opt" # Options, Optional
512 @classmethod
513 def attributes(cls) -> Tuple[str, ...]:
514 """
515 Get a tuple of all the attributes present in a Field Dictionary.
517 This method returns a tuple of all the attribute constants defined in
518 the CheckboxRadioButtonAttributes class. These attributes correspond to
519 the entries that are common to all field dictionaries as specified in
520 the PDF 1.7 reference.
522 Returns:
523 A tuple containing all the attribute constants.
525 """
526 return (cls.Opt,)
528 @classmethod
529 def attributes_dict(cls) -> Dict[str, str]:
530 """
531 Get a dictionary of attribute keys and their human-readable names.
533 This method returns a dictionary where the keys are the attribute
534 constants defined in the CheckboxRadioButtonAttributes class and the
535 values are their corresponding human-readable names. These attributes
536 correspond to the entries that are common to all field dictionaries as
537 specified in the PDF 1.7 reference.
539 Returns:
540 A dictionary containing attribute keys and their names.
542 """
543 return {
544 cls.Opt: "Options",
545 }
548class FieldFlag(IntFlag):
549 """Table 8.70 Field flags common to all field types."""
551 READ_ONLY = 1
552 REQUIRED = 2
553 NO_EXPORT = 4
556class DocumentInformationAttributes:
557 """Table 10.2 Entries in the document information dictionary."""
559 TITLE = "/Title" # text string, optional
560 AUTHOR = "/Author" # text string, optional
561 SUBJECT = "/Subject" # text string, optional
562 KEYWORDS = "/Keywords" # text string, optional
563 CREATOR = "/Creator" # text string, optional
564 PRODUCER = "/Producer" # text string, optional
565 CREATION_DATE = "/CreationDate" # date, optional
566 MOD_DATE = "/ModDate" # date, optional
567 TRAPPED = "/Trapped" # name, optional
570class PageLayouts:
571 """
572 Page 84, PDF 1.4 reference.
573 Page 115, PDF 2.0 reference.
574 """
576 SINGLE_PAGE = "/SinglePage"
577 ONE_COLUMN = "/OneColumn"
578 TWO_COLUMN_LEFT = "/TwoColumnLeft"
579 TWO_COLUMN_RIGHT = "/TwoColumnRight"
580 TWO_PAGE_LEFT = "/TwoPageLeft" # (PDF 1.5)
581 TWO_PAGE_RIGHT = "/TwoPageRight" # (PDF 1.5)
584class GraphicsStateParameters:
585 """Table 58 – Entries in a Graphics State Parameter Dictionary"""
587 TYPE = "/Type" # name, optional
588 LW = "/LW" # number, optional
589 LC = "/LC" # integer, optional
590 LJ = "/LJ" # integer, optional
591 ML = "/ML" # number, optional
592 D = "/D" # array, optional
593 RI = "/RI" # name, optional
594 OP = "/OP"
595 op = "/op"
596 OPM = "/OPM"
597 FONT = "/Font" # array, optional
598 BG = "/BG"
599 BG2 = "/BG2"
600 UCR = "/UCR"
601 UCR2 = "/UCR2"
602 TR = "/TR"
603 TR2 = "/TR2"
604 HT = "/HT"
605 FL = "/FL"
606 SM = "/SM"
607 SA = "/SA"
608 BM = "/BM"
609 S_MASK = "/SMask" # dictionary or name, optional
610 CA = "/CA"
611 ca = "/ca"
612 AIS = "/AIS"
613 TK = "/TK"
616class CatalogDictionary:
617 """§7.7.2 of the 1.7 and 2.0 references."""
619 TYPE = "/Type" # name, required; must be /Catalog
620 VERSION = "/Version" # name
621 EXTENSIONS = "/Extensions" # dictionary, optional; ISO 32000-1
622 PAGES = "/Pages" # dictionary, required
623 PAGE_LABELS = "/PageLabels" # number tree, optional
624 NAMES = "/Names" # dictionary, optional
625 DESTS = "/Dests" # dictionary, optional
626 VIEWER_PREFERENCES = "/ViewerPreferences" # dictionary, optional
627 PAGE_LAYOUT = "/PageLayout" # name, optional
628 PAGE_MODE = "/PageMode" # name, optional
629 OUTLINES = "/Outlines" # dictionary, optional
630 THREADS = "/Threads" # array, optional
631 OPEN_ACTION = "/OpenAction" # array or dictionary or name, optional
632 AA = "/AA" # dictionary, optional
633 URI = "/URI" # dictionary, optional
634 ACRO_FORM = "/AcroForm" # dictionary, optional
635 METADATA = "/Metadata" # stream, optional
636 STRUCT_TREE_ROOT = "/StructTreeRoot" # dictionary, optional
637 MARK_INFO = "/MarkInfo" # dictionary, optional
638 LANG = "/Lang" # text string, optional
639 SPIDER_INFO = "/SpiderInfo" # dictionary, optional
640 OUTPUT_INTENTS = "/OutputIntents" # array, optional
641 PIECE_INFO = "/PieceInfo" # dictionary, optional
642 OC_PROPERTIES = "/OCProperties" # dictionary, optional
643 PERMS = "/Perms" # dictionary, optional
644 LEGAL = "/Legal" # dictionary, optional
645 REQUIREMENTS = "/Requirements" # array, optional
646 COLLECTION = "/Collection" # dictionary, optional
647 NEEDS_RENDERING = "/NeedsRendering" # boolean, optional
648 DSS = "/DSS" # dictionary, optional
649 AF = "/AF" # array of dictionaries, optional
650 D_PART_ROOT = "/DPartRoot" # dictionary, optional
653class OutlineFontFlag(IntFlag):
654 """A class used as an enumerable flag for formatting an outline font."""
656 italic = 1
657 bold = 2
660class PageLabelStyle:
661 """
662 Table 8.10 in the 1.7 reference.
663 Table 161 in the 2.0 reference.
664 """
666 DECIMAL = "/D" # Decimal Arabic numerals
667 UPPERCASE_ROMAN = "/R" # Uppercase Roman numerals
668 LOWERCASE_ROMAN = "/r" # Lowercase Roman numerals
669 UPPERCASE_LETTER = "/A" # Uppercase letters
670 LOWERCASE_LETTER = "/a" # Lowercase letters
673class AnnotationFlag(IntFlag):
674 """See §12.5.3 "Annotation Flags"."""
676 INVISIBLE = 1
677 HIDDEN = 2
678 PRINT = 4
679 NO_ZOOM = 8
680 NO_ROTATE = 16
681 NO_VIEW = 32
682 READ_ONLY = 64
683 LOCKED = 128
684 TOGGLE_NO_VIEW = 256
685 LOCKED_CONTENTS = 512
688PDF_KEYS = (
689 AnnotationDictionaryAttributes,
690 CatalogAttributes,
691 CatalogDictionary,
692 CcittFaxDecodeParameters,
693 CheckboxRadioButtonAttributes,
694 ColorSpaces,
695 Core,
696 DocumentInformationAttributes,
697 EncryptionDictAttributes,
698 FieldDictionaryAttributes,
699 FileSpecificationDictionaryEntries,
700 FilterTypeAbbreviations,
701 FilterTypes,
702 GoToActionArguments,
703 GraphicsStateParameters,
704 ImageAttributes,
705 InteractiveFormDictEntries,
706 LzwFilterParameters,
707 PageAttributes,
708 PageLayouts,
709 PagesAttributes,
710 Resources,
711 StreamAttributes,
712 TrailerKeys,
713 TypArguments,
714 TypFitArguments,
715)
718class ImageType(IntFlag):
719 NONE = 0
720 XOBJECT_IMAGES = auto()
721 INLINE_IMAGES = auto()
722 DRAWING_IMAGES = auto()
723 ALL = XOBJECT_IMAGES | INLINE_IMAGES | DRAWING_IMAGES
724 IMAGES = ALL # for consistency with ObjectDeletionFlag
727_INLINE_IMAGE_VALUE_MAPPING = {
728 "/G": "/DeviceGray",
729 "/RGB": "/DeviceRGB",
730 "/CMYK": "/DeviceCMYK",
731 "/I": "/Indexed",
732 "/AHx": "/ASCIIHexDecode",
733 "/A85": "/ASCII85Decode",
734 "/LZW": "/LZWDecode",
735 "/Fl": "/FlateDecode",
736 "/RL": "/RunLengthDecode",
737 "/CCF": "/CCITTFaxDecode",
738 "/DCT": "/DCTDecode",
739 "/DeviceGray": "/DeviceGray",
740 "/DeviceRGB": "/DeviceRGB",
741 "/DeviceCMYK": "/DeviceCMYK",
742 "/Indexed": "/Indexed",
743 "/ASCIIHexDecode": "/ASCIIHexDecode",
744 "/ASCII85Decode": "/ASCII85Decode",
745 "/LZWDecode": "/LZWDecode",
746 "/FlateDecode": "/FlateDecode",
747 "/RunLengthDecode": "/RunLengthDecode",
748 "/CCITTFaxDecode": "/CCITTFaxDecode",
749 "/DCTDecode": "/DCTDecode",
750 "/RelativeColorimetric": "/RelativeColorimetric",
751}
753_INLINE_IMAGE_KEY_MAPPING = {
754 "/BPC": "/BitsPerComponent",
755 "/CS": "/ColorSpace",
756 "/D": "/Decode",
757 "/DP": "/DecodeParms",
758 "/F": "/Filter",
759 "/H": "/Height",
760 "/W": "/Width",
761 "/I": "/Interpolate",
762 "/Intent": "/Intent",
763 "/IM": "/ImageMask",
764 "/BitsPerComponent": "/BitsPerComponent",
765 "/ColorSpace": "/ColorSpace",
766 "/Decode": "/Decode",
767 "/DecodeParms": "/DecodeParms",
768 "/Filter": "/Filter",
769 "/Height": "/Height",
770 "/Width": "/Width",
771 "/Interpolate": "/Interpolate",
772 "/ImageMask": "/ImageMask",
773}