o
    >eK                     @   s(  d Z ddlmZmZ ddlmZ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 d.d/ d/ZG d0d1 d1ZG d2d3 d3eZG d4d5 d5ZG d6d7 d7Z G d8d9 d9Z!G d:d; d;Z"G d<d= d=eZ#G d>d? d?Z$G d@dA dAe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 dBdC dCeZ'dDS )Ea  
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Tuplec                   @   $   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THREADSPAGEPAGESCATALOG r   r   P/var/www/html/humari/django-venv/lib/python3.10/site-packages/pypdf/constants.pyr          r   c                   @       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   ROOTENCRYPTIDINFOSIZEr   r   r   r   r      s    r   c                   @      e Zd ZdZdZdS )CatalogAttributes/Names/DestsN)r   r   r   NAMESDESTSr   r   r   r   r    !       r    c                   @   r   )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P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UserAccessPermissionsz#TABLE 3.20 User access permissions.                   @            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clsrH   r   r   r   _is_reservedX   s   z"UserAccessPermissions._is_reservedc                 C   s   |dvS )z8Check if the given reserved name defaults to 1 = active.>   R1R2r   rL   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__itemsrN   lower)selfresultrH   flagr   r   r   to_dictb   s   
zUserAccessPermissions.to_dictvaluec                 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: )copyrR   rS   rN   rQ   poprT   
ValueError)rM   rY   
value_copyrV   rH   rW   	is_activer   r   r   	from_dictk   s   

zUserAccessPermissions.from_dictc                 C   s   | d| j  | j S )Nl    )rO   rP   rM   r   r   r   all}   s   zUserAccessPermissions.allN)rI   r.   )-r   r   r   r   rO   rP   PRINTMODIFYEXTRACTADD_OR_MODIFYR7R8FILL_FORM_FIELDSEXTRACT_TEXT_AND_GRAPHICSASSEMBLE_DOCPRINT_TO_REPRESENTATIONR13R14R15R16R17R18R19R20R21R22R23R24R25R26R27R28R29R30R31R32classmethodstrboolrN   rQ   r   rX   r_   ra   r   r   r   r   r.   4   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 )
Ressourcesz,TABLE 3.30 Entries in a resource dictionary.z
/ExtGState/ColorSpacez/Patternz/Shadingz/XObject/Fontz/ProcSetz/PropertiesN)r   r   r   r   EXT_G_STATECOLOR_SPACEPATTERNSHADINGXOBJECTFONTPROC_SET
PROPERTIESr   r   r   r   r          r   c                   @   r   )PagesAttributesz$Page Attributes, Table 6.2, Page 52./Type/Kidsz/Count/ParentN)r   r   r   r   TYPEKIDSCOUNTPARENTr   r   r   r   r          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S ) PageAttributesz$TABLE 3.27 Entries in a page object.r   r   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   r   r   LAST_MODIFIED	RESOURCESMEDIABOXCROPBOXBLEEDBOXTRIMBOXARTBOXBOX_COLOR_INFOCONTENTSROTATEGROUPTHUMBBDURTRANSANNOTSAAMETADATA
PIECE_INFOSTRUCT_PARENTSr   PZTABSTEMPLATE_INSTANTIATED
PRES_STEPS	USER_UNITVPr   r   r   r   r      s@    r   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.r   z/FS/Fz/UFz/DOSz/Macz/Unixr   /Vz/EFz/RFz/Descz/ClN)r   r   r   r   TypeFSFUFDOSMacUnixr   VEFRFDESCClr   r   r   r   r          r   c                   @      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   LENGTHFILTERDECODE_PARMSr   r   r   r   r      
    r   c                   @   r   )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   ASCII_HEX_DECODEASCII_85_DECODE
LZW_DECODEFLATE_DECODERUN_LENGTH_DECODECCITT_FAX_DECODE
DCT_DECODE
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 )
FilterTypeAbbreviationsz*Table 4.44 of the 1.7 Manual (page 353ff).z/AHxz/A85z/LZWz/Flz/RLz/CCFz/DCTN)r   r   r   r   AHxA85LZWFLRLCCFDCTr   r   r   r   r      s    r   c                   @   r   )LzwFilterParametersz
Table 4.4.z
/Predictor/Columnsz/Colors/BitsPerComponentz/EarlyChangeN)	r   r   r   r   	PREDICTORCOLUMNSCOLORSBITS_PER_COMPONENTEARLY_CHANGEr   r   r   r   r      r   r   c                   @   r   )CcittFaxDecodeParametersz
Table 4.5.z/Kz
/EndOfLinez/EncodedByteAlignr   z/Rowsz/EndOfBlockz	/BlackIs1z/DamagedRowsBeforeErrorN)r   r   r   r   KEND_OF_LINEENCODED_BYTE_ALIGNr   ROWSEND_OF_BLOCK
BLACK_IS_1DAMAGED_ROWS_BEFORE_ERRORr   r   r   r   r      r   r   c                   @   r   )ImageAttributesz&Table 4.39 Pdf Reference 1.7 page 340+r   /Subtypez/Namez/Widthz/Heightr   r   z/Decodez/Intentz/Interpolatez
/ImageMaskz/Mask/SMaskN)r   r   r   r   r   SUBTYPENAMEWIDTHHEIGHTr   r   DECODEINTENTINTERPOLATE
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   
DEVICE_RGBDEVICE_CMYKDEVICE_GRAYr   r   r   r   r     s    r   c                   @   r   )TypArguments#Table 8.2 of the PDF 1.7 reference.z/Leftz/Rightz/Bottomz/TopN)r   r   r   r   LEFTRIGHTBOTTOMTOPr   r   r   r   r  "  r   r  c                   @   r   )TypFitArgumentsr  z/Fitz/FitVz/FitBVz/FitBz/FitHz/FitBHz/FitRz/XYZN)r   r   r   r   FITFIT_VFIT_BVFIT_BFIT_HFIT_BHFIT_RXYZr   r   r   r   r	  +  r   r	  c                   @   r   )GoToActionArgumentsz/S/DN)r   r   r   SDr   r   r   r   r  8  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.r   r   z/Rectr   r(   z/NMz/Mr   z/APz/AS/DAz/Borderz/Cz/StructParentz/OCN)r   r   r   r   r   SubtypeRectContentsr,   NMMr   APASDABorderCStructParentOCr   r   r   r   r  =  s"    r  c                   @   r   )
InteractiveFormDictEntriesz/Fieldsz/NeedAppearancesz	/SigFlagsz/COz/DRr  z/Qz/XFAN)r   r   r   FieldsNeedAppearancesSigFlagsCODRr  QXFAr   r   r   r   r$  Q  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deedf fddZedeeef fddZdS )FieldDictionaryAttributeszHTABLE 8.69 Entries common to all field dictionaries (PDF 1.7 reference).z/FTr   r   z/Tz/TUz/TMz/Ffr   z/DVr   /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/   r0   r1   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   N)r   r   r   ReadOnlyRequiredNoExport	MultilinePasswordNoToggleToOffRadio
PushbuttonComboEditSort
FileSelectMultiSelectDoNotSpellCheckDoNotScrollCombRadiosInUnisonRichTextCommitOnSelChanger   r   r   r   FfBitsk  s(    rA  rI   .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   r`   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 TyperE  z
Field NamezAlternate Field NamezMapping NamezField FlagsValuezDefault Value)rD  rE  rC  rF  rB  rG  r   rH  r`   r   r   r   attributes_dict  s   z)FieldDictionaryAttributes.attributes_dictN)r   r   r   r   rD  rE  rI  rC  rF  rB  rG  r   rH  r   OptrA  r   r   r   rJ  r   rL  r   r   r   r   r,  \  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-  rI   .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.
        rM  r`   r   r   r   rJ    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.
        OptionsrO  r`   r   r   r   rL    s   z-CheckboxRadioButtonAttributes.attributes_dictN)r   r   r   r   rM  r   r   r   rJ  r   rL  r   r   r   r   rN    s    rN  c                   @   r   )	FieldFlagz1TABLE 8.70 Field flags common to all field types.r/   r0   r1   N)r   r   r   r   	READ_ONLYREQUIRED	NO_EXPORTr   r   r   r   rQ    r   rQ  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   TITLEAUTHORSUBJECTKEYWORDSCREATORPRODUCERCREATION_DATEMOD_DATETRAPPEDr   r   r   r   rU    s    rU  c                   @   r   )PageLayoutszPage 84, PDF 1.4 reference.z/SinglePagez
/OneColumnz/TwoColumnLeftz/TwoColumnRightN)r   r   r   r   SINGLE_PAGE
ONE_COLUMNTWO_COLUMN_LEFTTWO_COLUMN_RIGHTr   r   r   r   r_    r   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 Dictionaryr   z/LWz/LCz/LJz/MLr  z/RIz/OPz/opz/OPMr   z/BGz/BG2z/UCRz/UCR2z/TRz/TR2z/HTz/FLz/SMz/SAz/BMr   z/CAz/caz/AISz/TKN)r   r   r   r   r   LWLCLJMLr  RIOPopOPMr   BGBG2UCRUCR2TRTR2HTr   SMSABMr   CAcaAISTKr   r   r   r   rd    s:    rd  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.r   z/Versionr
   z/PageLabelsr!   r"   z/ViewerPreferencesz/PageLayoutz	/PageModer   r	   z/OpenActionr   z/URIz	/AcroFormr   z/StructTreeRootz	/MarkInfoz/Langz/SpiderInfoz/OutputIntentsr   z/OCPropertiesz/Permsz/Legalz/Requirementsz/Collectionz/NeedsRenderingN) r   r   r   r   r   VERSIONr   PAGE_LABELSr#   r$   VIEWER_PREFERENCESPAGE_LAYOUT	PAGE_MODEr   r   OPEN_ACTIONr   URI	ACRO_FORMr   STRUCT_TREE_ROOT	MARK_INFOLANGSPIDER_INFOOUTPUT_INTENTSr   OC_PROPERTIESPERMSLEGALREQUIREMENTS
COLLECTIONNEEDS_RENDERINGr   r   r   r   r{  "  s<    r{  c                   @   r   )OutlineFontFlagzBA class used as an enumerable flag for formatting an outline font.r/   r0   N)r   r   r   r   italicboldr   r   r   r   r  C  s    r  c                   @   r   )PageLabelStylez Table 8.10 in the 1.7 reference.r  z/rr'   z/az/AN)	r   r   r   r   DECIMALLOWERCASE_ROMANUPPERCASE_ROMANLOWERCASE_LETTERUPPERCASE_LETTERr   r   r   r   r  J  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 )AnnotationFlagzSee 12.5.3 "Annotation Flags".r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   N)r   r   r   r   	INVISIBLEHIDDENrb   NO_ZOOM	NO_ROTATENO_VIEWrR  LOCKEDTOGGLE_NO_VIEWLOCKED_CONTENTSr   r   r   r   r  T  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   XOBJECT_IMAGESINLINE_IMAGESDRAWING_IMAGESALLIMAGESr   r   r   r   r    s    r  N)(r   enumr   r   typingr   r   r   r   r    r&   r.   r   r   r   r   r   r   r   r   r   r   r   r  r	  r  r  r$  r,  rN  rQ  rU  r_  rd  r{  r  r  r  PDF_KEYSr  r   r   r   r   <module>   sz    

N	$
	`'	 !
