
    ,h-             
       P   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ZWdeUdeVdeeVee
df   f   fdZX G d deC      ZY G d d       ZZ G d! d"eZ      Z[y)#    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                 h    |dkD  rt        d      d| z   } | dd  } t        j                  d|       d   S )N   zinvalid size in convert_to_ints           iz>qr   )r,   structunpackrC   rD   s     P/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/PyPDF2/_reader.pyconvert_to_intrL   h   s@    ax;<<+a/A	"#A==q!!$$    c                 2    t        dd       t        | |      S )NconvertToIntrL   )r   rL   rJ   s     rK   rO   rO   p   s     !1AB!T""rM   c                      e Zd ZdZddZdedee   fdZdedee   fdZe	dee   fd       Z
e	dee   fd	       Ze	dee   fd
       Ze	dee   fd       Ze	dee   fd       Ze	dee   fd       Ze	dee   fd       Ze	dee   fd       Ze	dee   fd       Ze	dee   fd       Ze	dee   fd       Ze	dee   fd       Ze	dee   fd       Ze	dee   fd       Zy)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.
    rE   Nc                 .    t        j                  |        y N)r3   __init__selfs    rK   rT   zDocumentInformation.__init__   s    !!$'rM   keyc                 L    | j                  |d       }t        |t              r|S y rS   )get
isinstancer=   )rV   rW   retvals      rK   	_get_textzDocumentInformation._get_text   s%    #t$f./MrM   c                 <    t        dd       | j                  |      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   r\   )rV   rW   s     rK   r^   zDocumentInformation.getText   s     	#9g6~~c""rM   c                     | j                  t        j                        rN| j                  t        j                        xs- | j                  t        j                        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)rY   DITITLEr\   
get_objectrU   s    rK   titlezDocumentInformation.title   sP     xx! NN288$G(:(E(E(G	
 	
rM   c                 @    | j                  t        j                        S )z>The "raw" version of title; can return a ``ByteStringObject``.)rY   ra   rb   rU   s    rK   	title_rawzDocumentInformation.title_raw   s     xx!!rM   c                 @    | j                  t        j                        S )z
        Read-only property accessing the document's **author**.

        Returns a unicode string (``TextStringObject``) or ``None``
        if the author is not specified.
        )r\   ra   AUTHORrU   s    rK   authorzDocumentInformation.author   s     ~~bii((rM   c                 @    | j                  t        j                        S )z?The "raw" version of author; can return a ``ByteStringObject``.)rY   ra   rh   rU   s    rK   
author_rawzDocumentInformation.author_raw   s     xx		""rM   c                 @    | j                  t        j                        S )z
        Read-only property accessing the document's **subject**.

        Returns a unicode string (``TextStringObject``) or ``None``
        if the subject is not specified.
        )r\   ra   SUBJECTrU   s    rK   subjectzDocumentInformation.subject   s     ~~bjj))rM   c                 @    | j                  t        j                        S )z@The "raw" version of subject; can return a ``ByteStringObject``.)rY   ra   rm   rU   s    rK   subject_rawzDocumentInformation.subject_raw        xx

##rM   c                 @    | j                  t        j                        S )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.
        )r\   ra   CREATORrU   s    rK   creatorzDocumentInformation.creator   s     ~~bjj))rM   c                 @    | j                  t        j                        S )z@The "raw" version of creator; can return a ``ByteStringObject``.)rY   ra   rs   rU   s    rK   creator_rawzDocumentInformation.creator_raw   rq   rM   c                 @    | j                  t        j                        S )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.
        )r\   ra   PRODUCERrU   s    rK   producerzDocumentInformation.producer   s     ~~bkk**rM   c                 @    | j                  t        j                        S )zAThe "raw" version of producer; can return a ``ByteStringObject``.)rY   ra   rx   rU   s    rK   producer_rawz DocumentInformation.producer_raw   s     xx$$rM   c                     | j                  t        j                        }|yt        j                  |j                  dd      d      S )zP
        Read-only property accessing the document's **creation date**.
        N' D:%Y%m%d%H%M%S%z)r\   ra   CREATION_DATEr   strptimereplacerV   texts     rK   creation_datez!DocumentInformation.creation_date   s?    
 ~~b../<  c2!68JKKrM   c                 @    | j                  t        j                        S )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.
        )rY   ra   r   rU   s    rK   creation_date_rawz%DocumentInformation.creation_date_raw   s     xx(())rM   c                     | j                  t        j                        }|yt        j                  |j                  dd      d      S )z
        Read-only property accessing the document's **modification date**.

        The date and time the document was most recently modified.
        Nr}   r~   r   )r\   ra   MOD_DATEr   r   r   r   s     rK   modification_datez%DocumentInformation.modification_date   s=     ~~bkk*<  c2!68JKKrM   c                 @    | j                  t        j                        S )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.
        )rY   ra   r   rU   s    rK   modification_date_rawz)DocumentInformation.modification_date_raw  s     xx$$rM   )rE   N)__name__
__module____qualname____doc__rT   strr   r\   r^   propertyrd   rf   ri   rk   rn   rp   rt   rv   ry   r{   r   r   r   r   r    rM   rK   rQ   rQ   w   s   (S Xc] 	#3 	#8C= 	# 
x} 
 
 "8C= " " ) ) ) #HSM # # *# * * $Xc] $ $ 	*# 	* 	* $Xc] $ $ 	+(3- 	+ 	+ %hsm % % Lx1 L L *8C= * * 	L8H#5 	L 	L %x} % %rM   rQ   c                      e Zd ZdZ	 	 dpdeeef   dededee	f   ddfdZ
edefd       Zedee   fd	       Zdee   fd
Zedee   fd       Zedee   fd       Zdee   fdZedee   fd       ZdefdZdefdZedefd       ZdedefdZdedefdZedeeef   fd       Zedeeef   fd       Z 	 	 	 dqdee!   deeeef      dee   deeeef      fdZ"	 	 	 dqdee!   deeeef      dee   deeeef      fdZ#dee!e$f   deeef   dededdf
dZ%dee!e$f   dededdfd Z&dedededdfd!Z'deeef   fd"Z(deeef   fd#Z)	 	 drdee!df   dee   deeef   fd$Z*	 	 drdee!df   dee   deeef   fd%Z+ede,fd&       Z-ede,fd'       Z.	 drd(ee$   d)ee   de,fd*Z/	 drd(ee$   d)ee   de,fd+Z0edee1   fd,       Z2d-edee3e4f   defd.Z5d/edefd0Z6d/edefd1Z7d2e8defd3Z9d2e8defd4Z:d5ed6ee;ee<e4de3e$f         de8fd7Z=d(e$dee8   fd8Z>ede;e   fd9       Z?edee   fd:       Z@dee   fd;ZAedee   fd<       ZBedeeC   fd=       ZDdeeC   fd>ZEedeeC   fd?       ZF	 	 	 dqd@ede$ef   dAeeeef      d-ee4   ddfdBZGd-e4deeeHef   fdCZIdDedEedeeH   fdFZJd-eee4f   deeH   fdGZKdHe4deeH   fdIZLdeMdeNeef   fdJZOdeMdeNeef   fdKZPdLedMedeeH   fdNZQdLedMedeeH   fdOZRdLedMedPeeH   deeH   fdQZSdLedMedPeeH   deeH   fdRZTdeMddfdSZUdeMddfdTZVdeMddfdUZWdeMdefdVZXdeMddfdWZYdeMdXee   dYeddfdZZZdeMdee   fd[Z[deMdXedee   fd\Z\deMdee]e^e_f   fd]Z`eadeMdXedefd^       ZbdeMddfd_Zcd`e;e   daedegeeeNedbf   f   f   dcedeeeeNedbf   f   gef   ddfddZed6e;e   defeNeef      fdeZg	 dsdeMdfede	fdgZh	 dsdeMdfede	fdhZideee	f   dejfdiZkdjedeeef   fdkZledefdl       ZmdefdmZnedefdn       Zoedeeeef      fdo       Zpy)t	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``
    NstreamstrictpasswordrE   c                    || _         d | _        i | _        d| _        d | _        t        |d      rd|j                  vrt        dt               t        |t        t        f      r.t        |d      5 }t        |j                               }d d d        | j                  |       || _        d| _        d | _        | j$                  rd| _        | j&                  j)                  t*        j,                        }|r|d   j/                         j0                  nd}t3        t4        | j&                  t*        j6                     j/                               }t9        j                  ||      | _        ||nd}| j"                  j;                  |      t<        j>                  k(  r|tA        d	      d| _        y |tC        d
      y # 1 sw Y   6xY w)Nr   modebzQPdfReader stream/file object is not in binary mode. It may not be read correctly.rbFTrM   zWrong passwordNot encrypted file)"r   flattened_pagesresolved_objects
xref_index_page_id2numhasattrr   r   r   rZ   r   r   openr   readr   _override_encryption_encryptionis_encryptedtrailerrY   TKIDrc   original_bytesr   r3   ENCRYPTr   verifyr   NOT_DECRYPTEDr.   r,   )	rV   r   r   r   fhid_entry	id1_entryencrypt_entrypwds	            rK   rT   zPdfReader.__init__)  s    ;?LN  	 66"s&++'=0
 fsDk*fd# ,r +,		&$)!15(,D% ||''.HCK..0??QTI  $,,rzz":"E"E"GM  *}iHD '2(C  '',0J0JJ( ))9::(-D%#"#788 $;, ,s   0F>>Gc                     | j                   j                         }| j                   j                  dd       | j                   j                  d      j	                  d      }| j                   j                  |d       |S )Nr   rG   zutf-8)r   tellseekr   decode)rV   locpdf_file_versions      rK   
pdf_headerzPdfReader.pdf_header]  sd     kk A;;++A.55g>a rM   c                     t         j                  | j                  vry| j                  t         j                     }t               }t	        |t        d            rt        d      |j                  |       |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   rQ   rZ   typer,   update)rV   objr[   s      rK   metadatazPdfReader.metadatag  sb     77$,,&ll277#$&c4:&W  	crM   c                 4    t        ddd       | j                  S )d
        .. deprecated:: 1.28.0

            Use the attribute :py:attr:`metadata` instead.
        getDocumentInfor   r_   r   r   rU   s    rK   r   zPdfReader.getDocumentInfo|  s     	%%6
GL}}rM   c                 4    t        ddd       | j                  S )r   documentInfor   r_   r   rU   s    rK   r   zPdfReader.documentInfo  s     	%^ZI}}rM   c                     	 d| _         | j                  t        j                     j                  d| _         S # d| _         w xY 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_metadatarU   s    rK   r   zPdfReader.xmp_metadata  s6    	.(,D%<<(55(-D%D%s	   -7 	A c                 4    t        ddd       | j                  S )h
        .. deprecated:: 1.28.0

            Use the attribute :py:attr:`xmp_metadata` instead.
        getXmpMetadatar   r_   r   r   rU   s    rK   r   zPdfReader.getXmpMetadata       	%%5~wO   rM   c                 4    t        ddd       | j                  S )r   xmpMetadatar   r_   r   rU   s    rK   r   zPdfReader.xmpMetadata       	%]NGL   rM   c                     | j                   r#| j                  t        j                     d   d   S | j                  | j                          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/Count)r   r   r   r   r   _flattenlenrU   s    rK   _get_num_pageszPdfReader._get_num_pages  sP     <<(28<<##+t++,,rM   c                 <    t        ddd       | j                         S )\
        .. deprecated:: 1.28.0

            Use :code:`len(reader.pages)` instead.
        zreader.getNumPageslen(reader.pages)r_   r   r   rU   s    rK   getNumPageszPdfReader.getNumPages  s"     	%%9;NPWX""$$rM   c                 <    t        ddd       | j                         S )r   zreader.numPagesr   r_   r   rU   s    rK   numPageszPdfReader.numPages  s!     	%%68KWU""$$rM   
pageNumberc                 >    t        ddd       | j                  |      S )zd
        .. deprecated:: 1.28.0

            Use :code:`reader.pages[page_number]` instead.
        zreader.getPage(pageNumber)zreader.pages[page_number]r_   )r   	_get_page)rV   r   s     rK   getPagezPdfReader.getPage  s%     	%(*Ew	
 ~~j))rM   page_numberc                 ~    | j                   | j                          | j                   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.
        hint for mypy)r   r   )rV   r   s     rK   r   zPdfReader._get_page  s>     'MMO##/@@##K00rM   c                 4    t        ddd       | j                  S )`
        .. deprecated:: 1.28.0

            Use :py:attr:`named_destinations` instead.
        namedDestinationsnamed_destinationsr_   )r   r   rU   s    rK   r   zPdfReader.namedDestinations  s     	%%8:NPWX&&&rM   c                 "    | j                         S )zv
        A read-only dictionary which maps names to
        :class:`Destinations<PyPDF2.generic.Destination>`
        )_get_named_destinationsrU   s    rK   r   zPdfReader.named_destinations  s     ++--rM   treer[   fileobjc                 >   t        j                         }|j                  t        j                                |ii }t	        t
        | j                  t        j                           }t        j                  |v r)t	        t        t           |t        j                           }ny||S | j                  |||       |D ]  }||v s| j                  ||||        n d|v r>t	        t        |d         }|D ]&  }|j!                         }	| j                  |	|||       ( |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   r3   r   r   r   CD	ACRO_FORMr   r>   _check_kids_build_fieldr/   rc   )
rV   r   r[   r   field_attributescatalogattrfieldsffields
             rK   
get_fieldszPdfReader.get_fields  s   $ 5DDF = M M OP>F+T\\"''-BCG||w&HZ0'",,2GH<Mvw/$ 	Dt|!!$9IJ		 +tI7F L!!%:JKL rM   c                 B    t        ddd       | j                  |||      S )zU
        .. deprecated:: 1.28.0

            Use :meth:`get_fields` instead.
        	getFieldsr   r_   )r   r   )rV   r   r[   r   s       rK   r   zPdfReader.getFields2  s#     	%[,HtVW55rM   r   r   c                     | j                  |||       	 |d   }|r$| j                  |||       |j                  d       t	        |      ||<   y # t        $ r 	 |d   }n# t        $ r Y Y y w xY wY Ww xY w)Nz/TM/T
)r   KeyError_write_fieldwriter5   )rV   r   r[   r   r   rW   s         rK   r   zPdfReader._build_field@  s     	0	,C gu.>?MM$Els  	Dk  	s5   A 	A2AA2	A,(A2+A,,A21A2c                     t         j                  |v r:|t         j                     D ]#  }| j                  |j                         ||       % y y rS   )PAKIDSr   rc   )rV   r   r[   r   kids        rK   r   zPdfReader._check_kidsU  sD     77d?BGG} C 0&'BC rM   c                 ~   t        j                         }|t        j                         z   }|D ]  }|t         j                  t         j                  fv r&||   }	 |t         j
                  k(  r/ddddd}||   |v r|j                  |dz   |||      z   dz          nk|t         j                  k(  r2	 ||   t         j                     }|j                  |dz   |z   dz          n&|j                  |dz   t        ||         z   dz           y # t        $ r ||   t         j                     }Y ew xY w# t        $ r Y w xY w)NButtonTextChoice	Signature)z/Btn/Txz/Chz/Sig: r   )r%   
attributesr"   KidsAAFTr  ParentTMr   Tr   )	rV   r   r   r   field_attributes_tupler   	attr_nametypesnames	            rK   r  zPdfReader._write_field]  si   !:!E!E!G"%B%M%M%OO 	 + 	D)..),,  (.I4777 !)%' +	E T{e+i$&6uT{9K&Kd&RS6===H$T{+D+G+GH MM)d"2T"9D"@AMM)d"2St5E"E"LM5	, $ H$T{+D+F+FGH
  s8   AD/0D
AD/
D,)D/+D,,D//	D<;D<c                     | j                         }|i S |D ci c]4  }||   j                  d      dk(  r||   d   ||   j                  d      6 c}S c c}w )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, ...
        z/FTr  r   z/V)r   rY   )rV   
formfieldsr   s      rK   get_form_text_fieldszPdfReader.get_form_text_fields  st     __&
I $
% $$U+u4 ud#Z%6%:%:4%@@
 	
 
s   9Ac                 <    t        ddd       | j                         S )z_
        .. deprecated:: 1.28.0

            Use :meth:`get_form_text_fields` instead.
        getFormTextFieldsr  r_   )r   r  rU   s    rK   r  zPdfReader.getFormTextFields  s%     	%!7	
 ((**rM   c                 L   |i }t        t        | j                  t        j                           }t
        j                  |v r"t        t        |t
        j                           }nft
        j                  |v rTt        t        |t
        j                           }t
        j                  |v r!t        t        |t
        j                           }||S t        j                  |v rHt        t        |t        j                           D ]"  }| j                  |j                         |       $ |S t
        j                  |v rt        t        |t
        j                           }t        dt        |      d      D ]l  }t        t         ||   j                               }||dz      j                         }t#        |t              r	d|v r|d   }| j%                  ||      }	|	h|	||<   n |S |j'                         D ]/  \  }
}|j                         }| j%                  |
|      }	|	+|	||
<   1 |S )z
        Retrieve the named destinations present in the document.

        :return: a dictionary which maps names to
            :class:`Destinations<PyPDF2.generic.Destination>`.
        r      r   /D)r   r3   r   r   r   CADESTSr>   NAMESr  r  r/   r   rc   ranger   r   rZ   _build_destinationitems)rV   r   r[   r   namesr  irW   valuedestk__v__vals                rK   r   z!PdfReader._get_named_destinations  s    >F+T\\"''-BCG xx7"J(9:W$-wrxx/@A88u$
E"((O<D<M77d?Kbgg7 G,,S^^-=vFG& ! XX)4>:E1c%j!, '3a 3 3 56a!e//1e%5645=!$KE..sE:#"&F3K'  !JJL 'Snn&..sC8#"&F3K	'
 rM   c                 @    t        ddd       | j                  ||      S )r   getNamedDestinationsr   r_   )r   r   )rV   r   r[   s      rK   r/  zPdfReader.getNamedDestinations  s)     	%"$8'	
 ++D&99rM   c                 "    | j                         S )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_outlinerU   s    rK   outlinezPdfReader.outline  s       ""rM   c                 4    t        ddd       | j                  S )zT
        .. deprecated:: 2.9.0

            Use :py:attr:`outline` instead.
        outlinesr2  r_   )r   r2  rU   s    rK   r4  zPdfReader.outlines  s     	%ZGD||rM   noder2  c                 F   |g }t        t        | j                  t        j                           }t
        j                  |v rLt        t        |t
        j                           }t        |t              r|S |d|v rt        t        |d         }| j                         | _
        ||S 	 | j                  |      }|r|j                  |       d|v r8g }| j                  t        t        |d         |       |r|j                  |       d|vr	 |S t        t        |d         }{)N/Firstz/Next)r   r3   r   r   r   COOUTLINESrZ   r:   r   _namedDests_build_outline_itemappendr1  )rV   r5  r2  r   linesoutline_objsub_outlines          rK   r1  zPdfReader._get_outline  s    ?G+T\\"''-BCG {{g%-wr{{/CDeZ0"N $U): 0%/BD#;;=D<N 2248K{+ 4)+!!$'7h"H+VNN;/d"  ($w-8D rM   c                 @    t        ddd       | j                  ||      S )zU
        .. deprecated:: 1.28.0

            Use :py:attr:`outline` instead.
        getOutlinesr2  r_   )r   r1  )rV   r5  r2  s      rK   rA  zPdfReader.getOutlines  s#     	%]IwG  w//rM   c                     t        t        | j                  t        j                           }t
        j                  |v rt        d|t
        j                           S y)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   r3   r   r   r   r8  THREADS)rV   r   s     rK   threadszPdfReader.threads)  sC     'bgg)>?:: wrzz':;;rM   indirect_referencec                 p   | j                   Bt        | j                        D ci c]  \  }}|j                  j                  | c}}| _         |t        |t              ryt        |t              r|}n|j                  }| j                   J d       | j                   j                  |d      }|S c c}}w )zGenerate _page_id2numr   )	r   	enumeratepagesrE  idnumrZ   r:   intrY   )rV   rE  r(  xrJ  rets         rK   _get_page_number_by_indirectz&PdfReader._get_page_number_by_indirect7  s     $:CDJJ:O!26!Q$$**A-!D %4F
)S(#.&E&,,E  ,=o=##E2.
!s   !B2pagec                 8    | j                  |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
        )rN  rE  rV   rO  s     rK   get_page_numberzPdfReader.get_page_numberJ  s     001H1HIIrM   c                 >    t        ddd       | j                  |      S )zZ
        .. deprecated:: 1.28.0

            Use :meth:`get_page_number` instead.
        getPageNumberrR  r_   )r   rR  rQ  s     rK   rT  zPdfReader.getPageNumberT  s"     	%_6GQ##D))rM   destinationc                 8    | j                  |j                        S )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
        )rN  rO  rV   rU  s     rK   get_destination_page_numberz%PdfReader.get_destination_page_number]  s     001A1ABBrM   c                 >    t        ddd       | j                  |      S )zf
        .. deprecated:: 1.28.0

            Use :meth:`get_destination_page_number` instead.
        getDestinationPageNumberrX  r_   )r   rX  rW  s     rK   rZ  z"PdfReader.getDestinationPageNumberf  s'     	%&(Ew	
 //<<rM   rd   arrayc                    d\  }}t        |t        t        f      s t        |t              rt	        |      dk(  s|)t               }t        ||t        j                               S |dd \  }}|dd  }	 t        ||t        ||            S # t        $ rl t        d| d| t               | j                  r | j                  d   j                  }|
t               n|}t        ||t        j                               cY S w xY w)NNNr   r  )fit_typefit_argszUnknown destination:  )rZ   r:   r   r/   r   r2   r6   fitr,   r   r   r   rI  rE  )rV   rd   r[  rO  typtmprE  s          rK   r%  zPdfReader._build_destinations  s     	c uz3/05+.3u:?} <DudCGGI66a
ID#!"IE	I"5$S50QRR I!6ugQugFQ;;jjm6658[Z\c""5*<cggiHHIs   3B A2D ?D c                    d\  }}}	 t        d|d         }d|v rMt        t        |d         }t        t
        |t        j                           }|dk(  r6|t        j                     }n"d|v r|d   }t        |t              r	d	|v r|d	   }t        |t              r| j                  ||      }nt        |t              r+	 | j                  || j                  |   j                        }nU|| j                  ||      }n@| j                  rt        d
|      t        d|dt                | j                  |d       }|rOd|v r!t        d |d   D              |t        d      <   d|v r|d   |t        d      <   d|v r|d   |t        d      <   ||_        |S # t        $ r  | j                  rt        d|      d}Y w xY w# t        $ r | j                  |d       }Y w xY w)NNNNr   z/Titlez(Outline Entry Missing /Title attribute: r~   z/Az/GoToz/Destr   zUnexpected destination zRemoved unexpected destination z from destinationz/Cc              3   2   K   | ]  }t        |        y wrS   )r7   ).0cs     rK   	<genexpr>z0PdfReader._build_outline_item.<locals>.<genexpr>  s     <`PQ[^<`s   z/Fr   )r   r   r   r,   r3   r9   r&   SDrZ   r/   r%  r   r:  
dest_arrayr   r   r5  )rV   r5  r*  rd   outline_itemactionaction_types          rK   r;  zPdfReader._build_outline_item  s   $4!e\	X/E 4<*DJ7Fz62E2G2G+HIKg%1334_=D$ 01ddlDzdK(225$?Lc"D#664++D1<<  \  225$?L{{"%<TH#EFF5dX=NO  225$?L t|1<<`UYZ^U_<`1`Z-.t| 26dZ-.4 6:(^Z12 u  	{{"%MdX#VWWE	6  D#66udCDs#   F >)G %G ?G G! G!c                 B    t        | j                  | j                        S )zWRead-only property that emulates a list of :py:class:`Page<PyPDF2._page.Page>` objects.)r   r   r   rU   s    rK   rI  zPdfReader.pages  s     D//@@rM   c                     t        t        | j                  t        j                           }t
        j                  |v r!t        t        |t
        j                           S y)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   r3   r   r   r   r   PAGE_LAYOUTr9   )rV   r   s     rK   page_layoutzPdfReader.page_layout  sC    2 'bgg)>?>>W$
GBNN$;<<rM   c                 4    t        ddd       | j                  S )Y
        .. deprecated:: 1.28.0

            Use :py:attr:`page_layout` instead.
        getPageLayoutrs  r_   r   rs  rU   s    rK   rv  zPdfReader.getPageLayout  s     	%_mWMrM   c                 4    t        ddd       | j                  S )ru  
pageLayoutrs  r_   rw  rU   s    rK   ry  zPdfReader.pageLayout  s     	%\='JrM   c                 b    	 | j                   t        j                     d   S # t        $ r Y yw xY 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   rU   s    rK   	page_modezPdfReader.page_mode  s1    .	<<(55 		s   " 	..c                 4    t        ddd       | j                  S )W
        .. deprecated:: 1.28.0

            Use :py:attr:`page_mode` instead.
        getPageModer{  r_   r   r{  rU   s    rK   r~  zPdfReader.getPageMode)  s     	%]KI~~rM   c                 4    t        ddd       | j                  S )r}  pageModer{  r_   r  rU   s    rK   r  zPdfReader.pageMode2  s     	%ZgF~~rM   rI  inheritc                 T   t        t        j                        t        t        j                        t        t        j                        t        t        j
                        f}|i }|E| j                  t        j                     j                         }|d   j                         }g | _
        d}t        j                  |v r|t        j                     }|dk(  rf|D ]  }||v s||   ||<    |t        j                     D ];  }i }	t        |t              r||	d<    | j                   |j                         |fi |	 = y |dk(  rdt#        |j%                               D ]  \  }
}|
|vs|||
<    t'        | |      }|j)                  |       | j                  j+                  |       y y )Nr   rE  z/Page)r9   PG	RESOURCESMEDIABOXCROPBOXROTATEr   r   r   rc   r   r  TYPEr  rZ   r8   r   listr&  r   r   r<  )rV   rI  r  rE  inheritable_page_attributesr   tr   rO  addtattr_inr)  page_objs                rK   r   zPdfReader._flatten<  s    r||$r{{#rzz"ryy!	'
# ?G= ll277+668GH%002E#%D 77ebggA=3 05=$)$KGDM0 bgg BdN315D-.doo/ADA	B
 '\"&w}}"7 + %'%*E'N	+
 "$(:;HOOE"   ''1 rM   c                 0   | j                   |j                     \  }}t        |d|       j                         }t	        t
        |d         dk(  sJ ||d   k  sJ t        t        |j                                     }t        |d         D ]  }t        |       |j                  dd       t        j                  |      }t        |       |j                  dd       t        j                  |      }t        |       |j                  dd       ||j                  k7  r| j                  r||k7  rt        d      |j                  t!        |d   |z         d       t        |       |j                  dd       	 t#        ||       }	|	c S  | j                  rt        d      t-               S # t$        $ ra}
t'        d	| d
|j                   d|j(                   d|
 t*               | j                  rt        d|
       t-               }	Y d }
~
|	c S d }
~
ww xY w)Nr   /Typez/ObjStmz/NrG  r   zObject is in wrong index.r7  zInvalid stream (index z) within object r`  r  zCan't read object stream: z%This is a fatal error in strict mode.)xref_objStmrJ  r8   rc   r   r   r   r   get_datar$  r   r   r;   read_from_streamr   r,   rK  r?   r-   r   
generationr   r:   )rV   rE  stmnumidxobj_stmstream_datar(  objnumoffsetr   excs              rK   _get_object_from_streamz!PdfReader._get_object_from_streamj  s	   
 &&'9'?'?@'5fa'F'Q'Q'SC)*i77WT]""b!1!1!345wt}% $	A,R#!22;?F,R#!22;?F,R#+111{{sax"#>??S!2V!;<a@  ,R##!+t4 JI$	L ;;FGG|% " # ,QC/?)//02D2O2O1PPRe 	 ;;&)CC5'IJJ lJ#s   9F++	H4AHHnumgenc                 8    t        |||       j                         S )zr
        used to ease development
        equivalent to generic.IndirectObject(num,gen,self).get_object()
        )r8   rc   )rV   r  r  s      rK   _get_indirect_objectzPdfReader._get_indirect_object  s    
 c3-88::rM   c                    t        |t              rt        |d|       }| j                  |j                  |j
                        }||S |j                  dk(  r+|j
                  | j                  v r| j                  |      }n|j                  | j                  v r |j
                  | j                  |j                     v r| j                  j                  |j                  i       j                  |j
                  d      r
t               S | j                  |j                     |j
                     }| j                  j                  |d       	 | j                  | j                        \  }}||j
                  k7  rD| j6                  r8| j8                  rst;        d|j
                   d|j                   d| d d	      ||j
                  k7  r8| j8                  r,t;        d|j
                   d|j                   d| d d	      | j8                  r|j                  k(  sJ t=        | j                  |       }| j>                  s'| j@                  | j@                  jC                         stE        d      tG        tH        |      }| j@                  jK                  ||j
                  |j                        }nt!        | j                  d      r$t#        | j                  j%                               }nm| j                  j'                         }| j                  j                  dd       | j                  j)                  d      }| j                  j                  |d       t+        j,                  d|j
                   d|j                   dj/                         |      }|t1        d|j
                   d|j                   dt2               |j                  | j                  vri | j                  |j                  <   |j5                  d      dz   | j                  |j                     |j
                  <   | j                  j                  |jM                  d      dz          tO        | j                         | j                  j                  dd       t=        | j                  |       }| j>                  s| j@                  | j@                  jC                         stE        d      tG        tH        |      }| j@                  jK                  ||j
                  |j                        }nBt1        d|j
                   d|j                   dt2               | j8                  rt;        d      | jQ                  |j                  |j
                  |       |S # t        $ r t!        | j                  d      r$t#        | j                  j%                               }nm| j                  j'                         }| j                  j                  dd       | j                  j)                  d      }| j                  j                  |d       t+        j,                  d|j
                   d|j                   dj/                         |      }|t1        d|j
                   d	|j                   d
t2               |j5                  d      dz   | j                  |j                     |j
                  <   | j                  j                  |j5                  d      dz          | j                  | j                        \  }}nd}Y w xY w)Nr   F	getbufferrG  z\sz\s+z\s+objz
Object ID ,z ref repairedr   zExpected object ID (r`  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.))rZ   rK  r8   cache_get_indirect_objectr  rJ  r  r  xrefxref_free_entryrY   r:   r   r   read_object_header	Exceptionr   bytesr  r   r   researchencoder   r   startr   r   r,   r?   r   r   is_decryptedr+   r   r<   decrypt_objectendr   cache_indirect_object)	rV   rE  r[   r  rJ  r  bufpms	            rK   rc   zPdfReader.get_object  sf    (#.!/0BAt!L//))+=+C+C
 M))Q."((D,<,<<112DEF))TYY6"((DII6H6S6S,TT##''(:(E(ErJNN"((% "|#II0;;<=O=U=UVEKKUA&$($;$;DKK$H!z2 *000T__;;&./A/G/G.HJ\JgJgIh i227* F77  ,222t{{"*+=+C+C*DA)445 6wa
|2/ 
 {{!%7%B%BBB d3F ,,1A1A1M''446/0MNNi0))88.446H6S6S t{{K0DKK1134KK$$&  A&kk&&r*  A&		(../s3E3P3P2QQWX__aA }0667q9K9V9V8WW]^ &00		A?ADII0;;<GGAJN 		,7789K9Q9QR   qA.$T[[1  Q'$T[[$7 00T5E5E5Q++88:34QRR!)V4F!--<< 2 8 8:L:W:WF 0667q9K9V9V8WWde ;;&'?@@""))+=+C+CV	
 K  4;;4 5 5 78C((*AKK$$Q*++**2.CKK$$Q*II,22337I7T7T6UU[\cce ="$%7%=%=$>a@R@]@]?^^kl  a II0;;<*00 KK$$QWWQZ!^4(,(?(?(L%E:E/s   V F#\=<\=indirectReferencec                 >    t        ddd       | j                  |      S )zU
        .. deprecated:: 1.28.0

            Use :meth:`get_object` instead.
        	getObjectrc   r_   )r   rc   )rV   r  s     rK   r  zPdfReader.getObject)  s      	%[,H011rM   c                    d}t        |       |t        |      z  }|j                  dd       t        |      }|t        |      z  }|j                  dd       t        |      }|t        |      z  }|j                  dd       |j	                  d      }t        |       |j                  dd       |r"| j                  rt        d| d| t               t        |      t        |      fS )NFrG  r      z.Superfluous whitespace found in object header r`  )
r   r   r   r   r   r   r   r   r   rK  )rV   r   extrarJ  r  _objs         rK   r  zPdfReader.read_object_header4  s    
 &!%f--B%f-%f--B*62
%f--B {{1~F#BT[[@qU 5z3z?**rM   c                 >    t        ddd       | j                  |      S )z]
        .. deprecated:: 1.28.0

            Use :meth:`read_object_header` instead.
        readObjectHeaderr  r_   )r   r  )rV   r   s     rK   r  zPdfReader.readObjectHeaderP  s#     	%%79MwW&&v..rM   r  rJ  c                 <    | j                   j                  ||f      S rS   )r   rY   rV   r  rJ  s      rK   r  z#PdfReader.cache_get_indirect_object[  s      $$((*e)<==rM   c                 @    t        ddd       | j                  ||      S )zd
        .. deprecated:: 1.28.0

            Use :meth:`cache_get_indirect_object` instead.
        cacheGetIndirectObjectr  r_   )r   r  r  s      rK   r  z PdfReader.cacheGetIndirectObject`  s)     	%$&A7	
 --j%@@rM   r   c                     ||f| j                   v r/d| d| }| j                  rt        |      t        |t               || j                   ||f<   |t        |||       |_        |S )NzOverwriting cache for r`  )r   r   r,   r   r   r8   rE  )rV   r  rJ  r   msgs        rK   r  zPdfReader.cache_indirect_objectm  su     $"7"77*:,aw?C{{"3''3)58z512?%3E:t%LC"
rM   c                 @    t        dd       | j                  |||      S )z`
        .. deprecated:: 1.28.0

            Use :meth:`cache_indirect_object` instead.
        cacheIndirectObjectr  )r   r  )rV   r  rJ  r   s       rK   r  zPdfReader.cacheIndirectObjectz  s%     	%%:<ST))*eSAArM   c                    | j                  |       | j                  |       | j                  |      }| j                  ||      }|dk7  r-| j                  r|rt        d      t        d| dt               | j                  |||       | j                  r| j                  s|j                         }| j                  j                         D ]  \  }}|dk(  rt        |j                               }|D ]q  }|j                  ||   d       	 | j!                  |      \  }	}
|	|| j                  z
  k(  s@| j                  |   |   | j                  |   |	<   | j                  |   |= s  |j                  |d       y y y # t"        $ r Y  w xY w)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   r  r&  sortedkeysr   r  
ValueError)rV   r   	startxrefxref_issue_nrr   r  
xref_entryxref_kidpid_pgens              rK   r   zPdfReader.read  s   v&f%,,V4	 --fi@A{{}"#6779-JHU 	++FI}M ??4;;++-C#'99??#4 /Z%<OO% ! 	/BKK
22%)%<%<V%D
U b4??22.2iinR.@		#s+ IIcN2.	//$ KKQ) $/? & s   E??	FFc                 |   |j                  dt        j                         |j                         st	        d      | j
                  ru|j                  dt        j                         |j                  d      }|dk7  rt        d|j                  d       d      |j                  dt        j                         y y )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   )rV   r   header_bytes      rK   r  zPdfReader._basic_validation  s    Ar{{#{{} !<==;;KK2;;' ++a.Kh&"'(:(:6(B'C D+ +  KK2;;' rM   c                     d}d}|d d dk7  r3|j                         |k  rt        d      t        |      }|d d dk7  r2y y )NrG   rM   r  s   %%EOFzEOF marker not found)r   r,   r   )rV   r   last_mblines       rK   r  zPdfReader._find_eof_marker  sN    2Ah("{{}w&"#9::%f-D 2Ah("rM   c                     t        |      }	 t        |      }t        |      }|dd dk7  rt        d      |S # t        $ rL |j	                  d      st        d      t        |dd j                               }t        dt               Y |S w xY w)z5Find startxref entry - the location of the xref tableN	   s	   startxrefzstartxref not foundz startxref on same line as offset)r   rK  r,   r  
startswithstripr   r   )rV   r   r  r  s       rK   r  zPdfReader._find_startxref_pos  s    !&)	:D	I &f-DBQx<'"#899  	I??<0"#899DHNN,-I=xH
 	Is   8 ABBc                    |j                  d      }|d d dk7  rt        d      t        |       |j                  dd       d}	 t	        t
        t        ||             }|r(|dk7  r#|| _        | j                  rt        d	t               d
}t        |       |j                  dd       t	        t
        t        ||             }t        |       |j                  dd       d}||k  r|j                  d      }|d   dv r+|j                  dd       |j                  d      }|d   dv r+|d   dv r|j                  dd       	 |d d j                  d      \  }}	|dd }
t        |      t        |	      }}|| j,                  vri | j,                  |<   i | j.                  |<   || j,                  |   v rn>|| j,                  |   |<   	 
dk(  | j.                  |   |<   	 
dk(  | j.                  d   |<   |dz  }|dz  }||k  rt        |       |j                  dd       |j                  d      }|dk7  r|j                  dd       ny # t        $ r t        |d      rt        |j                               }nD|j!                         }|j                  dd       |j                  d      }|j                  |       t#        j$                  | dj'                         |      }|t        d| dt               d}d}n>t        d| dt               t        |j)                  d            }|j+                         }Y w xY w# t        $ r Y vw xY w# t        $ r Y pw xY w)N   r  s   refzxref table read errorrG  r   Tr   zFXref table not zero-indexed. ID numbers for objects will be corrected.F      
is   0123456789t             r  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   rK  r?   r   r   r   r   splitr  r   r  r  r   r  r  r  groupr  r  r  )rV   r   ref	firsttimer  rD   cntr  offset_bgeneration_bentry_type_br  r  r  r  r   
trailertags                    rK   _read_standard_xref_tablez#PdfReader._read_standard_xref_table  sk   kk!nr7f677F#B	sK56CSAX"%;;"`  I'KKA[67D'KKAC*{{2 1g,KK+!;;r?D 1g, 8~-KKA&+-1#2Y__T-B*Hl#'2;L),XL8IJF6 TYY.,.DIIj)79D((4$))J//
 17DIIj)#.@LPT@T,,Z8=;G4;O,,U3C8 qqS *T  'KKAQJZ'B"G Z ! +v{3#F$4$4$67"KKMAq)$kk"oA		SE):";"B"B"DcJAy&$SE)QR$ &+
!#&$SE)PQ$ &)_
!"1+N %  % s7   2I M M C3MM	MM	M#"M#r  r  c                 l   i | _         i | _        i | _        t               | _        ||j                  |d       |j                  d      }|dv r|j                  d      }|dk(  r| j                  |      }n@|r	 | j                  |       y |j                         r	 | j                  |      }t        j                  t        j$                  t        j&                  t        j(                  f}|D ]=  }||v s|| j                  vs|j+                  |      | j                  t-        |      <   ? d|v rY|j/                         }	|j                  t1        t2        |d         dz   d       | j                  |       |j                  |	d       d|v rt1        t2        |d         }ny | j5                  ||      }|y y # t        $ r d}Y w xY w# t        $ r[}t        j                  | j                  v r"t        d|j                   t                Y d }~y t#        d|j                         d }~ww xY w)	Nr   r   r     xz!Previous trailer can not be read ztrailer can not be read /XRefStm/Prev)r  r  r  r3   r   r   r   
_read_xref_rebuild_xref_tabler  isdigit_read_pdf15_xref_streamr   r   r   argsr   r,   r   r   r   raw_getr9   r   r   rK  _read_xref_other_error)
rV   r   r  r  rL  
xrefstreametrailer_keysrW   r  s
             rK   r  z(PdfReader._read_xref_tables_and_trailers@  s    02	:<79')#KK	1%AAG|KKNDy OOF3	&,,V4 
P!%!=!=f!EJ  "ww

BGGRUUB' PCj(S-D8B8J8J38OZ_5P +AKKS*Z*@ AA EqI008KK1%j( $S*W*= >I 77	J	Q # ! &$%M&
 ! Pww$,,.&?xH$ *-EaffX+NOOPs0   ;F> G >GG	H39H.H..H3c                 8   | j                  |       t        |       |j                  dd       t        t        t
        t        f   t        ||             }|j                         D ]#  \  }}|| j                  vs|| j                  |<   % d|v rZ|j                         }|j                  t        t        |d         dz   d       	 | j                  |       |j                  |d       d|v r|d   }|S y # t        $ r t        d|d    dt               Y @w xY w)NrG  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   rK  r  r  r   r   )rV   r   new_trailerrW   r)  r  r  s          rK   r  zPdfReader._read_xrefq  s   &&v.F#B4S>;vt+DE%++- 	*JC$,,&$)S!	* $AKKS+j"9:Q>B,,V4 KK1k!#G,I  %k*&=%>>jks   C6 6 DDc                 6   |dk(  r(| j                   rt        d      t        dt               y |j	                  dd       |j                  d      }|j                  d      }|dk7  r
|d	|z
  z  }|S |j	                  |d       t        d
      D ]*  }|j                  d      j                         s#||z  }|c S  d| j                  v r/| j                   s#t        dt               	 | j                  |       y t        d      # t        $ r t        d      w xY w)Nr   z6/Prev=0 in the trailer (try opening with strict=False)zA/Prev=0 in the trailer - assuming there is no previous xref tableir   r     xrefrG  
   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   r  )rV   r   r  rc  xref_loclooks         rK   r  z PdfReader._read_xref_other_error  s"    >{{"L  S  	Ckk"o88G$r>h&IIq!!H 	!D{{1~%%'T!	  		! dll"4;;?J;((0 LMM  ;"#9::;s   &D Dc                    	 |j                  dd        j                  |      \  }}t        t        t	        |             }t        t
        |d         dk(  sJ  j                  |||       t        t        |j                                     	|j                  dd|j                  d      g      }t        t        t        t        f   |j                  d            t              d	k\  sJ  j                  rt              d	kD  rt        d
       dt         dt"        t         t$        t         df   f   f	fd}dt         dt"        t         t$        t         df   f   dt&        f fd} j)                  |||       |S )NrG  r   r  z/XRefz/Indexr   z/Sizez/Wr  zToo many entry sizes: r(  rE   .c                 h    |    dkD  r#j                  |          }t        ||          S | dk(  ryy)Nr   r   )r   rL   )r(  rC   entry_sizesr  s     rK   	get_entryz4PdfReader._read_pdf15_xref_stream.<locals>.get_entry  sE     1~!$$[^4%aQ88 AvrM   r  r  c                 `    | j                   j                  |g       v xs | j                  v S rS   )r  rY   r  )r  r  rV   s     rK   used_beforez6PdfReader._read_pdf15_xref_stream.<locals>.used_before  s-    $))--
B77R3$BRBR;RRrM   )r   r  r   r0   r?   r   r  r   r   r  rY   r   r   r   r   r,   rK  r   r   bool_read_xref_subsections)
rV   r   rJ  r  r  	idx_pairsr  r  r  r  s
   `       @@rK   r  z!PdfReader._read_pdf15_xref_stream  s^    	B 33F;z-VT)BC
CG,-88"":ujAb!4!4!678 NN8a1H-IJ	4S>:>>$+?@;1$$;;3{+a/!7}EFF	 	sE#s(O';!< 		SS 	SeCsCx4H.I 	Sd 	S
 	##Iy+FrM   c                    | j                  |dz
  d       | j                  d      }|dvry| j                  d      }|dk7  rJd}|dv r| j                  d      }|dk(  ry|dv r|| j                  d      z  }|j                         d	k7  ry
y)zBReturn an int which indicates an issue. 0 means there is no issue.r   r   s   
 	r  r  rM   s   0123456789 	r  s   objr  )r   r   lower)r   r  r  s      rK   r  zPdfReader._get_xref_issues  s     	IM1%{{1~z!{{1~7?D**{{1~3; ** FKKN"Dzz|v% rM   c                    i | _         |j                  dd       |j                  d      }t        j                  d|      D ]t  }t        |j                  d            }t        |j                  d            }|| j                   vri | j                   |<   |j                  d      | j                   |   |<   v |j                  dd       t        j                  d|      D ]z  }|j                  |j                  d      d       t        t        t        t        f   t        ||             }t        |j                               D ]  \  }}|| j                  |<    | y )Nr   rG  s(   [\r\n \t][ \t]*(\d+)[ \t]+(\d+)[ \t]+objr   r  s$   [\r\n \t][ \t]*trailer[\r\n \t]*(<<))r  r   r   r  finditerrK  r  r  r   r   r   r?   r  r&  r   )	rV   r   f_r  rJ  r  r
  rW   r)  s	            rK   r   zPdfReader._rebuild_xref_table  s!   	Aq[[_I2N 	6A
OEQWWQZJ*(*		*%+,771:DIIj!%(	6 	AqErJ 	*AKK
A&tCH~{64/HIK";#4#4#67 *
U$)S!*		*rM   r  r  .r  c                    d}| j                  |      D ]  \  }}||k\  sJ ||z   }t        |||z         D ]  } |d      }|dk(  r |d      }	 |d      }
!|dk(  rJ |d      } |d      }|| j                  vri | j                  |<    |||      r]|| j                  |   |<   p|dk(  r. |d      } |d      }d} |||      r||f| j                  |<   | j                  st        d|         y )Nr   r   r  zUnknown xref type: )_pairsr$  r  r  r   r,   )rV   r  r  r  last_endr  rD   r  	xref_typenext_free_objectnext_generationbyte_offsetr  
objstr_num	obstr_idxs                  rK   r  z PdfReader._read_xref_subsections  s!    ;;y1 	JKE4H$$t|HUEDL1 J%aL	>'0|$&/lO!^"+A,K!*1J!202		*-&sJ75@		*-c2!^!*1J )!I!"J&sJ71;Y0G((-[[&)<YK'HII1J		JrM   c              #   ^   K   d}	 ||   ||dz      f |dz  }|dz   t        |      k\  ry 'w)Nr   r   r  )r   )rV   r[  r(  s      rK   r   zPdfReader._pairs,  sF     (E!a%L((FAA#e*$	 s   +-limit_offsetc                 l   t        dd       g }	 |j                         dk(  s|j                         |k(  rt        d      |j                  d      }|j                         dk  rt        d	      |j	                  d
d       |dv r{d}|dv r^|j                  d      }|dv r|j	                  dd       d}|j                         dk  rt        d	      |j	                  d
d       |dv r^|j	                  |rdndd       n|j                  |       |j                          dj                  |      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)   
   FrG  rM   )r   r   r,   r   r   r<  reversejoin)rV   r   r)  
line_partsrL  crlfs         rK   r+  zPdfReader.read_next_end_line4  s.    	!!5'J
{{}!V[[]l%B"#FGGAA{{}q "#9::KKAN">)AAN*B*#{{}q(*+ABBKKA& >) A1a !!!$/ 0 	xx
##rM   c                 >    t        dd       | j                  ||      S )z.. deprecated:: 1.28.0readNextEndLiner_   )r   r+  )rV   r   r)  s      rK   r5  zPdfReader.readNextEndLineU  s"     	##4g>&&v|<<rM   c                 f    | j                   st        d      | j                   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   )rV   r   s     rK   decryptzPdfReader.decrypt\  s0     344&&x00rM   permissions_codec                     i }|dz  dk7  |d<   |dz  dk7  |d<   |dz  dk7  |d<   |dz  dk7  |d	<   |d
z  dk7  |d<   |dz  dk7  |d<   |dz  dk7  |d<   |dz  dk7  |d<   |S )Nr  r   printrG   modifyr  copy    annotations   formsi   accessabilityi   assemblei   print_high_qualityr   )rV   r8  permissionss      rK   decode_permissionszPdfReader.decode_permissionsp  s    /:>!CG 0J ?1 DH.*=BF%5%D%IM"/:>!CG'7;'G1'LO$"2k"Ba"GJ,1 	() rM   c                 :    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   rU   s    rK   r   zPdfReader.is_encrypted  s     zzT\\))rM   c                 4    t        ddd       | j                  S )Z
        .. deprecated:: 1.28.0

            Use :py:attr:`is_encrypted` instead.
        getIsEncryptedr   r_   r   r   rU   s    rK   rI  zPdfReader.getIsEncrypted  r   rM   c                 4    t        ddd       | j                  S )rH  isEncryptedr   r_   rJ  rU   s    rK   rL  zPdfReader.isEncrypted  r   rM   c                    d }i }t        t        | j                  t        j                           }d|vs|d   sy t        t
        |d         }d|v rt        t        |d         }t        |      }|D ]l  }|}t        |      }t        |t              s!t        t        t           |j                               }|sIt        j                  |j                         }	|	||<   n |S )Nz	/AcroFormz/XFA)r   r3   r   r   r   r>   r/   iternextrZ   r8   r   r4   rc   zlib
decompress_data)
rV   r   r[   r   r   r(  r   tagr   ess
             rK   xfazPdfReader.xfa  s    %)!#'bgg)>?g%W[-AJ 45T>+tF|4FVA )Ga0 *=!>OE!__U[[9&(s) rM   )FNre  r]  )r   )qr   r   r   r   r   r   r   r  r   r  rT   r   r   r   rQ   r   r   r   rB   r   r   r   rK  r   r   r   r   r   r   r   r   r   r   r>   r   r   r3   r   r   r  r  r  r   r/  r@   r2  r4  r1  rA  r/   rD  r:   r8   rN  rR  rT  r2   rX  rZ  r
   r;   r%  r;  rI  rs  rv  ry  rA   r{  r~  r  r   r<   r  r  rc   r  r   r   r  r  r  r  r  r  r   r  r  r  r  r  r  r  r0   r4   r1   r  staticmethodr  r   r   r  r	   r   r+  r5  r   r7  rE  r   rI  rL  rU  r   rM   rK   r   r     sd
   ( ,0	29k4'(29 29 c5()	29
 
29h  C     (#67  (*=!>  h':;   .h~6 . .! 8 ! !Xn5 ! !- -$%S % %# % %	*# 	** 	*1S 1Z 1 '4S> ' ' .DcN . . &*+/!%	+z"+ c3h(+ #	+
 
$sCx.	!+^ &*+/!%	6z"6 c3h(6 #	6
 
$sCx.	!6#Z!112# S#X# 	#
 # 
#*C*&667CADCORC	C#C # #s #t #J
d38n 
(	+4S> 	+ )- $/J$%/ / 
c3h	/f )- $:J$%: : 
c3h	: # # # +   QU'-.'@H'	'T QU	0-.	0@H	0		0 +.  "'c:~(M"N	&JJ J3 J** * *C{ Cs C=&=	=II lND*FVVW
I 
IBA(8 AXk=R AF AtJ' A A Xc]  : x}    HSM     8L1  6Xl3  (<0   <@,07;	,2T+Z78,2 $sCx.),2 %^4	,2
 
,2\4"04	sIs"	#4l; ;# ;(9:M ;@"'^(;"<@	)	@D	2!/	2	)		2+ +c3h +8	/ 	/	sCx	/>>&)>	)	>
AA&)A	)	A&)080C	)		B	B&)	B080C	B	)		B$ : $ $ $ L(
 (t (.z .d .*  "k
 kt kZ/K /K-5c]/KKN/K	/Kb  2'N 'N-0'N	#'NR& &	}13FF	G&P     0** * *&#J9#J SE5eCHo)=#>>?#J sE#uS#X*>$?@$FG	#J
 
#JJDI (5c?*C  78$ $03$	$D 78= =03=	=1c5j 1 1l 1(3 4T	?  *d * *! ! !T ! ! Xd38n-  rM   r   c                   ,     e Zd Zdededdf fdZ xZS )PdfFileReaderr  kwargsrE   Nc                 l    t        ddd       d|vrt        |      dk  rd|d<   t        |   |i | y )NrX  r   r_   r   r  T)r   r   superrT   )rV   r  rY  	__class__s      rK   rT   zPdfFileReader.__init__  s=    $_k7K6!c$i!m#F8$)&)rM   )r   r   r   r   rT   __classcell__)r\  s   @rK   rX  rX    s"    *c *S *T * *rM   rX  )\r  r  rH   rP  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#   r8  r$   ra   r%   r&   r'   r  r(   r  r)   r   errorsr*   r+   r,   r-   r.   genericr/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r  r@   rA   xmprB   r  rK  rL   rO   rQ   r   rX  r   rM   rK   <module>rg     s  < 
 	     
 
 
 2 +    / . 4 ! : E + , (     & - %e %3 %5eCHo1E+F %###
3c3h #]%* ]%@Z Zz4*I *rM   