codekingpro/portable-devtools
114k
1"""Various constants, enums, and flags to aid readability."""2 3from enum import Enum, IntFlag, auto, unique4 5 6class StrEnum(str, Enum): # Once we are on Python 3.11+: enum.StrEnum7 def __str__(self) -> str:8 return str(self.value)9 10 11class Core:12 """Keywords that don't quite belong anywhere else."""13 14 OUTLINES = "/Outlines"15 THREADS = "/Threads"16 PAGE = "/Page"17 PAGES = "/Pages"18 CATALOG = "/Catalog"19 20 21class TrailerKeys:22 SIZE = "/Size"23 PREV = "/Prev"24 ROOT = "/Root"25 ENCRYPT = "/Encrypt"26 INFO = "/Info"27 ID = "/ID"28 29 30class CatalogAttributes:31 NAMES = "/Names"32 DESTS = "/Dests"33 34 35class EncryptionDictAttributes:36 """37 Additional encryption dictionary entries for the standard security handler.38 39 Table 3.19, Page 122.40 Table 21 of the 2.0 manual.41 """42 43 R = "/R" # number, required; revision of the standard security handler44 O = "/O" # 32-byte string, required # noqa: E74145 U = "/U" # 32-byte string, required46 P = "/P" # integer flag, required; permitted operations47 ENCRYPT_METADATA = "/EncryptMetadata" # boolean flag, optional48 49 50class UserAccessPermissions(IntFlag):51 """52 Table 3.20 User access permissions.53 Table 22 of the 2.0 manual.54 """55 56 R1 = 157 R2 = 258 PRINT = 459 MODIFY = 860 EXTRACT = 1661 ADD_OR_MODIFY = 3262 R7 = 6463 R8 = 12864 FILL_FORM_FIELDS = 25665 EXTRACT_TEXT_AND_GRAPHICS = 51266 ASSEMBLE_DOC = 102467 PRINT_TO_REPRESENTATION = 204868 R13 = 2**1269 R14 = 2**1370 R15 = 2**1471 R16 = 2**1572 R17 = 2**1673 R18 = 2**1774 R19 = 2**1875 R20 = 2**1976 R21 = 2**2077 R22 = 2**2178 R23 = 2**2279 R24 = 2**2380 R25 = 2**2481 R26 = 2**2582 R27 = 2**2683 R28 = 2**2784 R29 = 2**2885 R30 = 2**2986 R31 = 2**3087 R32 = 2**3188 89 @classmethod90 def _is_reserved(cls, name: str) -> bool:91 """Check if the given name corresponds to a reserved flag entry."""92 return name.startswith("R") and name[1:].isdigit()93 94 @classmethod95 def _is_active(cls, name: str) -> bool:96 """Check if the given reserved name defaults to 1 = active."""97 return name not in {"R1", "R2"}98 99 def to_dict(self) -> dict[str, bool]:100 """Convert the given flag value to a corresponding verbose name mapping."""101 result: dict[str, bool] = {}102 for name, flag in UserAccessPermissions.__members__.items():103 if UserAccessPermissions._is_reserved(name):104 continue105 result[name.lower()] = (self & flag) == flag106 return result107 108 @classmethod109 def from_dict(cls, value: dict[str, bool]) -> "UserAccessPermissions":110 """Convert the verbose name mapping to the corresponding flag value."""111 value_copy = value.copy()112 result = cls(0)113 for name, flag in cls.__members__.items():114 if cls._is_reserved(name):115 # Reserved names have a required value. Use it.116 if cls._is_active(name):117 result |= flag118 continue119 is_active = value_copy.pop(name.lower(), False)120 if is_active:121 result |= flag122 if value_copy:123 raise ValueError(f"Unknown dictionary keys: {value_copy!r}")124 return result125 126 @classmethod127 def all(cls) -> "UserAccessPermissions":128 return cls((2**32 - 1) - cls.R1 - cls.R2)129 130 131class Resources:132 """133 Table 3.30 Entries in a resource dictionary.134 Table 34 in the 2.0 reference.135 """136 137 EXT_G_STATE = "/ExtGState" # dictionary, optional138 COLOR_SPACE = "/ColorSpace" # dictionary, optional139 PATTERN = "/Pattern" # dictionary, optional140 SHADING = "/Shading" # dictionary, optional141 XOBJECT = "/XObject" # dictionary, optional142 FONT = "/Font" # dictionary, optional143 PROC_SET = "/ProcSet" # array, optional144 PROPERTIES = "/Properties" # dictionary, optional145 146 147class PagesAttributes:148 """§7.7.3.2 of the 1.7 and 2.0 reference."""149 150 TYPE = "/Type" # name, required; must be /Pages151 PARENT = "/Parent" # dictionary, required; indirect reference to pages object152 KIDS = "/Kids" # array, required; List of indirect references153 COUNT = "/Count"154 # integer, required; the number of leaf nodes (page objects)155 # that are descendants of this node within the page tree156 157 158class PageAttributes:159 """§7.7.3.3 of the 1.7 and 2.0 reference."""160 161 TYPE = "/Type" # name, required; must be /Page162 PARENT = "/Parent" # dictionary, required; a pages object163 LAST_MODIFIED = (164 "/LastModified" # date, optional; date and time of last modification165 )166 RESOURCES = "/Resources" # dictionary, required if there are any167 MEDIABOX = "/MediaBox" # rectangle, required; rectangle specifying page size168 CROPBOX = "/CropBox" # rectangle, optional169 BLEEDBOX = "/BleedBox" # rectangle, optional170 TRIMBOX = "/TrimBox" # rectangle, optional171 ARTBOX = "/ArtBox" # rectangle, optional172 BOX_COLOR_INFO = "/BoxColorInfo" # dictionary, optional173 CONTENTS = "/Contents" # stream or array, optional174 ROTATE = "/Rotate" # integer, optional; page rotation in degrees175 GROUP = "/Group" # dictionary, optional; page group176 THUMB = "/Thumb" # stream, optional; indirect reference to image of the page177 B = "/B" # array, optional178 DUR = "/Dur" # number, optional179 TRANS = "/Trans" # dictionary, optional180 ANNOTS = "/Annots" # array, optional; an array of annotations181 AA = "/AA" # dictionary, optional182 METADATA = "/Metadata" # stream, optional183 PIECE_INFO = "/PieceInfo" # dictionary, optional184 STRUCT_PARENTS = "/StructParents" # integer, optional185 ID = "/ID" # byte string, optional186 PZ = "/PZ" # number, optional187 SEPARATION_INFO = "/SeparationInfo" # dictionary, optional188 TABS = "/Tabs" # name, optional189 TEMPLATE_INSTANTIATED = "/TemplateInstantiated" # name, optional190 PRES_STEPS = "/PresSteps" # dictionary, optional191 USER_UNIT = "/UserUnit" # number, optional192 VP = "/VP" # dictionary, optional193 AF = "/AF" # array of dictionaries, optional194 OUTPUT_INTENTS = "/OutputIntents" # array, optional195 D_PART = "/DPart" # dictionary, required, if this page is within the range of a DPart, not permitted otherwise196 197 198class FileSpecificationDictionaryEntries:199 """Table 3.41 Entries in a file specification dictionary."""200 201 Type = "/Type"202 FS = "/FS" # The name of the file system to be used to interpret this file specification203 F = "/F" # A file specification string of the form described in §3.10.1204 UF = "/UF" # A Unicode string of the file as described in §3.10.1205 DOS = "/DOS"206 Mac = "/Mac"207 Unix = "/Unix"208 ID = "/ID"209 V = "/V"210 EF = "/EF" # dictionary, containing a subset of the keys F, UF, DOS, Mac, and Unix211 RF = "/RF" # dictionary, containing arrays of /EmbeddedFile212 DESC = "/Desc" # description of the file213 Cl = "/Cl"214 215 216class StreamAttributes:217 """218 Table 4.2.219 Table 5 in the 2.0 reference.220 """221 222 LENGTH = "/Length" # integer, required223 FILTER = "/Filter" # name or array of names, optional224 DECODE_PARMS = "/DecodeParms" # variable, optional -- 'decodeParams is wrong225 226 227@unique228class FilterTypes(StrEnum):229 """§7.4 of the 1.7 and 2.0 references."""230 231 ASCII_HEX_DECODE = "/ASCIIHexDecode" # abbreviation: AHx232 ASCII_85_DECODE = "/ASCII85Decode" # abbreviation: A85233 LZW_DECODE = "/LZWDecode" # abbreviation: LZW234 FLATE_DECODE = "/FlateDecode" # abbreviation: Fl235 RUN_LENGTH_DECODE = "/RunLengthDecode" # abbreviation: RL236 CCITT_FAX_DECODE = "/CCITTFaxDecode" # abbreviation: CCF237 DCT_DECODE = "/DCTDecode" # abbreviation: DCT238 JPX_DECODE = "/JPXDecode"239 JBIG2_DECODE = "/JBIG2Decode"240 241 242class FilterTypeAbbreviations:243 """§8.9.7 of the 1.7 and 2.0 references."""244 245 AHx = "/AHx"246 A85 = "/A85"247 LZW = "/LZW"248 FL = "/Fl"249 RL = "/RL"250 CCF = "/CCF"251 DCT = "/DCT"252 253 254class LzwFilterParameters:255 """256 Table 4.4.257 Table 8 in the 2.0 reference.258 """259 260 PREDICTOR = "/Predictor" # integer261 COLORS = "/Colors" # integer262 BITS_PER_COMPONENT = "/BitsPerComponent" # integer263 COLUMNS = "/Columns" # integer264 EARLY_CHANGE = "/EarlyChange" # integer265 266 267class CcittFaxDecodeParameters:268 """269 Table 4.5.270 Table 11 in the 2.0 reference.271 """272 273 K = "/K" # integer274 END_OF_LINE = "/EndOfLine" # boolean275 ENCODED_BYTE_ALIGN = "/EncodedByteAlign" # boolean276 COLUMNS = "/Columns" # integer277 ROWS = "/Rows" # integer278 END_OF_BLOCK = "/EndOfBlock" # boolean279 BLACK_IS_1 = "/BlackIs1" # boolean280 DAMAGED_ROWS_BEFORE_ERROR = "/DamagedRowsBeforeError" # integer281 282 283class ImageAttributes:284 """§11.6.5 of the 1.7 and 2.0 references."""285 286 TYPE = "/Type" # name, required; must be /XObject287 SUBTYPE = "/Subtype" # name, required; must be /Image288 NAME = "/Name" # name, required289 WIDTH = "/Width" # integer, required290 HEIGHT = "/Height" # integer, required291 BITS_PER_COMPONENT = "/BitsPerComponent" # integer, required292 COLOR_SPACE = "/ColorSpace" # name, required293 DECODE = "/Decode" # array, optional294 INTENT = "/Intent" # string, optional295 INTERPOLATE = "/Interpolate" # boolean, optional296 IMAGE_MASK = "/ImageMask" # boolean, optional297 MASK = "/Mask" # 1-bit image mask stream298 S_MASK = "/SMask" # dictionary or name, optional299 300 301class ColorSpaces:302 DEVICE_RGB = "/DeviceRGB"303 DEVICE_CMYK = "/DeviceCMYK"304 DEVICE_GRAY = "/DeviceGray"305 306 307class TypArguments:308 """Table 8.2 of the PDF 1.7 reference."""309 310 LEFT = "/Left"311 RIGHT = "/Right"312 BOTTOM = "/Bottom"313 TOP = "/Top"314 315 316class TypFitArguments:317 """Table 8.2 of the PDF 1.7 reference."""318 319 XYZ = "/XYZ"320 FIT = "/Fit"321 FIT_H = "/FitH"322 FIT_V = "/FitV"323 FIT_R = "/FitR"324 FIT_B = "/FitB"325 FIT_BH = "/FitBH"326 FIT_BV = "/FitBV"327 328 329class GoToActionArguments:330 S = "/S" # name, required: type of action331 D = "/D" # name, byte string, or array, required: destination to jump to332 SD = "/SD" # array, optional: structure destination to jump to333 334 335class AnnotationDictionaryAttributes:336 """Table 8.15 Entries common to all annotation dictionaries."""337 338 Type = "/Type"339 Subtype = "/Subtype"340 Rect = "/Rect"341 Contents = "/Contents"342 P = "/P"343 NM = "/NM"344 M = "/M"345 F = "/F"346 AP = "/AP"347 AS = "/AS"348 DA = "/DA"349 Border = "/Border"350 C = "/C"351 StructParent = "/StructParent"352 OC = "/OC"353 354 355class InteractiveFormDictEntries:356 Fields = "/Fields"357 NeedAppearances = "/NeedAppearances"358 SigFlags = "/SigFlags"359 CO = "/CO"360 DR = "/DR"361 DA = "/DA"362 Q = "/Q"363 XFA = "/XFA"364 365 366class FieldDictionaryAttributes:367 """368 Entries common to all field dictionaries (Table 8.69 PDF 1.7 reference)369 (*very partially documented here*).370 371 FFBits provides the constants used for `/Ff` from Table 8.70/8.75/8.77/8.79372 """373 374 FT = "/FT" # name, required for terminal fields375 Parent = "/Parent" # dictionary, required for children376 Kids = "/Kids" # array, sometimes required377 T = "/T" # text string, optional378 TU = "/TU" # text string, optional379 TM = "/TM" # text string, optional380 Ff = "/Ff" # integer, optional381 V = "/V" # text string or array, optional382 DV = "/DV" # text string, optional383 AA = "/AA" # dictionary, optional384 Opt = "/Opt" # array, optional385 386 class FfBits(IntFlag):387 """388 Ease building /Ff flags389 Some entries may be specific to:390 391 * Text (Tx) (Table 8.75 PDF 1.7 reference)392 * Buttons (Btn) (Table 8.77 PDF 1.7 reference)393 * Choice (Ch) (Table 8.79 PDF 1.7 reference)394 """395 396 ReadOnly = 1 << 0397 """common to Tx/Btn/Ch in Table 8.70"""398 Required = 1 << 1399 """common to Tx/Btn/Ch in Table 8.70"""400 NoExport = 1 << 2401 """common to Tx/Btn/Ch in Table 8.70"""402 403 Multiline = 1 << 12404 """Tx"""405 Password = 1 << 13406 """Tx"""407 408 NoToggleToOff = 1 << 14409 """Btn"""410 Radio = 1 << 15411 """Btn"""412 Pushbutton = 1 << 16413 """Btn"""414 415 Combo = 1 << 17416 """Ch"""417 Edit = 1 << 18418 """Ch"""419 Sort = 1 << 19420 """Ch"""421 422 FileSelect = 1 << 20423 """Tx"""424 425 MultiSelect = 1 << 21426 """Tx"""427 428 DoNotSpellCheck = 1 << 22429 """Tx/Ch"""430 DoNotScroll = 1 << 23431 """Tx"""432 Comb = 1 << 24433 """Tx"""434 435 RadiosInUnison = 1 << 25436 """Btn"""437 438 RichText = 1 << 25439 """Tx"""440 441 CommitOnSelChange = 1 << 26442 """Ch"""443 444 @classmethod445 def attributes(cls) -> tuple[str, ...]:446 """447 Get a tuple of all the attributes present in a Field Dictionary.448 449 This method returns a tuple of all the attribute constants defined in450 the FieldDictionaryAttributes class. These attributes correspond to the451 entries that are common to all field dictionaries as specified in the452 PDF 1.7 reference.453 454 Returns:455 A tuple containing all the attribute constants.456 457 """458 return (459 cls.TM,460 cls.T,461 cls.FT,462 cls.Parent,463 cls.TU,464 cls.Ff,465 cls.V,466 cls.DV,467 cls.Kids,468 cls.AA,469 )470 471 @classmethod472 def attributes_dict(cls) -> dict[str, str]:473 """474 Get a dictionary of attribute keys and their human-readable names.475 476 This method returns a dictionary where the keys are the attribute477 constants defined in the FieldDictionaryAttributes class and the values478 are their corresponding human-readable names. These attributes479 correspond to the entries that are common to all field dictionaries as480 specified in the PDF 1.7 reference.481 482 Returns:483 A dictionary containing attribute keys and their names.484 485 """486 return {487 cls.FT: "Field Type",488 cls.Parent: "Parent",489 cls.T: "Field Name",490 cls.TU: "Alternate Field Name",491 cls.TM: "Mapping Name",492 cls.Ff: "Field Flags",493 cls.V: "Value",494 cls.DV: "Default Value",495 }496 497 498class CheckboxRadioButtonAttributes:499 """Table 8.76 Field flags common to all field types."""500 501 Opt = "/Opt" # Options, Optional502 503 @classmethod504 def attributes(cls) -> tuple[str, ...]:505 """506 Get a tuple of all the attributes present in a Field Dictionary.507 508 This method returns a tuple of all the attribute constants defined in509 the CheckboxRadioButtonAttributes class. These attributes correspond to510 the entries that are common to all field dictionaries as specified in511 the PDF 1.7 reference.512 513 Returns:514 A tuple containing all the attribute constants.515 516 """517 return (cls.Opt,)518 519 @classmethod520 def attributes_dict(cls) -> dict[str, str]:521 """522 Get a dictionary of attribute keys and their human-readable names.523 524 This method returns a dictionary where the keys are the attribute525 constants defined in the CheckboxRadioButtonAttributes class and the526 values are their corresponding human-readable names. These attributes527 correspond to the entries that are common to all field dictionaries as528 specified in the PDF 1.7 reference.529 530 Returns:531 A dictionary containing attribute keys and their names.532 533 """534 return {535 cls.Opt: "Options",536 }537 538 539class FieldFlag(IntFlag):540 """Table 8.70 Field flags common to all field types."""541 542 READ_ONLY = 1543 REQUIRED = 2544 NO_EXPORT = 4545 546 547class DocumentInformationAttributes:548 """Table 10.2 Entries in the document information dictionary."""549 550 TITLE = "/Title" # text string, optional551 AUTHOR = "/Author" # text string, optional552 SUBJECT = "/Subject" # text string, optional553 KEYWORDS = "/Keywords" # text string, optional554 CREATOR = "/Creator" # text string, optional555 PRODUCER = "/Producer" # text string, optional556 CREATION_DATE = "/CreationDate" # date, optional557 MOD_DATE = "/ModDate" # date, optional558 TRAPPED = "/Trapped" # name, optional559 560 561class PageLayouts:562 """563 Page 84, PDF 1.4 reference.564 Page 115, PDF 2.0 reference.565 """566 567 SINGLE_PAGE = "/SinglePage"568 ONE_COLUMN = "/OneColumn"569 TWO_COLUMN_LEFT = "/TwoColumnLeft"570 TWO_COLUMN_RIGHT = "/TwoColumnRight"571 TWO_PAGE_LEFT = "/TwoPageLeft" # (PDF 1.5)572 TWO_PAGE_RIGHT = "/TwoPageRight" # (PDF 1.5)573 574 575class GraphicsStateParameters:576 """Table 58 – Entries in a Graphics State Parameter Dictionary"""577 578 TYPE = "/Type" # name, optional579 LW = "/LW" # number, optional580 LC = "/LC" # integer, optional581 LJ = "/LJ" # integer, optional582 ML = "/ML" # number, optional583 D = "/D" # array, optional584 RI = "/RI" # name, optional585 OP = "/OP"586 op = "/op"587 OPM = "/OPM"588 FONT = "/Font" # array, optional589 BG = "/BG"590 BG2 = "/BG2"591 UCR = "/UCR"592 UCR2 = "/UCR2"593 TR = "/TR"594 TR2 = "/TR2"595 HT = "/HT"596 FL = "/FL"597 SM = "/SM"598 SA = "/SA"599 BM = "/BM"600 S_MASK = "/SMask" # dictionary or name, optional601 CA = "/CA"602 ca = "/ca"603 AIS = "/AIS"604 TK = "/TK"605 606 607class CatalogDictionary:608 """§7.7.2 of the 1.7 and 2.0 references."""609 610 TYPE = "/Type" # name, required; must be /Catalog611 VERSION = "/Version" # name612 EXTENSIONS = "/Extensions" # dictionary, optional; ISO 32000-1613 PAGES = "/Pages" # dictionary, required614 PAGE_LABELS = "/PageLabels" # number tree, optional615 NAMES = "/Names" # dictionary, optional616 DESTS = "/Dests" # dictionary, optional617 VIEWER_PREFERENCES = "/ViewerPreferences" # dictionary, optional618 PAGE_LAYOUT = "/PageLayout" # name, optional619 PAGE_MODE = "/PageMode" # name, optional620 OUTLINES = "/Outlines" # dictionary, optional621 THREADS = "/Threads" # array, optional622 OPEN_ACTION = "/OpenAction" # array or dictionary or name, optional623 AA = "/AA" # dictionary, optional624 URI = "/URI" # dictionary, optional625 ACRO_FORM = "/AcroForm" # dictionary, optional626 METADATA = "/Metadata" # stream, optional627 STRUCT_TREE_ROOT = "/StructTreeRoot" # dictionary, optional628 MARK_INFO = "/MarkInfo" # dictionary, optional629 LANG = "/Lang" # text string, optional630 SPIDER_INFO = "/SpiderInfo" # dictionary, optional631 OUTPUT_INTENTS = "/OutputIntents" # array, optional632 PIECE_INFO = "/PieceInfo" # dictionary, optional633 OC_PROPERTIES = "/OCProperties" # dictionary, optional634 PERMS = "/Perms" # dictionary, optional635 LEGAL = "/Legal" # dictionary, optional636 REQUIREMENTS = "/Requirements" # array, optional637 COLLECTION = "/Collection" # dictionary, optional638 NEEDS_RENDERING = "/NeedsRendering" # boolean, optional639 DSS = "/DSS" # dictionary, optional640 AF = "/AF" # array of dictionaries, optional641 D_PART_ROOT = "/DPartRoot" # dictionary, optional642 643 644class OutlineFontFlag(IntFlag):645 """A class used as an enumerable flag for formatting an outline font."""646 647 italic = 1648 bold = 2649 650 651class PageLabelStyle:652 """653 Table 8.10 in the 1.7 reference.654 Table 161 in the 2.0 reference.655 """656 657 DECIMAL = "/D" # Decimal Arabic numerals658 UPPERCASE_ROMAN = "/R" # Uppercase Roman numerals659 LOWERCASE_ROMAN = "/r" # Lowercase Roman numerals660 UPPERCASE_LETTER = "/A" # Uppercase letters661 LOWERCASE_LETTER = "/a" # Lowercase letters662 663 664class AnnotationFlag(IntFlag):665 """See §12.5.3 "Annotation Flags"."""666 667 INVISIBLE = 1668 HIDDEN = 2669 PRINT = 4670 NO_ZOOM = 8671 NO_ROTATE = 16672 NO_VIEW = 32673 READ_ONLY = 64674 LOCKED = 128675 TOGGLE_NO_VIEW = 256676 LOCKED_CONTENTS = 512677 678 679PDF_KEYS = (680 AnnotationDictionaryAttributes,681 CatalogAttributes,682 CatalogDictionary,683 CcittFaxDecodeParameters,684 CheckboxRadioButtonAttributes,685 ColorSpaces,686 Core,687 DocumentInformationAttributes,688 EncryptionDictAttributes,689 FieldDictionaryAttributes,690 FileSpecificationDictionaryEntries,691 FilterTypeAbbreviations,692 FilterTypes,693 GoToActionArguments,694 GraphicsStateParameters,695 ImageAttributes,696 InteractiveFormDictEntries,697 LzwFilterParameters,698 PageAttributes,699 PageLayouts,700 PagesAttributes,701 Resources,702 StreamAttributes,703 TrailerKeys,704 TypArguments,705 TypFitArguments,706)707 708 709class ImageType(IntFlag):710 NONE = 0711 XOBJECT_IMAGES = auto()712 INLINE_IMAGES = auto()713 DRAWING_IMAGES = auto()714 ALL = XOBJECT_IMAGES | INLINE_IMAGES | DRAWING_IMAGES715 IMAGES = ALL # for consistency with ObjectDeletionFlag716 717 718_INLINE_IMAGE_VALUE_MAPPING = {719 "/G": "/DeviceGray",720 "/RGB": "/DeviceRGB",721 "/CMYK": "/DeviceCMYK",722 "/I": "/Indexed",723 "/AHx": "/ASCIIHexDecode",724 "/A85": "/ASCII85Decode",725 "/LZW": "/LZWDecode",726 "/Fl": "/FlateDecode",727 "/RL": "/RunLengthDecode",728 "/CCF": "/CCITTFaxDecode",729 "/DCT": "/DCTDecode",730 "/DeviceGray": "/DeviceGray",731 "/DeviceRGB": "/DeviceRGB",732 "/DeviceCMYK": "/DeviceCMYK",733 "/Indexed": "/Indexed",734 "/ASCIIHexDecode": "/ASCIIHexDecode",735 "/ASCII85Decode": "/ASCII85Decode",736 "/LZWDecode": "/LZWDecode",737 "/FlateDecode": "/FlateDecode",738 "/RunLengthDecode": "/RunLengthDecode",739 "/CCITTFaxDecode": "/CCITTFaxDecode",740 "/DCTDecode": "/DCTDecode",741 "/RelativeColorimetric": "/RelativeColorimetric",742}743 744_INLINE_IMAGE_KEY_MAPPING = {745 "/BPC": "/BitsPerComponent",746 "/CS": "/ColorSpace",747 "/D": "/Decode",748 "/DP": "/DecodeParms",749 "/F": "/Filter",750 "/H": "/Height",751 "/W": "/Width",752 "/I": "/Interpolate",753 "/Intent": "/Intent",754 "/IM": "/ImageMask",755 "/BitsPerComponent": "/BitsPerComponent",756 "/ColorSpace": "/ColorSpace",757 "/Decode": "/Decode",758 "/DecodeParms": "/DecodeParms",759 "/Filter": "/Filter",760 "/Height": "/Height",761 "/Width": "/Width",762 "/Interpolate": "/Interpolate",763 "/ImageMask": "/ImageMask",764}765 766 767class AFRelationship:768 """769 Associated file relationship types, defining the relationship between770 the PDF component and the associated file.771 772 Defined in table 43 of the PDF 2.0 reference.773 """774 775 SOURCE = "/Source" # Original content source776 DATA = "/Data" # Base data for visual presentation777 ALTERNATIVE = "/Alternative" # Alternative content representation778 SUPPLEMENT = "/Supplement" # Supplemental representation of original source/data779 ENCRYPTED_PAYLOAD = "/EncryptedPayload" # Encrypted payload document780 FORM_DATA = "/FormData" # Data associated with AcroForm of this PDF781 SCHEMA = "/Schema" # Schema definition for associated object782 UNSPECIFIED = "/Unspecified" # Not known or cannot be described with values783 784 785class BorderStyles:786 """787 A class defining border styles used in PDF documents.788 789 Defined in table 168 of the PDF 2.0 reference.790 """791 792 BEVELED = "/B"793 DASHED = "/D"794 INSET = "/I"795 SOLID = "/S"796 UNDERLINED = "/U"797 798 799class FontFlags(IntFlag):800 """801 A class defining font flags in PDF document font descriptor resources.802 803 Defined in table 121 of the PDF 2.0 reference.804 """805 806 FIXED_PITCH = 1 << 0807 SERIF = 1 << 1808 SYMBOLIC = 1 << 2809 SCRIPT = 1 << 3810 NONSYMBOLIC = 1 << 5811 ITALIC = 1 << 6812 ALL_CAP = 1 << 16813 SMALL_CAP = 1 << 17814 FORCE_BOLD = 1 << 18815 