U
    NfR                     @   sB  d Z ddlmZmZ ddlmZmZ ddlmZ G dd dZ	G dd	 d	Z
G d
d dZG dd dZG dd deZG dd dZG dd dZG dd dZG dd dZG dd dZG dd dZG dd dZG dd dZG d d! d!ZG d"d# d#ZG d$d% d%ZG d&d' d'ZG d(d) d)ZG d*d+ d+ZG d,d- d-ZG d.d/ d/ZG d0d1 d1ZG d2d3 d3ZG d4d5 d5Z G d6d7 d7eZ!G d8d9 d9Z"G d:d; d;Z#G d<d= d=Z$G d>d? d?Z%G d@dA dAeZ&G dBdC dCZ'G dDdE dEeZ(eee%ee ee	e"eeeeee$eeeee#eeee
eefZ)G dFdG dGeZ*dHS )Ia  
See Portable Document Format Reference Manual, 1993. ISBN 0-201-62628-4.

See https://ia802202.us.archive.org/8/items/pdfy-0vt8s-egqFwDl7L2/PDF%20Reference%201.0.pdf

PDF Reference, third edition, Version 1.4, 2001. ISBN 0-201-75839-3.

PDF Reference, sixth edition, Version 1.7, 2006.
    )IntFlagauto)DictTuple   deprecate_with_replacementc                   @   s$   e Zd ZdZdZdZdZdZdZdS )Corez/Keywords that don't quite belong anywhere else.	/Outlines/Threadsz/Page/Pagesz/CatalogN)	__name__
__module____qualname____doc__OUTLINESTHREADSZPAGEPAGESZCATALOG r   r   3/tmp/pip-unpacked-wheel-zevpxvmc/pypdf/constants.pyr	      s   r	   c                   @   s    e Zd ZdZdZdZdZdZdS )TrailerKeysz/Rootz/Encrypt/IDz/Infoz/SizeN)r   r   r   ROOTZENCRYPTIDINFOZSIZEr   r   r   r   r      s
   r   c                   @   s   e Zd ZdZdZdS )CatalogAttributes/Names/DestsN)r   r   r   NAMESDESTSr   r   r   r   r   #   s   r   c                   @   s$   e Zd ZdZdZdZdZdZdZdS )EncryptionDictAttributeszo
    Additional encryption dictionary entries for the standard security handler.

    TABLE 3.19, Page 122
    /Rz/Oz/U/Pz/EncryptMetadataN)	r   r   r   r   ROUPZENCRYPT_METADATAr   r   r   r   r    (   s   r    c                   @   s   e Zd ZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!d Z"d!Z#e$e%e&d"d#d$Z'e$e%e&d"d%d&Z(e)e%e&f d'd(d)Z*e$e)e%e&f d d*d+d,Z+e$d d'd-d.Z,d/S )0UserAccessPermissionsz#TABLE 3.20 User access permissions.r                   @            i   i           @                          @             i   i   i    i   @l        )namereturnc                 C   s   | do|dd  S )z=Check if the given name corresponds to a reserved flag entry.r#   r   N)
startswithisdigitclsr@   r   r   r   _is_reservedZ   s    z"UserAccessPermissions._is_reservedc                 C   s   |dkS )z8Check if the given reserved name defaults to 1 = active.>   R2R1r   rD   r   r   r   
_is_active_   s    z UserAccessPermissions._is_activerA   c                 C   s<   i }t j D ](\}}t |r"q| |@ |k|| < q|S )zEConvert the given flag value to a corresponding verbose name mapping.)r'   __members__itemsrF   lower)selfresultr@   flagr   r   r   to_dictd   s    
zUserAccessPermissions.to_dict)valuerA   c                 C   st   |  }| d}| j D ]B\}}| |r@| |r||O }q|| d}|r||O }q|rptd||S )zAConvert the verbose name mapping to the corresponding flag value.r   FzUnknown dictionary keys: )copyrK   rL   rF   rI   poprM   
ValueError)rE   rR   Z
value_copyrO   r@   rP   Z	is_activer   r   r   	from_dictm   s    


zUserAccessPermissions.from_dictc                 C   s   | d| j  | j S )Nl    )rH   rG   rE   r   r   r   all   s    zUserAccessPermissions.allN)-r   r   r   r   rH   rG   PRINTZMODIFYZEXTRACTZADD_OR_MODIFYZR7ZR8ZFILL_FORM_FIELDSZEXTRACT_TEXT_AND_GRAPHICSZASSEMBLE_DOCZPRINT_TO_REPRESENTATIONZR13ZR14ZR15ZR16ZR17ZR18ZR19ZR20ZR21ZR22ZR23ZR24ZR25ZR26ZR27ZR28ZR29ZR30ZR31ZR32classmethodstrboolrF   rI   r   rQ   rV   rX   r   r   r   r   r'   6   sT   	r'   c                   @   s0   e Zd ZdZdZdZdZdZdZdZ	dZ
d	Zd
S )	ResourceszP
    TABLE 3.30 Entries in a resource dictionary.
    used to be Ressources
    
/ExtGState/ColorSpace/Pattern/Shading/XObject/Font/ProcSet/PropertiesN)r   r   r   r   EXT_G_STATECOLOR_SPACEPATTERNSHADINGXOBJECTFONTPROC_SET
PROPERTIESr   r   r   r   r]      s   r]   c                   @   s   e Zd ZdZeeedddZeeedddZeeedddZ	eeedd	d
Z
eeedddZeeedddZeeedddZeeedddZdS )
RessourceszE
    Use :class: `Resources` instead.

    .. deprecated:: 5.0.0
    rJ   c                 C   s   t ddd dS )Nrn   r]   5.0.0r^   r   rW   r   r   r   rf      s    zRessources.EXT_G_STATEc                 C   s   t ddd dS )Nrn   r]   ro   r_   r   rW   r   r   r   rg      s    zRessources.COLOR_SPACEc                 C   s   t ddd dS )Nrn   r]   ro   r`   r   rW   r   r   r   rh      s    zRessources.PATTERNc                 C   s   t ddd dS )Nrn   r]   ro   ra   r   rW   r   r   r   ri      s    zRessources.SHADINGc                 C   s   t ddd dS )Nrn   r]   ro   rb   r   rW   r   r   r   rj      s    zRessources.XOBJECTc                 C   s   t ddd dS )Nrn   r]   ro   rc   r   rW   r   r   r   rk      s    zRessources.FONTc                 C   s   t ddd dS )Nrn   r]   ro   rd   r   rW   r   r   r   rl      s    zRessources.PROC_SETc                 C   s   t ddd dS )Nrn   r]   ro   re   r   rW   r   r   r   rm      s    zRessources.PROPERTIESN)r   r   r   r   rZ   propertyr[   rf   rg   rh   ri   rj   rk   rl   rm   r   r   r   r   rn      s2   rn   c                   @   s    e Zd ZdZdZdZdZdZdS )PagesAttributesz$Page Attributes, Table 6.2, Page 52./Type/Kidsz/Count/ParentN)r   r   r   r   TYPEZKIDSZCOUNTPARENTr   r   r   r   rq      s
   rq   c                   @   s   e Zd ZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dS ) PageAttributesz$TABLE 3.27 Entries in a page object.rr   rt   z/LastModifiedz
/Resourcesz	/MediaBoxz/CropBoxz	/BleedBoxz/TrimBoxz/ArtBoxz/BoxColorInfo	/Contentsz/Rotatez/Groupz/Thumbz/Bz/Durz/Transz/Annots/AA	/Metadata
/PieceInfoz/StructParentsr   z/PZz/Tabsz/TemplateInstantiatedz
/PresStepsz	/UserUnitz/VPN)!r   r   r   r   ru   rv   ZLAST_MODIFIEDZ	RESOURCESZMEDIABOXZCROPBOXZBLEEDBOXZTRIMBOXZARTBOXZBOX_COLOR_INFOZCONTENTSZROTATEZGROUPZTHUMBBZDURZTRANSZANNOTSAAMETADATA
PIECE_INFOZSTRUCT_PARENTSr   ZPZZTABSZTEMPLATE_INSTANTIATEDZ
PRES_STEPSZ	USER_UNITZVPr   r   r   r   rw      s>   rw   c                   @   sD   e Zd ZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZdZdZdZdS )"FileSpecificationDictionaryEntriesz6TABLE 3.41 Entries in a file specification dictionary.rr   z/FS/Fz/UFz/DOSz/Macz/Unixr   /Vz/EFz/RFz/Descz/ClN)r   r   r   r   TypeZFSFZUFZDOSZMacZUnixr   VZEFZRFZDESCZClr   r   r   r   r      s   r   c                   @   s   e Zd ZdZdZdZdZdS )StreamAttributesz
Table 4.2.z/Lengthz/Filterz/DecodeParmsN)r   r   r   r   ZLENGTHZFILTERZDECODE_PARMSr   r   r   r   r     s   r   c                   @   s0   e Zd ZdZdZdZdZdZdZdZ	dZ
d	Zd
S )FilterTypeszF
    Table 4.3 of the 1.4 Manual.

    Page 354 of the 1.7 Manual
    z/ASCIIHexDecodez/ASCII85Decodez
/LZWDecodez/FlateDecodez/RunLengthDecodez/CCITTFaxDecodez
/DCTDecodez
/JPXDecodeN)r   r   r   r   ZASCII_HEX_DECODEZASCII_85_DECODEZ
LZW_DECODEZFLATE_DECODEZRUN_LENGTH_DECODEZCCITT_FAX_DECODEZ
DCT_DECODEZ
JPX_DECODEr   r   r   r   r     s   r   c                   @   s,   e Zd ZdZdZdZdZdZdZdZ	dZ
d	S )
FilterTypeAbbreviationsz*Table 4.44 of the 1.7 Manual (page 353ff).z/AHxz/A85z/LZWz/Flz/RLz/CCFz/DCTN)r   r   r   r   ZAHxZA85ZLZWFLZRLZCCFZDCTr   r   r   r   r   $  s   r   c                   @   s$   e Zd ZdZdZdZdZdZdZdS )LzwFilterParametersz
Table 4.4.z
/Predictor/Columnsz/Colors/BitsPerComponentz/EarlyChangeN)	r   r   r   r   Z	PREDICTORCOLUMNSCOLORSBITS_PER_COMPONENTZEARLY_CHANGEr   r   r   r   r   0  s   r   c                   @   s0   e Zd ZdZdZdZdZdZdZdZ	dZ
d	Zd
S )CcittFaxDecodeParametersz
Table 4.5.z/Kz
/EndOfLinez/EncodedByteAlignr   z/Rowsz/EndOfBlockz	/BlackIs1z/DamagedRowsBeforeErrorN)r   r   r   r   KZEND_OF_LINEZENCODED_BYTE_ALIGNr   ZROWSZEND_OF_BLOCKZ
BLACK_IS_1ZDAMAGED_ROWS_BEFORE_ERRORr   r   r   r   r   :  s   r   c                   @   sD   e Zd ZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZdZdZdZdS )ImageAttributesz&Table 4.39 Pdf Reference 1.7 page 340+rr   /Subtypez/Namez/Widthz/Heightr   r_   z/Decodez/Intentz/Interpolatez
/ImageMaskz/Mask/SMaskN)r   r   r   r   ru   ZSUBTYPENAMEZWIDTHZHEIGHTr   rg   ZDECODEZINTENTZINTERPOLATEZ
IMAGE_MASKMASKS_MASKr   r   r   r   r   G  s   r   c                   @   s   e Zd ZdZdZdZdS )ColorSpacesz
/DeviceRGBz/DeviceCMYKz/DeviceGrayN)r   r   r   Z
DEVICE_RGBZDEVICE_CMYKZDEVICE_GRAYr   r   r   r   r   Y  s   r   c                   @   s    e Zd ZdZdZdZdZdZdS )TypArguments#Table 8.2 of the PDF 1.7 reference.z/Leftz/Rightz/Bottomz/TopN)r   r   r   r   LEFTRIGHTZBOTTOMZTOPr   r   r   r   r   _  s
   r   c                   @   s0   e Zd ZdZdZdZdZdZdZdZ	dZ
d	Zd
S )TypFitArgumentsr   z/Fitz/FitVz/FitBVz/FitBz/FitHz/FitBHz/FitRz/XYZN)r   r   r   r   ZFITZFIT_VZFIT_BVZFIT_BZFIT_HZFIT_BHZFIT_RZXYZr   r   r   r   r   h  s   r   c                   @   s   e Zd ZdZdZdS )GoToActionArgumentsz/S/DN)r   r   r   SDr   r   r   r   r   u  s   r   c                   @   sL   e Zd ZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZdZdZdZdZdZdS )AnnotationDictionaryAttributesz9TABLE 8.15 Entries common to all annotation dictionaries.rr   r   z/Rectrx   r"   z/NMz/Mr   z/APz/AS/DAz/Borderz/Cz/StructParentz/OCN)r   r   r   r   r   ZSubtypeZRectZContentsr&   ZNMMr   ZAPZASDAZBorderCZStructParentZOCr   r   r   r   r   z  s    r   c                   @   s,   e Zd ZdZdZdZdZdZdZdZ	dZ
d	S )
InteractiveFormDictEntriesz/Fieldsz/NeedAppearancesz	/SigFlagsz/COz/DRr   z/Qz/XFAN)r   r   r   ZFieldsZNeedAppearancesZSigFlagsZCOZDRr   QZXFAr   r   r   r   r     s   r   c                   @   s~   e Zd ZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZdZG dd dZeeedf dddZeeeef dddZdS )FieldDictionaryAttributeszHTABLE 8.69 Entries common to all field dictionaries (PDF 1.7 reference).z/FTrt   rs   z/Tz/TUz/TMz/Ffr   z/DVry   /Optc                   @   sX   e Zd ZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZdZdZdZdZdZdZdZdZdS )z FieldDictionaryAttributes.FfBitsr   r(   r)   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   N)r   r   r   ZReadOnlyZRequiredZNoExportZ	MultilineZPasswordZNoToggleToOffZRadioZ
PushbuttonZComboZEditZSortZ
FileSelectZMultiSelectZDoNotSpellCheckZDoNotScrollZCombZRadiosInUnisonZRichTextZCommitOnSelChanger   r   r   r   FfBits  s&   r   .rJ   c              
   C   s,   | j | j| j| j| j| j| j| j| j| j	f
S )a  
        Get a tuple of all the attributes present in a Field Dictionary.

        This method returns a tuple of all the attribute constants defined in
        the FieldDictionaryAttributes class. These attributes correspond to the
        entries that are common to all field dictionaries as specified in the
        PDF 1.7 reference.

        Returns:
            A tuple containing all the attribute constants.
        )
TMTFTParentTUFfr   DVKidsr}   rW   r   r   r   
attributes  s    z$FieldDictionaryAttributes.attributesc                 C   s4   | j d| jd| jd| jd| jd| jd| jd| jdiS )	a  
        Get a dictionary of attribute keys and their human-readable names.

        This method returns a dictionary where the keys are the attribute
        constants defined in the FieldDictionaryAttributes class and the values
        are their corresponding human-readable names. These attributes
        correspond to the entries that are common to all field dictionaries as
        specified in the PDF 1.7 reference.

        Returns:
            A dictionary containing attribute keys and their names.
        z
Field Typer   z
Field NamezAlternate Field NamezMapping NamezField FlagsValuezDefault Value)r   r   r   r   r   r   r   r   rW   r   r   r   attributes_dict  s"            z)FieldDictionaryAttributes.attributes_dictN)r   r   r   r   r   r   r   r   r   r   r   r   r   r}   Optr   rZ   r   r[   r   r   r   r   r   r   r   r     s"   r   c                   @   sH   e Zd ZdZdZeeedf dddZee	eef dddZ
d	S )
CheckboxRadioButtonAttributesz1TABLE 8.76 Field flags common to all field types.r   .rJ   c                 C   s   | j fS )a  
        Get a tuple of all the attributes present in a Field Dictionary.

        This method returns a tuple of all the attribute constants defined in
        the CheckboxRadioButtonAttributes class. These attributes correspond to
        the entries that are common to all field dictionaries as specified in
        the PDF 1.7 reference.

        Returns:
            A tuple containing all the attribute constants.
        r   rW   r   r   r   r     s    z(CheckboxRadioButtonAttributes.attributesc                 C   s
   | j diS )a  
        Get a dictionary of attribute keys and their human-readable names.

        This method returns a dictionary where the keys are the attribute
        constants defined in the CheckboxRadioButtonAttributes class and the
        values are their corresponding human-readable names. These attributes
        correspond to the entries that are common to all field dictionaries as
        specified in the PDF 1.7 reference.

        Returns:
            A dictionary containing attribute keys and their names.
        Optionsr   rW   r   r   r   r     s     z-CheckboxRadioButtonAttributes.attributes_dictN)r   r   r   r   r   rZ   r   r[   r   r   r   r   r   r   r   r     s   r   c                   @   s   e Zd ZdZdZdZdZdS )	FieldFlagz1TABLE 8.70 Field flags common to all field types.r   r(   r)   N)r   r   r   r   	READ_ONLYZREQUIREDZ	NO_EXPORTr   r   r   r   r      s   r   c                   @   s4   e Zd ZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdS )DocumentInformationAttributesz:TABLE 10.2 Entries in the document information dictionary.z/Titlez/Authorz/Subjectz	/Keywordsz/Creatorz	/Producerz/CreationDatez/ModDatez/TrappedN)r   r   r   r   ZTITLEZAUTHORZSUBJECTZKEYWORDSZCREATORZPRODUCERZCREATION_DATEZMOD_DATEZTRAPPEDr   r   r   r   r   (  s   r   c                   @   s    e Zd ZdZdZdZdZdZdS )PageLayoutszPage 84, PDF 1.4 reference.z/SinglePagez
/OneColumnz/TwoColumnLeftz/TwoColumnRightN)r   r   r   r   ZSINGLE_PAGEZ
ONE_COLUMNZTWO_COLUMN_LEFTZTWO_COLUMN_RIGHTr   r   r   r   r   6  s
   r   c                   @   s|   e Zd ZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdS )GraphicsStateParametersu=   Table 58 – Entries in a Graphics State Parameter Dictionaryrr   z/LWz/LCz/LJz/MLr   z/RIz/OPz/opz/OPMrc   z/BGz/BG2z/UCRz/UCR2z/TRz/TR2z/HTz/FLz/SMz/SAz/BMr   z/CAz/caz/AISz/TKN)r   r   r   r   ru   ZLWZLCZLJZMLr   ZRIOPopZOPMrk   ZBGZBG2ZUCRZUCR2ZTRZTR2ZHTr   ZSMZSAZBMr   CAcaZAISZTKr   r   r   r   r   ?  s8   r   c                   @   s   e Zd ZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdS )CatalogDictionaryz Table 3.25 in the 1.7 reference.rr   z/Versionr   z/PageLabelsr   r   z/ViewerPreferencesz/PageLayoutz	/PageModer
   r   z/OpenActionry   z/URIz	/AcroFormrz   z/StructTreeRootz	/MarkInfoz/Langz/SpiderInfoz/OutputIntentsr{   z/OCPropertiesz/Permsz/Legalz/Requirementsz/Collectionz/NeedsRenderingN) r   r   r   r   ru   VERSIONr   ZPAGE_LABELSr   r   ZVIEWER_PREFERENCESZPAGE_LAYOUTZ	PAGE_MODEr   r   ZOPEN_ACTIONr}   URIZ	ACRO_FORMr~   ZSTRUCT_TREE_ROOTZ	MARK_INFOLANGZSPIDER_INFOZOUTPUT_INTENTSr   ZOC_PROPERTIESZPERMSZLEGALZREQUIREMENTSZ
COLLECTIONZNEEDS_RENDERINGr   r   r   r   r   _  s:   r   c                   @   s   e Zd ZdZdZdZdS )OutlineFontFlagzBA class used as an enumerable flag for formatting an outline font.r   r(   N)r   r   r   r   ZitalicZboldr   r   r   r   r     s   r   c                   @   s$   e Zd ZdZdZdZdZdZdZdS )PageLabelStylez Table 8.10 in the 1.7 reference.r   z/rr!   z/az/AN)	r   r   r   r   ZDECIMALZLOWERCASE_ROMANZUPPERCASE_ROMANZLOWERCASE_LETTERZUPPERCASE_LETTERr   r   r   r   r     s   r   c                   @   s8   e Zd ZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZdS )AnnotationFlagzSee 12.5.3 "Annotation Flags".r   r(   r)   r*   r+   r,   r-   r.   r/   r0   N)r   r   r   r   Z	INVISIBLEZHIDDENrY   ZNO_ZOOMZ	NO_ROTATEZNO_VIEWr   LOCKEDZTOGGLE_NO_VIEWZLOCKED_CONTENTSr   r   r   r   r     s   r   c                   @   s2   e Zd ZdZe Ze Ze ZeeB eB ZeZ	dS )	ImageTyper   N)
r   r   r   NONEr   ZXOBJECT_IMAGESZINLINE_IMAGESZDRAWING_IMAGESALLZIMAGESr   r   r   r   r     s   r   N)+r   enumr   r   typingr   r   _utilsr   r	   r   r   r    r'   r]   rn   rq   rw   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   ZPDF_KEYSr   r   r   r   r   <module>   s|   

N8	$
	`'	 !
