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