o
     ZhR                     @   sX  d Z ddlmZmZmZmZ ddlmZmZ G dd de	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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e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 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efZ+G dFdG dGeZ,dHS )Iz7Various constants, enums, and flags to aid readability.    )EnumIntFlagautounique)DictTuplec                   @   s   e Zd ZdefddZdS )StrEnumreturnc                 C   s
   t | jS )N)strvalue)self r   F/var/www/html/lang_env/lib/python3.10/site-packages/pypdf/constants.py__str__   s   
zStrEnum.__str__N)__name__
__module____qualname__r
   r   r   r   r   r   r      s    r   c                   @   $   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)	r   r   r   __doc__OUTLINESTHREADSZPAGEPAGESZCATALOGr   r   r   r   r      s    r   c                   @   r   )TrailerKeysz/Sizez/Prevz/Rootz/Encryptz/Info/IDN)	r   r   r   ZSIZEZPREVROOTZENCRYPTINFOIDr   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                   @   r   )EncryptionDictAttributesz
    Additional encryption dictionary entries for the standard security handler.

    Table 3.19, Page 122.
    Table 21 of the 2.0 manual.
    /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$d"e%d#e&fd$d%Z'e$d"e%d#e&fd&d'Z(d#e)e%e&f fd(d)Z*e$d*e)e%e&f d#d fd+d,Z+e$d0d-d.Z,d/S )1UserAccessPermissionszM
    Table 3.20 User access permissions.
    Table 22 of the 2.0 manual.
                       @            i   i           @                          @             i   i   i    i   @l        namer	   c                 C   s   | do|dd  S )z=Check if the given name corresponds to a reserved flag entry.r)   r.   N)
startswithisdigitclsrG   r   r   r   _is_reservedZ   s   z"UserAccessPermissions._is_reservedc                 C   s   |dvS )z8Check if the given reserved name defaults to 1 = active.>   R2R1r   rJ   r   r   r   
_is_active_   s   z UserAccessPermissions._is_activec                 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__itemsrL   lower)r   resultrG   flagr   r   r   to_dictd   s   
zUserAccessPermissions.to_dictr   c                 C   st   |  }| d}| j D ]!\}}| |r | |r||O }q|| d}|r.||O }q|r8td||S )zAConvert the verbose name mapping to the corresponding flag value.r   FzUnknown dictionary keys: )copyrP   rQ   rL   rO   poprR   
ValueError)rK   r   Z
value_copyrS   rG   rT   Z	is_activer   r   r   	from_dictm   s   

zUserAccessPermissions.from_dictc                 C   s   | d| j  | j S )Nl    )rN   rM   rK   r   r   r   all   s   zUserAccessPermissions.allN)r	   r-   )-r   r   r   r   rN   rM   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classmethodr
   boolrL   rO   r   rU   rY   r[   r   r   r   r   r-   3   sV    	r-   c                   @   0   e Zd ZdZdZdZdZdZdZdZ	dZ
d	Zd
S )	ResourceszY
    Table 3.30 Entries in a resource dictionary.
    Table 34 in the 2.0 reference.
    z
/ExtGState/ColorSpacez/Patternz/Shadingz/XObject/Fontz/ProcSetz/PropertiesN)r   r   r   r   ZEXT_G_STATECOLOR_SPACEZPATTERNZSHADINGZXOBJECTFONTZPROC_SETZ
PROPERTIESr   r   r   r   r`          r`   c                   @   s   e Zd ZdZdS )
RessourceszE
    Use :class: `Resources` instead.

    .. deprecated:: 5.0.0
    N)r   r   r   r   r   r   r   r   rf      s    rf   c                   @       e Zd ZdZdZdZdZdZdS )PagesAttributesu'   §7.7.3.2 of the 1.7 and 2.0 reference./Type/Parent/Kidsz/CountN)r   r   r   r   TYPEPARENTZKIDSZCOUNTr   r   r   r   rh          rh   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#d"Z$d#S )$PageAttributesu'   §7.7.3.3 of the 1.7 and 2.0 reference.ri   rj   z/LastModifiedz
/Resourcesz	/MediaBoxz/CropBoxz	/BleedBoxz/TrimBoxz/ArtBoxz/BoxColorInfo	/Contentsz/Rotatez/Groupz/Thumbz/Bz/Durz/Transz/Annots/AA	/Metadata
/PieceInfoz/StructParentsr   z/PZz/SeparationInfoz/Tabsz/TemplateInstantiatedz
/PresStepsz	/UserUnitz/VP/AF/OutputIntentsz/DPartN)%r   r   r   r   rl   rm   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SEPARATION_INFOZTABSZTEMPLATE_INSTANTIATEDZ
PRES_STEPSZ	USER_UNITZVPAFOUTPUT_INTENTSZD_PARTr   r   r   r   ro      sH    ro   c                   @   D   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.ri   z/FS/Fz/UFz/DOSz/Macz/Unixr   /Vz/EFz/RFz/Descz/ClN)r   r   r   r   TypeZFSFZUFZDOSZMacUnixr    VZEFZRFZDESCZClr   r   r   r   r}          r}   c                   @      e Zd ZdZdZdZdZdS )StreamAttributesz6
    Table 4.2.
    Table 5 in the 2.0 reference.
    z/Lengthz/Filterz/DecodeParmsN)r   r   r   r   ZLENGTHZFILTERZDECODE_PARMSr   r   r   r   r      s
    r   c                   @   r_   )FilterTypesu$   §7.4 of the 1.7 and 2.0 references.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                   @   ,   e Zd ZdZdZdZdZdZdZdZ	dZ
d	S )
FilterTypeAbbreviationsu&   §8.9.7 of the 1.7 and 2.0 references.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                   @   r   )LzwFilterParametersz6
    Table 4.4.
    Table 8 in the 2.0 reference.
    z
/Predictorz/Colors/BitsPerComponent/Columnsz/EarlyChangeN)	r   r   r   r   Z	PREDICTORZCOLORSBITS_PER_COMPONENTCOLUMNSZEARLY_CHANGEr   r   r   r   r         r   c                   @   r_   )CcittFaxDecodeParametersz7
    Table 4.5.
    Table 11 in the 2.0 reference.
    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     re   r   c                   @   r|   )ImageAttributesu'   §11.6.5 of the 1.7 and 2.0 references.ri   /Subtypez/Namez/Widthz/Heightr   ra   z/Decodez/Intentz/Interpolatez
/ImageMaskz/Mask/SMaskN)r   r   r   r   rl   ZSUBTYPENAMEZWIDTHZHEIGHTr   rc   ZDECODEZINTENTZINTERPOLATEZ
IMAGE_MASKMASKS_MASKr   r   r   r   r   #  r   r   c                   @      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   5      r   c                   @   rg   )TypArguments#Table 8.2 of the PDF 1.7 reference.z/Leftz/Rightz/Bottomz/TopN)r   r   r   r   ZLEFTZRIGHTZBOTTOMZTOPr   r   r   r   r   ;  rn   r   c                   @   r_   )TypFitArgumentsr   z/XYZz/Fitz/FitHz/FitVz/FitRz/FitBz/FitBHz/FitBVN)r   r   r   r   ZXYZZFITZFIT_HZFIT_VZFIT_RZFIT_BZFIT_BHZFIT_BVr   r   r   r   r   D  s    r   c                   @   r   )GoToActionArgumentsz/S/Dz/SDN)r   r   r   SDZSDr   r   r   r   r   Q  r   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.ri   r   z/Rectrp   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   W  s"    r   c                   @   r   )
InteractiveFormDictEntriesz/Fieldsz/NeedAppearancesz	/SigFlagsz/COz/DRr   z/Qz/XFAN)r   r   r   ZFieldsZNeedAppearancesZSigFlagsZCOZDRr   QZXFAr   r   r   r   r   k  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eZedeedf fddZedeeef fddZdS )FieldDictionaryAttributesz
    Entries common to all field dictionaries (Table 8.69 PDF 1.7 reference)
    (*very partially documented here*).

    FFBits provides the constants used for `/Ff` from Table 8.70/8.75/8.77/8.79
    z/FTrj   rk   z/Tz/TUz/TMz/Ffr   z/DVrq   /Optc                   @   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S )z FieldDictionaryAttributes.FfBitsz
        Ease building /Ff flags
        Some entries may be specific to:

        * Text (Tx) (Table 8.75 PDF 1.7 reference)
        * Buttons (Btn) (Table 8.77 PDF 1.7 reference)
        * Choice (Ch) (Table 8.79 PDF 1.7 reference)
        r.   r/   r0   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   rF   N)r   r   r   r   ReadOnlyRequiredZNoExport	MultilineZPasswordZNoToggleToOffZRadioZ
PushbuttonZComboZEditZSortZ
FileSelectZMultiSelectZDoNotSpellCheckZDoNotScrollZCombZRadiosInUnisonZRichTextZCommitOnSelChanger   r   r   r   FfBits  sP    	r   r	   .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Kidsrw   rZ   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   rZ   r   r   r   attributes_dict  s   z)FieldDictionaryAttributes.attributes_dictN)r   r   r   r   r   r   r   r   r   r   r   r   r   rw   Optr   r   r]   r   r
   r   r   r   r   r   r   r   r   v  s$    :r   c                   @   sH   e Zd ZdZdZedeedf fddZede	eef fddZ
d	S )
CheckboxRadioButtonAttributesz1Table 8.76 Field flags common to all field types.r   r	   .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   rZ   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   rZ   r   r   r   r     s   z-CheckboxRadioButtonAttributes.attributes_dictN)r   r   r   r   r   r]   r   r
   r   r   r   r   r   r   r   r     s    r   c                   @   r   )	FieldFlagz1Table 8.70 Field flags common to all field types.r.   r/   r0   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SUBJECT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ZdZ	dS )	PageLayoutszF
    Page 84, PDF 1.4 reference.
    Page 115, PDF 2.0 reference.
    z/SinglePagez
/OneColumnz/TwoColumnLeftz/TwoColumnRightz/TwoPageLeftz/TwoPageRightN)
r   r   r   r   ZSINGLE_PAGEZ
ONE_COLUMNZTWO_COLUMN_LEFTZTWO_COLUMN_RIGHTZTWO_PAGE_LEFTZTWO_PAGE_RIGHTr   r   r   r   r   9  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 Dictionaryri   z/LWz/LCz/LJz/MLr   z/RIz/OPz/opz/OPMrb   z/BGz/BG2z/UCRz/UCR2z/TRz/TR2z/HTz/FLz/SMz/SAz/BMr   z/CAz/caz/AISz/TKN)r   r   r   r   rl   ZLWZLCZLJZMLr   ZRIOPopZOPMrd   ZBGZBG2ZUCRZUCR2ZTRZTR2ZHTr   ZSMZSAZBMr   CAcaZAISZTKr   r   r   r   r   G  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#d"S )#CatalogDictionaryu&   §7.7.2 of the 1.7 and 2.0 references.ri   z/Versionz/Extensionsr   z/PageLabelsr"   r#   z/ViewerPreferencesz/PageLayoutz	/PageModer   r   z/OpenActionrq   z/URIz	/AcroFormrr   z/StructTreeRootz	/MarkInfoz/Langz/SpiderInforu   rs   z/OCPropertiesz/Permsz/Legalz/Requirementsz/Collectionz/NeedsRenderingz/DSSrt   z
/DPartRootN)$r   r   r   r   rl   VERSIONZ
EXTENSIONSr   ZPAGE_LABELSr$   r%   ZVIEWER_PREFERENCESZPAGE_LAYOUTZ	PAGE_MODEr   r   ZOPEN_ACTIONrw   URIZ	ACRO_FORMrx   ZSTRUCT_TREE_ROOTZ	MARK_INFOLANGZSPIDER_INFOr{   ry   ZOC_PROPERTIESZPERMSZLEGALZREQUIREMENTSZ
COLLECTIONZNEEDS_RENDERINGZDSSrz   ZD_PART_ROOTr   r   r   r   r   g  sD    r   c                   @   r   )OutlineFontFlagzBA class used as an enumerable flag for formatting an outline font.r.   r/   N)r   r   r   r   italicboldr   r   r   r   r     s    r   c                   @   r   )PageLabelStylezN
    Table 8.10 in the 1.7 reference.
    Table 161 in the 2.0 reference.
    r   r'   z/rz/Az/aN)	r   r   r   r   ZDECIMALZUPPERCASE_ROMANZLOWERCASE_ROMANZUPPERCASE_LETTERZLOWERCASE_LETTERr   r   r   r   r     r   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 )AnnotationFlagu    See §12.5.3 "Annotation Flags".r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   N)r   r   r   r   Z	INVISIBLEZHIDDENr\   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_IMAGESZALLZIMAGESr   r   r   r   r     s    r   N)-r   enumr   r   r   r   typingr   r   r
   r   r   r   r!   r&   r-   r`   rf   rh   ro   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    
	Q(	 ) %