o
    ë6Wj–- ã                
   @   s:  d dl Z d dlZd dlZd dlZd dlmZ d dlmZ d dlmZ d dl	m
Z
mZmZmZmZmZmZmZmZ ddlmZmZ ddlmZmZ dd	lmZmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z% dd
l&m'Z( ddl&m)Z* ddl&m+Z+ ddl&m,Z- ddl&m.Z/ ddl&m0Z0m1Z1 ddl&m2Z3 ddl&m4Z5 ddl&m6Z7 ddl8m9Z9m:Z:m;Z;m<Z<m=Z= ddl>m?Z?m@Z@mAZAmBZBmCZCmDZDmEZEmFZFmGZGmHZHmIZImJZJmKZKmLZLmMZMmNZNmOZO ddlPmQZQmRZR ddlSmTZT deUdeVdeeVee
df f fdd„ZWdeUdeVdeeVee
df f fdd„ZXG dd „ d eCƒZYG d!d"„ d"ƒZZG d#d$„ d$eZƒZ[dS )%é    N)Údatetime)ÚBytesIO)ÚPath)	ÚAnyÚCallableÚDictÚIterableÚListÚOptionalÚTupleÚUnionÚcasté   )Ú
EncryptionÚPasswordType)Ú
PageObjectÚ_VirtualList)ÚStrByteTypeÚ
StreamTypeÚb_Údeprecate_no_replacementÚdeprecation_no_replacementÚdeprecation_with_replacementÚlogger_warningÚread_non_whitespaceÚread_previous_lineÚread_until_whitespaceÚskip_over_commentÚskip_over_whitespace)ÚCatalogAttributes)ÚCatalogDictionary)ÚCheckboxRadioButtonAttributes)ÚCore)ÚDocumentInformationAttributes)ÚFieldDictionaryAttributesÚGoToActionArguments)ÚPageAttributes)ÚPagesAttributes)ÚTrailerKeys)ÚEmptyFileErrorÚFileNotDecryptedErrorÚPdfReadErrorÚPdfStreamErrorÚWrongPasswordError)ÚArrayObjectÚContentStreamÚDecodedStreamObjectÚDestinationÚDictionaryObjectÚEncodedStreamObjectÚFieldÚFitÚFloatObjectÚIndirectObjectÚ
NameObjectÚ
NullObjectÚNumberObjectÚ	PdfObjectÚTextStringObjectÚ
TreeObjectÚread_object)ÚOutlineTypeÚPagemodeType)ÚXmpInformationÚdÚsizeÚreturn.c                 C   s4   |dkrt dƒ‚d|  } | dd … } t d| ¡d S )Né   zinvalid size in convert_to_ints           iøÿÿÿz>qr   )r+   ÚstructÚunpack©rB   rC   © rI   ú]/home/esfera/Documents/content_generation/venv/lib/python3.10/site-packages/PyPDF2/_reader.pyÚconvert_to_inth   s
   rK   c                 C   s   t ddƒ t| |ƒS )NÚconvertToIntrK   )r   rK   rH   rI   rI   rJ   rL   p   s   

rL   c                   @   sz  e Zd ZdZd'dd„Zdedee fdd„Zdedee fd	d
„Ze	dee fdd„ƒZ
e	dee fdd„ƒZe	dee fdd„ƒZe	dee fdd„ƒZe	dee fdd„ƒZe	dee fdd„ƒZe	dee fdd„ƒZe	dee fdd„ƒZe	dee fdd„ƒZe	dee fdd„ƒZe	dee fdd „ƒZe	dee fd!d"„ƒZe	dee fd#d$„ƒZe	dee fd%d&„ƒZdS )(ÚDocumentInformationa‚  
    A class representing the basic document metadata provided in a PDF File.
    This class is accessible through :py:class:`PdfReader.metadata<PyPDF2.PdfReader.metadata>`.

    All text properties of the document metadata have
    *two* properties, eg. author and author_raw. The non-raw property will
    always return a ``TextStringObject``, making it ideal for a case where
    the metadata is being displayed. The raw property can sometimes return
    a ``ByteStringObject``, if PyPDF2 was unable to decode the string's
    text encoding; this requires additional safety in the caller and
    therefore is not as commonly accessed.
    rD   Nc                 C   s   t  | ¡ d S ©N)r2   Ú__init__©ÚselfrI   rI   rJ   rO   …   s   zDocumentInformation.__init__Úkeyc                 C   s   |   |d ¡}t|tƒr|S d S rN   )ÚgetÚ
isinstancer<   )rQ   rR   ÚretvalrI   rI   rJ   Ú	_get_textˆ   s   
zDocumentInformation._get_textc                 C   s   t ddƒ |  |¡S )z«
        The text value of the specified key or None.

        .. deprecated:: 1.28.0

            Use the attributes (e.g. :py:attr:`title` / :py:attr:`author`).
        ÚgetTextú3.0.0)r   rV   )rQ   rR   rI   rI   rJ   rW   Ž   s   

zDocumentInformation.getTextc                 C   s,   |   tj¡r|  tj¡p|   tj¡ ¡ S dS )z´
        Read-only property accessing the document's **title**.

        Returns a unicode string (``TextStringObject``) or ``None``
        if the title is not specified.
        N)rS   ÚDIÚTITLErV   Ú
get_objectrP   rI   rI   rJ   Útitle™   s
   

ÿÿýzDocumentInformation.titlec                 C   ó   |   tj¡S )z>The "raw" version of title; can return a ``ByteStringObject``.)rS   rY   rZ   rP   rI   rI   rJ   Ú	title_raw§   ó   zDocumentInformation.title_rawc                 C   r]   )z¶
        Read-only property accessing the document's **author**.

        Returns a unicode string (``TextStringObject``) or ``None``
        if the author is not specified.
        )rV   rY   ÚAUTHORrP   rI   rI   rJ   Úauthor¬   ó   zDocumentInformation.authorc                 C   r]   )z?The "raw" version of author; can return a ``ByteStringObject``.)rS   rY   r`   rP   rI   rI   rJ   Ú
author_raw¶   r_   zDocumentInformation.author_rawc                 C   r]   )z¸
        Read-only property accessing the document's **subject**.

        Returns a unicode string (``TextStringObject``) or ``None``
        if the subject is not specified.
        )rV   rY   ÚSUBJECTrP   rI   rI   rJ   Úsubject»   rb   zDocumentInformation.subjectc                 C   r]   )z@The "raw" version of subject; can return a ``ByteStringObject``.)rS   rY   rd   rP   rI   rI   rJ   Úsubject_rawÅ   r_   zDocumentInformation.subject_rawc                 C   r]   )ax  
        Read-only property accessing the document's **creator**.

        If the document was converted to PDF from another format, this is the
        name of the application (e.g. OpenOffice) that created the original
        document from which it was converted. Returns a unicode string
        (``TextStringObject``) or ``None`` if the creator is not specified.
        )rV   rY   ÚCREATORrP   rI   rI   rJ   ÚcreatorÊ   ó   
zDocumentInformation.creatorc                 C   r]   )z@The "raw" version of creator; can return a ``ByteStringObject``.)rS   rY   rg   rP   rI   rI   rJ   Úcreator_rawÖ   r_   zDocumentInformation.creator_rawc                 C   r]   )a\  
        Read-only property accessing the document's **producer**.

        If the document was converted to PDF from another format, this is
        the name of the application (for example, OSX Quartz) that converted
        it to PDF. Returns a unicode string (``TextStringObject``)
        or ``None`` if the producer is not specified.
        )rV   rY   ÚPRODUCERrP   rI   rI   rJ   ÚproducerÛ   ri   zDocumentInformation.producerc                 C   r]   )zAThe "raw" version of producer; can return a ``ByteStringObject``.)rS   rY   rk   rP   rI   rI   rJ   Úproducer_rawç   r_   z DocumentInformation.producer_rawc                 C   ó,   |   tj¡}|du rdS t | dd¡d¡S )zP
        Read-only property accessing the document's **creation date**.
        Nú'Ú úD:%Y%m%d%H%M%S%z)rV   rY   ÚCREATION_DATEr   ÚstrptimeÚreplace©rQ   ÚtextrI   rI   rJ   Úcreation_dateì   s   z!DocumentInformation.creation_datec                 C   r]   )zÄ
        The "raw" version of creation date; can return a ``ByteStringObject``.

        Typically in the format D:YYYYMMDDhhmmss[+-]hh'mm where the suffix is the
        offset from UTC.
        )rS   rY   rr   rP   rI   rI   rJ   Úcreation_date_rawö   rb   z%DocumentInformation.creation_date_rawc                 C   rn   )z˜
        Read-only property accessing the document's **modification date**.

        The date and time the document was most recently modified.
        Nro   rp   rq   )rV   rY   ÚMOD_DATEr   rs   rt   ru   rI   rI   rJ   Úmodification_date   s   z%DocumentInformation.modification_datec                 C   r]   )zÈ
        The "raw" version of modification date; can return a ``ByteStringObject``.

        Typically in the format D:YYYYMMDDhhmmss[+-]hh'mm where the suffix is the
        offset from UTC.
        )rS   rY   ry   rP   rI   rI   rJ   Úmodification_date_raw  rb   z)DocumentInformation.modification_date_raw)rD   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__rO   Ústrr
   rV   rW   Úpropertyr\   r^   ra   rc   re   rf   rh   rj   rl   rm   r   rw   rx   rz   r{   rI   rI   rI   rJ   rM   w   sB    
				rM   c                   @   sø  e Zd ZdZ		d½deeef dededee	f ddfdd	„Z
edefd
d„ƒZedee fdd„ƒZdee fdd„Zedee fdd„ƒZedee fdd„ƒZdee fdd„Zedee fdd„ƒZdefdd„Zdefdd„Zedefdd„ƒZdedefdd „Zd!edefd"d#„Zedeeef fd$d%„ƒZedeeef fd&d'„ƒZ 			d¾d(ee! d)eeeef  d*ee deeeef  fd+d,„Z"			d¾d(ee! d)eeeef  d*ee deeeef  fd-d.„Z#d/ee!e$f d)eeef d*ed0eddf
d1d2„Z%d(ee!e$f d)ed*eddfd3d4„Z&d*ed/ed0eddfd5d6„Z'deeef fd7d8„Z(deeef fd9d:„Z)		d¿d(ee!df d)ee deeef fd;d<„Z*		d¿d(ee!df d)ee deeef fd=d>„Z+ede,fd?d@„ƒZ-ede,fdAdB„ƒZ.	d¿dCee$ dDee de,fdEdF„Z/	d¿dCee$ dDee de,fdGdH„Z0edee1 fdIdJ„ƒZ2dKedee3e4f defdLdM„Z5dNedefdOdP„Z6dNedefdQdR„Z7dSe8defdTdU„Z9dSe8defdVdW„Z:dXedYee;ee<e4de3e$f   de8fdZd[„Z=dCe$dee8 fd\d]„Z>ede;e fd^d_„ƒZ?edee fd`da„ƒZ@dee fdbdc„ZAedee fddde„ƒZBedeeC fdfdg„ƒZDdeeC fdhdi„ZEedeeC fdjdk„ƒZF			d¾dlede$ef dmeeeef  dKee4 ddfdndo„ZGdKe4deeeHef fdpdq„ZIdredsedeeH fdtdu„ZJdKeee4f deeH fdvdw„ZKdxe4deeH fdydz„ZLdeMdeNeef fd{d|„ZOdeMdeNeef fd}d~„ZPded€edeeH fd�d‚„ZQded€edeeH fdƒd„„ZRded€ed…eeH deeH fd†d‡„ZSded€ed…eeH deeH fdˆd‰„ZTdeMddfdŠd‹„ZUdeMddfdŒd�„ZVdeMddfdŽd�„ZWdeMdefd�d‘„ZXdeMddfd’d“„ZYdeMd”ee d•eddfd–d—„ZZdeMdee fd˜d™„Z[deMd”edee fdšd›„Z\deMdee]e^e_f fdœd�„Z`eadeMd”edefdždŸ„ƒZbdeMddfd d¡„Zcd¢e;e d£edegeeeNed¤f f f d¥edeeeeNed¤f f gef ddfd¦d§„ZedYe;e defeNeef  fd¨d©„Zg	ªdÀdeMd«ede	fd¬d­„Zh	ªdÀdeMd«ede	fd®d¯„Zideee	f dejfd°d±„Zkd²edeeef fd³d´„Zledefdµd¶„ƒZmdefd·d¸„Znedefd¹dº„ƒZoedeeeef  fd»d¼„ƒZpdS )ÁÚ	PdfReadera®  
    Initialize a PdfReader object.

    This operation can take some time, as the PDF stream's cross-reference
    tables are read into memory.

    :param stream: A File object or an object that supports the standard read
        and seek methods similar to a File object. Could also be a
        string representing a path to a PDF file.
    :param bool strict: Determines whether user should be warned of all
        problems and also causes some correctable problems to be fatal.
        Defaults to ``False``.
    :param None/str/bytes password: Decrypt PDF file at initialization. If the
        password is None, the file will not be decrypted.
        Defaults to ``None``
    FNÚstreamÚstrictÚpasswordrD   c           	      C   s@  || _ d | _i | _d| _d | _t|dƒrd|jvrtdtƒ t	|t
tfƒr@t|dƒ�}t| ¡ ƒ}W d   ƒ n1 s;w   Y  |  |¡ || _d| _d | _| jr–d| _| j tj¡}|rd|d  ¡ jnd}tt| jtj  ¡ ƒ}t ||¡| _|d ur~|nd}| j |¡tjkr‘|d ur‘t d	ƒ‚d| _d S |d uržt!d
ƒ‚d S )Nr   ÚmodeÚbzQPdfReader stream/file object is not in binary mode. It may not be read correctly.ÚrbFTó    zWrong passwordúNot encrypted file)"r„   Úflattened_pagesÚresolved_objectsÚ
xref_indexÚ_page_id2numÚhasattrr†   r   r|   rT   r€   r   Úopenr   Úreadrƒ   Ú_override_encryptionÚ_encryptionÚis_encryptedÚtrailerrS   ÚTKÚIDr[   Úoriginal_bytesr   r2   ÚENCRYPTr   Úverifyr   ÚNOT_DECRYPTEDr-   r+   )	rQ   rƒ   r„   r…   ÚfhÚid_entryÚ	id1_entryÚencrypt_entryÚpwdrI   rI   rJ   rO   )  sF   þýÿ
ÿ
ÿzPdfReader.__init__c                 C   s<   | j  ¡ }| j  dd¡ | j  d¡ d¡}| j  |d¡ |S )Nr   rE   zutf-8)rƒ   ÚtellÚseekr‘   Údecode)rQ   ÚlocÚpdf_file_versionrI   rI   rJ   Ú
pdf_header]  s
   
zPdfReader.pdf_headerc                 C   sF   t j| jvrdS | jt j }tƒ }t|tdƒƒrtdƒ‚| |¡ |S )a=  
        Retrieve the PDF file's document information dictionary, if it exists.
        Note that some PDF files use metadata streams instead of docinfo
        dictionaries, and these metadata streams will not be accessed by this
        function.

        :return: the document information of this PDF file
        NzEtrailer not found or does not point to document information directory)r–   ÚINFOr•   rM   rT   Útyper+   Úupdate)rQ   ÚobjrU   rI   rI   rJ   Úmetadatag  s   
ÿ
zPdfReader.metadatac                 C   ó   t dddƒ | jS )úd
        .. deprecated:: 1.28.0

            Use the attribute :py:attr:`metadata` instead.
        ÚgetDocumentInfor«   rX   ©r   r«   rP   rI   rI   rJ   r®   |  ó   zPdfReader.getDocumentInfoc                 C   r¬   )r­   ÚdocumentInfor«   rX   r¯   rP   rI   rI   rJ   r±   …  ó   zPdfReader.documentInfoc                 C   s&   zd| _ | jtj jW d| _ S d| _ w )a  
        XMP (Extensible Metadata Platform) data

        :return: a :class:`XmpInformation<xmp.XmpInformation>`
            instance that can be used to access XMP metadata from the document.
            or ``None`` if no metadata was found on the document root.
        TF)r’   r•   r–   ÚROOTÚxmp_metadatarP   rI   rI   rJ   r´   �  s   	zPdfReader.xmp_metadatac                 C   r¬   )úh
        .. deprecated:: 1.28.0

            Use the attribute :py:attr:`xmp_metadata` instead.
        ÚgetXmpMetadatar´   rX   ©r   r´   rP   rI   rI   rJ   r¶   ž  r°   zPdfReader.getXmpMetadatac                 C   r¬   )rµ   ÚxmpMetadatar´   rX   r·   rP   rI   rI   rJ   r¸   §  r²   zPdfReader.xmpMetadatac                 C   s6   | j r| jtj d d S | jdu r|  ¡  t| jƒS )zÈ
        Calculate the number of pages in this PDF file.

        :return: number of pages
        :raises PdfReadError: if file is encrypted and restrictions prevent
            this action.
        ú/Pagesú/CountN)r”   r•   r–   r³   r‹   Ú_flattenÚlenrP   rI   rI   rJ   Ú_get_num_pages±  s
   

zPdfReader._get_num_pagesc                 C   ó   t dddƒ |  ¡ S )ú\
        .. deprecated:: 1.28.0

            Use :code:`len(reader.pages)` instead.
        zreader.getNumPagesúlen(reader.pages)rX   ©r   r½   rP   rI   rI   rJ   ÚgetNumPagesÃ  s   zPdfReader.getNumPagesc                 C   r¾   )r¿   zreader.numPagesrÀ   rX   rÁ   rP   rI   rI   rJ   ÚnumPagesÌ  s   zPdfReader.numPagesÚ
pageNumberc                 C   ó   t dddƒ |  |¡S )zd
        .. deprecated:: 1.28.0

            Use :code:`reader.pages[page_number]` instead.
        zreader.getPage(pageNumber)zreader.pages[page_number]rX   )r   Ú	_get_page)rQ   rÄ   rI   rI   rJ   ÚgetPageÖ  s   ÿ
zPdfReader.getPageÚpage_numberc                 C   s.   | j du r	|  ¡  | j dusJ dƒ‚| j | S )zè
        Retrieve a page by number from this PDF file.

        :param int page_number: The page number to retrieve
            (pages begin at zero)
        :return: a :class:`PageObject<PyPDF2._page.PageObject>` instance.
        Núhint for mypy)r‹   r»   )rQ   rÈ   rI   rI   rJ   rÆ   á  s   


zPdfReader._get_pagec                 C   r¬   )ú`
        .. deprecated:: 1.28.0

            Use :py:attr:`named_destinations` instead.
        ÚnamedDestinationsÚnamed_destinationsrX   )r   rÌ   rP   rI   rI   rJ   rË   ð  r²   zPdfReader.namedDestinationsc                 C   ó   |   ¡ S )zv
        A read-only dictionary which maps names to
        :class:`Destinations<PyPDF2.generic.Destination>`
        )Ú_get_named_destinationsrP   rI   rI   rJ   rÌ   ú  s   zPdfReader.named_destinationsÚtreerU   Úfileobjc           
      C   sÔ   t  ¡ }| t ¡ ¡ |du r,i }tt| jtj ƒ}t	j
|v r*ttt |t	j
 ƒ}ndS |du r2|S |  |||¡ |D ]}||v rK|  ||||¡  nq;d|v rhtt|d ƒ}|D ]}| ¡ }	|  |	|||¡ qY|S )a  
        Extract field data if this PDF contains interactive form fields.

        The *tree* and *retval* parameters are for recursive use.

        :param fileobj: A file object (usually a text file) to write
            a report to on all interactive form fields found.
        :return: A dictionary where each key is a field name, and each
            value is a :class:`Field<PyPDF2.generic.Field>` object. By
            default, the mapping name is used for keys.
            ``None`` if form data could not be located.
        Nz/Fields)r$   Úattributes_dictr©   r!   r   r2   r•   r–   r³   ÚCDÚ	ACRO_FORMr
   r=   Ú_check_kidsÚ_build_fieldr.   r[   )
rQ   rÏ   rU   rÐ   Úfield_attributesÚcatalogÚattrÚfieldsÚfÚfieldrI   rI   rJ   Ú
get_fields  s,   
ýzPdfReader.get_fieldsc                 C   s   t dddƒ |  |||¡S )zU
        .. deprecated:: 1.28.0

            Use :meth:`get_fields` instead.
        Ú	getFieldsrÜ   rX   )r   rÜ   )rQ   rÏ   rU   rÐ   rI   rI   rJ   rÝ   2  s   zPdfReader.getFieldsrÛ   rÖ   c                 C   s~   |   |||¡ z|d }W n ty(   z|d }W n ty%   Y Y d S w Y nw |r7|  |||¡ | d¡ t|ƒ||< d S )Nz/TMú/TÚ
)rÔ   ÚKeyErrorÚ_write_fieldÚwriter4   )rQ   rÛ   rU   rÐ   rÖ   rR   rI   rI   rJ   rÕ   @  s   þÿþ
zPdfReader._build_fieldc                 C   s4   t j|v r|t j D ]}|  | ¡ ||¡ q
d S d S rN   )ÚPAÚKIDSrÜ   r[   )rQ   rÏ   rU   rÐ   ÚkidrI   rI   rJ   rÔ   U  s
   
ýzPdfReader._check_kidsc           	   	   C   s
  t  ¡ }|t ¡  }|D ]v}|t jt jfv rq|| }z^|t jkr>dddddœ}|| |v r=| |d |||   d ¡ n:|t jkriz	|| t j }W n t	y\   || t j
 }Y nw | |d | d ¡ n| |d t|| ƒ d ¡ W q t	y‚   Y qw d S )NÚButtonÚTextÚChoiceÚ	Signature)z/Btnú/Txz/Chz/Sigú: rß   )r$   Ú
attributesr!   ÚKidsÚAAÚFTrâ   ÚParentÚTMrà   ÚTr€   )	rQ   rÐ   rÛ   rÖ   Úfield_attributes_tuplerØ   Ú	attr_nameÚtypesÚnamerI   rI   rJ   rá   ]  sB   
ÿþ
ü€
ÿ€þåzPdfReader._write_fieldc                    s&   |   ¡ ‰ ˆ du r
i S ‡ fdd„ˆ D ƒS )a6  
        Retrieve form fields from the document with textual data.

        The key is the name of the form field, the value is the content of the
        field.

        If the document contains multiple form fields with the same name, the
        second and following will get the suffix _2, _3, ...
        Nc                    s6   i | ]}ˆ |   d ¡dkrˆ | d ˆ |   d¡“qS )z/FTrê   rÞ   z/V)rS   )Ú.0rÛ   ©Ú
formfieldsrI   rJ   Ú
<dictcomp>�  s
    þz2PdfReader.get_form_text_fields.<locals>.<dictcomp>)rÜ   rP   rI   rø   rJ   Úget_form_text_fields‚  s   
þzPdfReader.get_form_text_fieldsc                 C   r¾   )z_
        .. deprecated:: 1.28.0

            Use :meth:`get_form_text_fields` instead.
        ÚgetFormTextFieldsrû   rX   )r   rû   rP   rI   rI   rJ   rü   –  s   ÿzPdfReader.getFormTextFieldsc                 C   st  |du r7i }t t| jtj ƒ}tj|v rt t|tj ƒ}ntj|v r7t t|tj ƒ}tj|v r7t t|tj ƒ}|du r=|S t	j
|v rWt t|t	j
 ƒD ]
}|  | ¡ |¡ qJ|S tj|v r�t t|tj ƒ}tdt|ƒdƒD ].}t t||  ¡ ƒ}||d   ¡ }t|tƒrŒd|v rŒ|d }|  ||¡}	|	durš|	||< ql|S | ¡ D ]\}
}| ¡ }|  |
|¡}	|	dur·|	||
< q¡|S )z¼
        Retrieve the named destinations present in the document.

        :return: a dictionary which maps names to
            :class:`Destinations<PyPDF2.generic.Destination>`.
        Nr   é   r   ú/D)r   r2   r•   r–   r³   ÚCAÚDESTSr=   ÚNAMESrã   rä   r.   rÎ   r[   Úranger¼   r€   rT   Ú_build_destinationÚitems)rQ   rÏ   rU   r×   Únamesrå   ÚirR   ÚvalueÚdestÚk__Úv__ÚvalrI   rI   rJ   rÎ   ¡  sD   




ð€û€z!PdfReader._get_named_destinationsc                 C   ó   t dddƒ |  ||¡S )rÊ   ÚgetNamedDestinationsrÌ   rX   )r   rÎ   )rQ   rÏ   rU   rI   rI   rJ   r  Ò  s   
ÿzPdfReader.getNamedDestinationsc                 C   rÍ   )z÷
        Read-only property for the outline (i.e., a collection of 'outline items'
        which are also known as 'bookmarks') present in the document.

        :return: a nested list of :class:`Destinations<PyPDF2.generic.Destination>`.
        )Ú_get_outlinerP   rI   rI   rJ   Úoutlineá  s   zPdfReader.outlinec                 C   r¬   )zT
        .. deprecated:: 2.9.0

            Use :py:attr:`outline` instead.
        Úoutlinesr  rX   )r   r  rP   rI   rI   rJ   r  ë  r²   zPdfReader.outlinesÚnoder  c                 C   sâ   |d u r7g }t t| jtj ƒ}tj|v r2t t|tj ƒ}t|tƒr#|S |d ur2d|v r2t t|d ƒ}|  	¡ | _
|d u r=|S 	 |  |¡}|rJ| |¡ d|v rbg }|  t t|d ƒ|¡ |rb| |¡ d|vri	 |S t t|d ƒ}q>)Nú/FirstTz/Next)r   r2   r•   r–   r³   ÚCOÚOUTLINESrT   r9   rÎ   Ú_namedDestsÚ_build_outline_itemÚappendr  )rQ   r  r  r×   ÚlinesÚoutline_objÚsub_outlinerI   rI   rJ   r  õ  s4   





þòzPdfReader._get_outlinec                 C   r  )zU
        .. deprecated:: 1.28.0

            Use :py:attr:`outline` instead.
        ÚgetOutlinesr  rX   )r   r  )rQ   r  r  rI   rI   rJ   r    s   zPdfReader.getOutlinesc                 C   s0   t t| jtj ƒ}tj|v rt d|tj ƒS dS )uÍ   
        Read-only property for the list of threads see Â§8.3.2 from PDF 1.7 spec

        :return: an Array of Dictionnaries with "/F" and "/I" properties
                 or None if no articles.
        r.   N)r   r2   r•   r–   r³   r  ÚTHREADS)rQ   r×   rI   rI   rJ   Úthreads)  s   
zPdfReader.threadsÚindirect_referencec                 C   sp   | j du rdd„ t| jƒD ƒ| _ |du st|tƒrdS t|tƒr#|}n|j}| j dus/J dƒ‚| j  |d¡}|S )zGenerate _page_id2numNc                 S   s   i | ]	\}}|j j|“qS rI   )r  Úidnum)r÷   r  ÚxrI   rI   rJ   rú   <  s    ÿz:PdfReader._get_page_number_by_indirect.<locals>.<dictcomp>éÿÿÿÿrÉ   )rŽ   Ú	enumerateÚpagesrT   r9   Úintr  rS   )rQ   r  r  ÚretrI   rI   rJ   Ú_get_page_number_by_indirect7  s   
ÿ
z&PdfReader._get_page_number_by_indirectÚpagec                 C   ó   |   |j¡S )a  
        Retrieve page number of a given PageObject

        :param PageObject page: The page to get page number. Should be
            an instance of :class:`PageObject<PyPDF2._page.PageObject>`
        :return: the page number or -1 if page not found
        )r&  r  ©rQ   r'  rI   rI   rJ   Úget_page_numberJ  rb   zPdfReader.get_page_numberc                 C   rÅ   )zZ
        .. deprecated:: 1.28.0

            Use :meth:`get_page_number` instead.
        ÚgetPageNumberr*  rX   )r   r*  r)  rI   rI   rJ   r+  T  s   
zPdfReader.getPageNumberÚdestinationc                 C   r(  )zË
        Retrieve page number of a given Destination object.

        :param Destination destination: The destination to get page number.
        :return: the page number or -1 if page not found
        )r&  r'  ©rQ   r,  rI   rI   rJ   Úget_destination_page_number]  ó   z%PdfReader.get_destination_page_numberc                 C   rÅ   )zf
        .. deprecated:: 1.28.0

            Use :meth:`get_destination_page_number` instead.
        ÚgetDestinationPageNumberr.  rX   )r   r.  r-  rI   rI   rJ   r0  f  s   ÿ
z"PdfReader.getDestinationPageNumberr\   Úarrayc                 C   sÜ   d\}}t |ttfƒst |tƒrt|ƒdks|d u r%tƒ }t||t ¡ ƒS |dd… \}}|dd … }zt||t||d�ƒW S  tym   t	d|› d|› �t
ƒ | jrT‚ | jd j}|d u ratƒ n|}t||t ¡ ƒ Y S w )N©NNr   rý   )Úfit_typeÚfit_argszUnknown destination: ú )rT   r9   r€   r.   r¼   r1   r5   Úfitr+   r   r|   r„   r#  r  )rQ   r\   r1  r'  ÚtypÚtmpr  rI   rI   rJ   r  s  s*   	ÿþùzPdfReader._build_destinationc                 C   s²  d\}}}z	t d|d ƒ}W n ty#   | jrtd|›�ƒ‚d}Y nw d|v rAt t|d ƒ}t t|tj ƒ}|dkr@|tj }nd|v rV|d }t	|tƒrVd	|v rV|d	 }t	|t
ƒrb|  ||¡}nEt	|tƒrƒz|  || j| j¡}W n3 ty‚   |  |d ¡}Y n%w |d u rŽ|  ||¡}n| jr˜td
|›�ƒ‚td|›d�tƒ |  |d ¡}|rÔd|v r¼t
dd„ |d D ƒƒ|tdƒ< d|v rÈ|d |tdƒ< d|v rÔ|d |tdƒ< ||_|S )N©NNNr€   z/Titlez(Outline Entry Missing /Title attribute: rp   z/Az/GoToz/Destrþ   zUnexpected destination zRemoved unexpected destination z from destinationz/Cc                 s   s   � | ]}t |ƒV  qd S rN   )r6   )r÷   ÚcrI   rI   rJ   Ú	<genexpr>Ë  s   € z0PdfReader._build_outline_item.<locals>.<genexpr>z/Frº   )r   rà   r„   r+   r2   r8   r%   ÚSÚDrT   r.   r  r€   r  Ú
dest_arrayr   r|   r  )rQ   r  r  r\   Úoutline_itemÚactionÚaction_typerI   rI   rJ   r  ”  s\   
ý
€

ÿþ
þzPdfReader._build_outline_itemc                 C   s   t | j| jƒS )zWRead-only property that emulates a list of :py:class:`Page<PyPDF2._page.Page>` objects.)r   r½   rÆ   rP   rI   rI   rJ   r#  ×  s   zPdfReader.pagesc                 C   s0   t t| jtj ƒ}tj|v rt t|tj ƒS dS )a  
        Get the page layout.

        :return: Page layout currently being used.

        .. list-table:: Valid ``layout`` values
           :widths: 50 200

           * - /NoLayout
             - Layout explicitly not specified
           * - /SinglePage
             - Show one page at a time
           * - /OneColumn
             - Show one column at a time
           * - /TwoColumnLeft
             - Show pages in two columns, odd-numbered pages on the left
           * - /TwoColumnRight
             - Show pages in two columns, odd-numbered pages on the right
           * - /TwoPageLeft
             - Show two pages at a time, odd-numbered pages on the left
           * - /TwoPageRight
             - Show two pages at a time, odd-numbered pages on the right
        N)r   r2   r•   r–   r³   rÒ   ÚPAGE_LAYOUTr8   )rQ   r•   rI   rI   rJ   Úpage_layoutÜ  s   
zPdfReader.page_layoutc                 C   r¬   )úY
        .. deprecated:: 1.28.0

            Use :py:attr:`page_layout` instead.
        ÚgetPageLayoutrC  rX   ©r   rC  rP   rI   rI   rJ   rE  ú  r°   zPdfReader.getPageLayoutc                 C   r¬   )rD  Ú
pageLayoutrC  rX   rF  rP   rI   rI   rJ   rG    r²   zPdfReader.pageLayoutc                 C   s(   z	| j tj d W S  ty   Y dS w )aO  
        Get the page mode.

        :return: Page mode currently being used.

        .. list-table:: Valid ``mode`` values
           :widths: 50 200

           * - /UseNone
             - Do not show outline or thumbnails panels
           * - /UseOutlines
             - Show outline (aka bookmarks) panel
           * - /UseThumbs
             - Show page thumbnails panel
           * - /FullScreen
             - Fullscreen view
           * - /UseOC
             - Show Optional Content Group (OCG) panel
           * - /UseAttachments
             - Show attachments panel
        z	/PageModeN)r•   r–   r³   rà   rP   rI   rI   rJ   Ú	page_mode  s
   ÿzPdfReader.page_modec                 C   r¬   )úW
        .. deprecated:: 1.28.0

            Use :py:attr:`page_mode` instead.
        ÚgetPageModerH  rX   ©r   rH  rP   rI   rI   rJ   rJ  )  r°   zPdfReader.getPageModec                 C   r¬   )rI  ÚpageModerH  rX   rK  rP   rI   rI   rJ   rL  2  r²   zPdfReader.pageModer#  Úinheritc                 C   s0  t tjƒt tjƒt tjƒt tjƒf}|d u ri }|d u r-| jtj  	¡ }|d  	¡ }g | _
d}tj|v r9|tj }|dkrm|D ]}||v rK|| ||< q?|tj D ]}i }	t|tƒr^||	d< | j| 	¡ |fi |	¤Ž qQd S |dkr–t| ¡ ƒD ]\}
}|
|vrƒ|||
< qwt| |ƒ}| |¡ | j
 |¡ d S d S )Nr¹   r  z/Page)r8   ÚPGÚ	RESOURCESÚMEDIABOXÚCROPBOXÚROTATEr•   r–   r³   r[   r‹   rã   ÚTYPErä   rT   r7   r»   Úlistr  r   r©   r  )rQ   r#  rM  r  Úinheritable_page_attributesr×   ÚtrØ   r'  ÚaddtÚattr_inr  Úpage_objrI   rI   rJ   r»   <  sD   ü

€
ü€

özPdfReader._flattenc                 C   s˜  | j |j \}}t|d| ƒ ¡ }tt|d ƒdksJ ‚||d k s#J ‚tt| ¡ ƒƒ}t	|d ƒD ]�}t
|ƒ | dd¡ t |¡}t
|ƒ | dd¡ t |¡}t
|ƒ | dd¡ ||jkraq1| jrl||krltdƒ‚| t|d | ƒd¡ t
|ƒ | dd¡ z
t|| ƒ}	W |	  S  tyÁ }
 z)td	|› d
|j› d|j› d|
› �tƒ | jr±td|
› �ƒ‚tƒ }	W Y d }
~
|	  S d }
~
ww | jrÉtdƒ‚tƒ S )Nr   ú/Typez/ObjStmz/Nr!  r   zObject is in wrong index.r  zInvalid stream (index z) within object r5  rë   zCan't read object stream: z%This is a fatal error in strict mode.)Úxref_objStmr  r7   r[   r   r€   r   r   Úget_datar  r   r¢   r:   Úread_from_streamr„   r+   r$  r>   r,   r   Ú
generationr|   r9   )rQ   r  ÚstmnumÚidxÚobj_stmÚstream_datar  ÚobjnumÚoffsetrª   ÚexcrI   rI   rJ   Ú_get_object_from_streamj  sX   


òÿÿþü€òz!PdfReader._get_object_from_streamÚnumÚgenc                 C   s   t ||| ƒ ¡ S )zr
        used to ease development
        equivalent to generic.IndirectObject(num,gen,self).get_object()
        )r7   r[   )rQ   rg  rh  rI   rI   rJ   Ú_get_indirect_object   s   zPdfReader._get_indirect_objectc           	   
   C   s2  t |tƒrt|d| ƒ}|  |j|j¡}|d ur|S |jdkr+|j| jv r+|  |¡}�nã|j| jv �rP|j| j|j v �rP| j	 
|ji ¡ 
|jd¡rLtƒ S | j|j |j }| j |d¡ z
|  | j¡\}}W nw tyÝ   t| jdƒr{t| j ¡ ƒ}n| j ¡ }| j dd¡ | j d¡}| j |d¡ t d|j› d|j› d� ¡ |¡}|d urÙtd|j› d	|j› d
�tƒ | d¡d | j|j |j< | j | d¡d ¡ |  | j¡\}}nd}Y nw ||jkrý| jrý| jrütd|j› d|j› d|› d|› d�	ƒ‚n||jk�r| j�rtd|j› d|j› d|› d|› d�	ƒ‚| j�r&||jk�s&J ‚t| j| ƒ}| j�sO| j d u�rO| j  !¡ �s@t"dƒ‚t#t$|ƒ}| j  %||j|j¡}n¾t| jdƒ�r_t| j ¡ ƒ}n| j ¡ }| j dd¡ | j d¡}| j |d¡ t d|j› d|j› d� ¡ |¡}|d u�røtd|j› d|j› d�tƒ |j| jv�r©i | j|j< | d¡d | j|j |j< | j | &d¡d ¡ t'| jƒ | j dd¡ t| j| ƒ}| j�s÷| j d u�r÷| j  !¡ �sèt"dƒ‚t#t$|ƒ}| j  %||j|j¡}ntd|j› d|j› d�tƒ | j�rtdƒ‚|  (|j|j|¡ |S )Nr   FÚ	getbufferr!  z\sz\s+z\s+objz
Object ID ú,z ref repairedr   zExpected object ID (r5  z) does not match actual (z); xref table not zero-indexed.z).zFile has not been decryptedzObject z foundz not defined.zCould not find object.))rT   r$  r7   Úcache_get_indirect_objectr^  r  r[  rf  ÚxrefÚxref_free_entryrS   r9   rƒ   r¢   Úread_object_headerÚ	Exceptionr�   Úbytesrj  r¡   r‘   ÚreÚsearchÚencoder   r|   Ústartr�   r„   r+   r>   r’   r“   Úis_decryptedr*   r   r;   Údecrypt_objectÚendr   Úcache_indirect_object)	rQ   r  rU   ru  r  r^  ÚbufÚpÚmrI   rI   rJ   r[   §  sê   
ÿ
ÿ
þþ
þÿ€éÿÿÿÿ
ÿþþÿ

ÿ€
þ
þÿ


ÿ€þ
ÿzPdfReader.get_objectÚindirectReferencec                 C   rÅ   )zU
        .. deprecated:: 1.28.0

            Use :meth:`get_object` instead.
        Ú	getObjectr[   rX   )r   r[   )rQ   r}  rI   rI   rJ   r~  )  ó   
zPdfReader.getObjectc                 C   s²   d}t |ƒ |t|ƒO }| dd¡ t|ƒ}|t|ƒO }| dd¡ t|ƒ}|t|ƒO }| dd¡ | d¡}t|ƒ | dd¡ |rQ| jrQtd|› d|› �tƒ t	|ƒt	|ƒfS )NFr!  r   é   z.Superfluous whitespace found in object header r5  )
r   r   r¢   r   r‘   r   r„   r   r|   r$  )rQ   rƒ   Úextrar  r^  Ú_objrI   rI   rJ   ro  4  s&   

þzPdfReader.read_object_headerc                 C   rÅ   )z]
        .. deprecated:: 1.28.0

            Use :meth:`read_object_header` instead.
        ÚreadObjectHeaderro  rX   )r   ro  )rQ   rƒ   rI   rI   rJ   rƒ  P  r  zPdfReader.readObjectHeaderr^  r  c                 C   s   | j  ||f¡S rN   )rŒ   rS   ©rQ   r^  r  rI   rI   rJ   rl  [  s   z#PdfReader.cache_get_indirect_objectc                 C   r  )zd
        .. deprecated:: 1.28.0

            Use :meth:`cache_get_indirect_object` instead.
        ÚcacheGetIndirectObjectrl  rX   )r   rl  r„  rI   rI   rJ   r…  `  s   ÿz PdfReader.cacheGetIndirectObjectrª   c                 C   s^   ||f| j v rd|› d|› �}| jrt|ƒ‚t|tƒ || j ||f< |d ur-t||| ƒ|_|S )NzOverwriting cache for r5  )rŒ   r„   r+   r   r|   r7   r  )rQ   r^  r  rª   ÚmsgrI   rI   rJ   ry  m  s   
zPdfReader.cache_indirect_objectc                 C   s   t ddƒ |  |||¡S )z`
        .. deprecated:: 1.28.0

            Use :meth:`cache_indirect_object` instead.
        ÚcacheIndirectObjectry  )r   ry  )rQ   r^  r  rª   rI   rI   rJ   r‡  z  s   
zPdfReader.cacheIndirectObjectc              
   C   s.  |   |¡ |  |¡ |  |¡}|  ||¡}|dkr+| jr"|r"tdƒ‚td|› d�tƒ |  |||¡ | j	r“| js•| 
¡ }| j ¡ D ]I\}}|dkrJqAt| ¡ ƒ}|D ]7}| || d¡ z	|  |¡\}	}
W n
 tyo   Y  nw |	|| j	 kr‰| j| | | j| |	< | j| |= qRqA| |d¡ d S d S d S )Nr   zBroken xref tablezincorrect startxref pointer(ú)éÿÿ  )Ú_basic_validationÚ_find_eof_markerÚ_find_startxref_posÚ_get_xref_issuesr„   r+   r   r|   Ú_read_xref_tables_and_trailersr�   r¡   rm  r  ÚsortedÚkeysr¢   ro  Ú
ValueError)rQ   rƒ   Ú	startxrefÚxref_issue_nrr¤   rh  Ú
xref_entryÚxref_kÚidÚpidÚ_pgenrI   rI   rJ   r‘   …  s<   



ÿÿ€ìzPdfReader.readc                 C   sp   |  dtj¡ | ¡ stdƒ‚| jr6|  dtj¡ | d¡}|dkr-td| 	d¡› d�ƒ‚|  dtj¡ d S d S )Nr   zCannot read an empty fileé   s   %PDF-zPDF starts with 'Úutf8z', but '%PDF-' expected)
r¢   ÚosÚSEEK_ENDr¡   r)   r„   ÚSEEK_SETr‘   r+   r£   )rQ   rƒ   Úheader_byterI   rI   rJ   rŠ  «  s   
ÿøzPdfReader._basic_validationc                 C   sL   d}d}|d d… dkr$|  ¡ |k rtdƒ‚t|ƒ}|d d… dksd S d S )NrE   r‰   r™  s   %%EOFzEOF marker not found)r¡   r+   r   )rQ   rƒ   Úlast_mbÚlinerI   rI   rJ   r‹  º  s   ýzPdfReader._find_eof_markerc                 C   s~   t |ƒ}zt|ƒ}W n" ty,   | d¡stdƒ‚t|dd…  ¡ ƒ}tdtƒ Y |S w t |ƒ}|dd… dkr=tdƒ‚|S )z5Find startxref entry - the location of the xref tables	   startxrefzstartxref not foundé	   Nz startxref on same line as offset)r   r$  r‘  Ú
startswithr+   Ústripr   r|   )rQ   rƒ   r   r’  rI   rI   rJ   rŒ  Â  s   
özPdfReader._find_startxref_posc                 C   sâ  |  d¡}|d d… dkrtdƒ‚t|ƒ | dd¡ d}	 ttt|| ƒƒ}|r7|dkr7|| _| jr7t	d	t
ƒ d
}t|ƒ | dd¡ ttt|| ƒƒ}t|ƒ | dd¡ d}||k �rS|  d¡}|d dv rx| dd¡ |  d¡}|d dv sg|d dv r„| dd¡ z|d d…  d¡\}}	|dd… }
t|ƒt|	ƒ}}W nZ tyú   t|dƒr³t| ¡ ƒ}n| ¡ }| dd¡ |  d¡}| |¡ t |› d� ¡ |¡}|d u rät	d|› d�t
ƒ d}d}nt	d|› d�t
ƒ t| d¡ƒ}| ¡ }Y nw || jv�ri | j|< i | j|< || j| v �rn3|| j| |< z|
dk| j| |< W n
 t�y0   Y nw z|
dk| jd |< W n
 t�yF   Y nw |d7 }|d7 }||k s\t|ƒ | dd¡ |  d¡}|dk�rn| dd¡ nd S q)Né   r€  s   refzxref table read errorr!  r   Tr   zFXref table not zero-indexed. ID numbers for objects will be corrected.Fé   ó   
iíÿÿÿs   0123456789té   ó    é   é   rj  z\s+(\d+)\s+objzentry z( in Xref table invalid; object not foundr‰  z' in Xref table invalid but object foundó   fé   s   traileriùÿÿÿ)r‘   r+   r   r¢   r   r$  r>   r�   r„   r   r|   Úsplitrp  r�   rq  rj  r¡   rr  rs  rt  Úgroupru  rm  rn  )rQ   rƒ   ÚrefÚ	firsttimerg  rC   Úcntr   Úoffset_bÚgeneration_bÚentry_type_brd  r^  rz  r{  rÚ   Ú
trailertagrI   rI   rJ   Ú_read_standard_xref_tableÓ  s¦   
þ


þ




þ
þ€è

ÿÿ·J

�z#PdfReader._read_standard_xref_tabler’  r“  c           
   
   C   s²  i | _ i | _i | _tƒ | _|d ur×| |d¡ | d¡}|dv r%| d¡}|dkr/|  |¡}n¢|rEz|  |¡ W d S  t	yD   d}Y n�w | 
¡ rËz|  |¡}W n* t	yz } ztj| jv rntd|j› �tƒ W Y d }~d S td|j› �ƒ‚d }~ww tjtjtjtjf}|D ]}||v rœ|| jvrœ| |¡| jt|ƒ< q‡d|v r½| ¡ }	| tt|d ƒd d¡ |  |¡ | |	d¡ d|v rÉtt|d ƒ}nd S |  ||¡}|d usd S d S )	Nr   r   r¦  ó   xz!Previous trailer can not be read ztrailer can not be read ú/XRefStmú/Prev)rm  rn  r[  r2   r•   r¢   r‘   Ú
_read_xrefÚ_rebuild_xref_tablerp  ÚisdigitÚ_read_pdf15_xref_streamr–   r³   r   Úargsr|   r+   r™   r§   r—   Úraw_getr8   r¡   r   r$  Ú_read_xref_other_error)
rQ   rƒ   r’  r“  r   Ú
xrefstreamÚeÚtrailer_keysrR   r{  rI   rI   rJ   rŽ  @  s\   


ÿ
þ€ø	€
Øz(PdfReader._read_xref_tables_and_trailersc                 C   sâ   |   |¡ t|ƒ | dd¡ ttttf t|| ƒƒ}| ¡ D ]\}}|| j	vr-|| j	|< qd|v re| 
¡ }| tt|d ƒd d¡ z|  |¡ W n ty^   td|d › d�tƒ Y nw | |d¡ d|v ro|d }|S d S )Nr!  r   r¸  r   zXRef object at z, can not be read, some object may be missingr¹  )r¶  r   r¢   r   r   r€   r   r>   r  r•   r¡   r$  r½  rp  r   r|   )rQ   rƒ   Únew_trailerrR   r  r{  r’  rI   rI   rJ   rº  q  s0   


€þÿzPdfReader._read_xrefc                 C   sÞ   |dkr| j rtdƒ‚tdtƒ d S | dd¡ | d¡}| d¡}|dkr.|d	| 8 }|S | |d¡ td
ƒD ]}| d¡ ¡ rI||7 }|  S q8d| j	v rk| j sktdtƒ z|  
|¡ W d S  tyj   tdƒ‚w tdƒ‚)Nr   z6/Prev=0 in the trailer (try opening with strict=False)zA/Prev=0 in the trailer - assuming there is no previous xref tableiõÿÿÿr   r¥  ó   xrefr!  é
   r™  z/Rootz"Invalid parent xref., rebuild xrefzcan not rebuild xrefz/Could not find xref table at specified location)r„   r+   r   r|   r¢   r‘   Úfindr  r¼  r•   r»  rp  )rQ   rƒ   r’  r8  Úxref_locÚlookrI   rI   rJ   rÀ  Š  s>   ÿþ

ý

ÿz PdfReader._read_xref_other_errorc                    s   |  dd¡ ˆ |¡\}}ttt|ˆƒƒ}tt|d ƒdks J ‚ˆ |||¡ tt| 	¡ ƒƒ‰| 
dd| 
d¡g¡}ttttf | 
d¡ƒ‰ tˆ ƒd	ksNJ ‚ˆjr^tˆ ƒd	kr^td
ˆ › �ƒ‚dtdttttdf f f‡ ‡fdd„}dtdttttdf f dtf‡fdd„}ˆ |||¡ |S )Nr!  r   rZ  z/XRefz/Indexr   z/Sizez/Wr€  zToo many entry sizes: r  rD   .c                    s8   ˆ |  dkrˆ  ˆ |  ¡}t|ˆ |  ƒS | dkrdS dS )Nr   r   )r‘   rK   )r  rB   )Úentry_sizesrb  rI   rJ   Ú	get_entryÅ  s   z4PdfReader._read_pdf15_xref_stream.<locals>.get_entryrg  r^  c                    s   | ˆ j  |g ¡v p| ˆ jv S rN   )rm  rS   r[  )rg  r^  rP   rI   rJ   Úused_beforeÓ  s   z6PdfReader._read_pdf15_xref_stream.<locals>.used_before)r¢   ro  r   r/   r>   r€   ry  r   r   r\  rS   r   r   r¼   r„   r+   r$  r   r   ÚboolÚ_read_xref_subsections)rQ   rƒ   r  r^  rÁ  Ú	idx_pairsrË  rÌ  rI   )rÊ  rQ   rb  rJ   r½  ³  s   (*z!PdfReader._read_pdf15_xref_streamc                 C   s„   |   |d d¡ |  d¡}|dvrdS |  d¡}|dkr@d}|dv r1|  d¡}|dkr-dS |dv s"||  d¡7 }| ¡ d	kr@d
S dS )zBReturn an int which indicates an issue. 0 means there is no issue.r   r   s   
 	r¤  rÅ  r‰   s   0123456789 	rý   s   objr€  )r¢   r‘   Úlower)rƒ   r’  r   rI   rI   rJ   r�  Û  s    


ýzPdfReader._get_xref_issuesc           	      C   sÞ   i | _ | dd¡ | d¡}t d|¡D ]$}t| d¡ƒ}t| d¡ƒ}|| j vr.i | j |< | d¡| j | |< q| dd¡ t d|¡D ]'}| | d¡d¡ tt	t
t
f t|| ƒƒ}t| ¡ ƒD ]	\}}|| j|< qbqEd S )Nr   r!  s(   [\r\n \t][ \t]*(\d+)[ \t]+(\d+)[ \t]+objr   rý   s$   [\r\n \t][ \t]*trailer[\r\n \t]*(<<))rm  r¢   r‘   rr  Úfinditerr$  r®  ru  r   r   r   r>   rT  r  r•   )	rQ   rƒ   Úf_r|  r  r^  rÄ  rR   r  rI   rI   rJ   r»  ô  s"   


ÿüzPdfReader._rebuild_xref_tablerÏ  rË  .rÌ  c                 C   sö   d}|   |¡D ]q\}}||ksJ ‚|| }t||| ƒD ][}|dƒ}|dkr/|dƒ}	|dƒ}
q|dkrR|dƒ}|dƒ}|| jvrEi | j|< |||ƒsQ|| j| |< q|dkrm|dƒ}|dƒ}d}|||ƒsl||f| j|< q| jrwtd|› �ƒ‚qqd S )Nr   r   rý   zUnknown xref type: )Ú_pairsr  rm  r[  r„   r+   )rQ   rÏ  rË  rÌ  Úlast_endru  rC   rg  Ú	xref_typeÚnext_free_objectÚnext_generationÚbyte_offsetr^  Ú
objstr_numÚ	obstr_idxrI   rI   rJ   rÎ    s:   



€
€ÿéüz PdfReader._read_xref_subsectionsc                 c   s<   � d}	 || ||d  fV  |d7 }|d t |ƒkrd S q)Nr   Tr   rý   )r¼   )rQ   r1  r  rI   rI   rJ   rÓ  ,  s   €üzPdfReader._pairsr   Úlimit_offsetc                 C   sî   t ddd� g }	 | ¡ dks| ¡ |krtdƒ‚| d¡}| ¡ dk r(td	ƒ‚| d
d¡ |dv rhd}|dv r]| d¡}|dv rI| dd¡ d}| ¡ dk rStd	ƒ‚| d
d¡ |dv s8| |rcdndd¡ n| |¡ q	| ¡  d |¡S )z.. deprecated:: 2.1.0Úread_next_end_linez4.0.0)Ú
removed_inTr   z!Could not read malformed PDF filer   rý   zEOL marker not foundéþÿÿÿ)ó   
ó   Fr!  r‰   )r   r¡   r+   r‘   r¢   r  ÚreverseÚjoin)rQ   rƒ   rÛ  Ú
line_partsr   ÚcrlfrI   rI   rJ   rÜ  4  s8   

ùÿ
é
zPdfReader.read_next_end_linec                 C   s   t ddƒ |  ||¡S )z.. deprecated:: 1.28.0ÚreadNextEndLinerX   )r   rÜ  )rQ   rƒ   rÛ  rI   rI   rJ   rå  U  s   
zPdfReader.readNextEndLinec                 C   s   | j stdƒ‚| j  |¡S )ag  
        When using an encrypted / secured PDF file with the PDF Standard
        encryption handler, this function will allow the file to be decrypted.
        It checks the given password against the document's user password and
        owner password, and then stores the resulting decryption key if either
        password is correct.

        It does not matter which password was matched.  Both passwords provide
        the correct decryption key that will allow the document to be used with
        this library.

        :param str password: The password to match.
        :return: `PasswordType`.
        rŠ   )r“   r+   rš   )rQ   r…   rI   rI   rJ   Údecrypt\  s   zPdfReader.decryptÚpermissions_codec                 C   sˆ   i }|d@ dk|d< |d@ dk|d< |d@ dk|d< |d@ dk|d	< |d
@ dk|d< |d@ dk|d< |d@ dk|d< |d@ dk|d< |S )Nr¤  r   ÚprintrE   Úmodifyr§  Úcopyé    Úannotationsé   Úformsi   Úaccessabilityi   Úassemblei   Úprint_high_qualityrI   )rQ   rç  ÚpermissionsrI   rI   rJ   Údecode_permissionsp  s   
ÿzPdfReader.decode_permissionsc                 C   s   t j| jv S )zè
        Read-only boolean property showing whether this PDF file is encrypted.
        Note that this property, if true, will remain true even after the
        :meth:`decrypt()<PyPDF2.PdfReader.decrypt>` method is called.
        )r–   r™   r•   rP   rI   rI   rJ   r”     r/  zPdfReader.is_encryptedc                 C   r¬   )úZ
        .. deprecated:: 1.28.0

            Use :py:attr:`is_encrypted` instead.
        ÚgetIsEncryptedr”   rX   ©r   r”   rP   rI   rI   rJ   rõ  ˆ  r°   zPdfReader.getIsEncryptedc                 C   r¬   )rô  ÚisEncryptedr”   rX   rö  rP   rI   rI   rJ   r÷  ‘  r²   zPdfReader.isEncryptedc           
      C   s¨   d }i }t t| jtj ƒ}d|vs|d sd S t t|d ƒ}d|v rRt t|d ƒ}t|ƒ}|D ]"}|}t|ƒ}t	|t
ƒrQt tt | ¡ ƒ}|rQt |j¡}	|	||< q/|S )Nz	/AcroFormz/XFA)r   r2   r•   r–   r³   r=   r.   ÚiterÚnextrT   r7   r
   r3   r[   ÚzlibÚ
decompressÚ_data)
rQ   rÏ   rU   r×   rÙ   r  rÚ   ÚtagrÛ   ÚesrI   rI   rJ   Úxfa›  s&   
€zPdfReader.xfa)FNr9  r2  )r   )qr|   r}   r~   r   r   r   r   rÍ  r€   rq  rO   r�   r¦   r
   rM   r«   r®   r±   rA   r´   r¶   r¸   r$  r½   rÂ   rÃ   r   rÇ   rÆ   r   r   rË   rÌ   r=   rÜ   rÝ   r2   rÕ   rÔ   rá   rû   rü   rÎ   r  r?   r  r  r  r  r.   r  r9   r7   r&  r*  r+  r1   r.  r0  r	   r:   r  r  r#  rC  rE  rG  r@   rH  rJ  rL  r»   r;   rf  ri  r[   r~  r   r   ro  rƒ  rl  r…  ry  r‡  r‘   rŠ  r‹  rŒ  r¶  rŽ  rº  rÀ  r/   r3   r0   r½  Ústaticmethodr�  r»  r   rÎ  r   rÓ  rÜ  rå  r   ræ  ró  r”   rõ  r÷  rÿ  rI   rI   rI   rJ   r‚     sF   ü
þýü
û4								üþýü
û/üþýü
û
þ
ýüû
ú
ÿÿÿ
þ%ý
þý

ü3ý
þý

ü	
ÿÿÿ
þ*ÿÿÿ
þÿ
þ
		ÿ
þþÿÿý
ø!C			üþýü
û.ÿ
þ6
ÿ
þ ÿ
þÿ

þÿÿ
þÿÿ
þÿÿÿ
þÿÿÿ
þ&mÿÿÿ
þ1ÿÿ
þ)ÿ
þ(þýü
û"%	ÿÿÿ
þ"ÿÿÿ
þ		 r‚   c                       s*   e Zd Zdededdf‡ fdd„Z‡  ZS )ÚPdfFileReaderr¾  ÚkwargsrD   Nc                    s>   t dddƒ d|vrt|ƒdk rd|d< tƒ j|i |¤Ž d S )Nr  r‚   rX   r„   rý   T)r   r¼   ÚsuperrO   )rQ   r¾  r  ©Ú	__class__rI   rJ   rO   µ  s   zPdfFileReader.__init__)r|   r}   r~   r   rO   Ú__classcell__rI   rI   r  rJ   r  ´  s    "r  )\r›  rr  rF   rú  r   Úior   Úpathlibr   Útypingr   r   r   r   r	   r
   r   r   r   r“   r   r   Ú_pager   r   Ú_utilsr   r   r   r   r   r   r   r   r   r   r   r   Ú	constantsr   rÿ   r    rÒ   r!   r"   r  r#   rY   r$   r%   r&   rN  r'   rã   r(   r–   Úerrorsr)   r*   r+   r,   r-   Úgenericr.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   rõ   r?   r@   ÚxmprA   rq  r$  rK   rL   rM   r‚   r  rI   rI   rI   rJ   Ú<module>   sb   ,8L&ÿÿ
þ !             *