U
    c<                    @   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 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/Z0 ddl)m1Z2 ddl)m3Z3m4Z4 ddl)m5Z6 ddl)m7Z8 ddl)m9Z: ddl;m<Z<m=Z=m>Z>m?Z?m@Z@ ddlAmBZBmCZCmDZDmEZEmFZFmGZGmHZHmIZImJZJmKZKmLZLmMZMmNZNmOZOmPZPmQZQmRZR ddlSmTZTmUZU ddlVmWZW eXeYeeYee
df f dddZZeXeYeeYee
df f dddZ[G dd deFZ\G d d! d!Z]G d"d# d#e]Z^dS )$    N)datetime)BytesIO)Path)	AnyCallableDictIterableListOptionalTupleUnioncast   )
EncryptionPasswordType)
PageObject_VirtualList)index2label)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returnc                 C   s4   |dkrt dd|  } | dd  } td| d S )N   zinvalid size in convert_to_ints           iz>qr   )r,   structunpackrC   rD    rJ   1/tmp/pip-unpacked-wheel-u_n6aelj/pypdf/_reader.pyconvert_to_inti   s
    rL   c                 C   s   t dd t| |S )NconvertToIntrL   )r   rL   rI   rJ   rJ   rK   rM   q   s    
rM   c                   @   sz  e Zd ZdZddddZeee dddZeee dd	d
Ze	ee dddZ
e	ee dddZe	ee dddZe	ee dddZe	ee dddZe	ee dddZe	ee dddZe	ee dddZe	ee dddZe	ee dddZe	ee ddd Ze	ee dd!d"Ze	ee dd#d$Ze	ee d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<pypdf.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 pypdf was unable to decode the string's
    text encoding; this requires additional safety in the caller and
    therefore is not as commonly accessed.
    NrE   c                 C   s   t |  d S N)r3   __init__selfrJ   rJ   rK   rQ      s    zDocumentInformation.__init__)keyrE   c                 C   s   |  |d }t|tr|S d S rP   )get
isinstancer=   )rS   rT   retvalrJ   rJ   rK   	_get_text   s    
zDocumentInformation._get_textc                 C   s   t dd | |S )zq
        Use the attributes (e.g. :py:attr:`title` / :py:attr:`author`).

        .. deprecated:: 1.28.0
        getText3.0.0)r   rX   )rS   rT   rJ   rJ   rK   rY      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 ``TextStringObject`` or ``None`` if the title is not
        specified.
        N)rU   DITITLErX   
get_objectrR   rJ   rJ   rK   title   s    

zDocumentInformation.titlec                 C   s   |  tjS )z>The "raw" version of title; can return a ``ByteStringObject``.)rU   r[   r\   rR   rJ   rJ   rK   	title_raw   s    zDocumentInformation.title_rawc                 C   s   |  tjS )z
        Read-only property accessing the document's author.

        Returns a ``TextStringObject`` or ``None`` if the author is not
        specified.
        )rX   r[   AUTHORrR   rJ   rJ   rK   author   s    zDocumentInformation.authorc                 C   s   |  tjS )z?The "raw" version of author; can return a ``ByteStringObject``.)rU   r[   r`   rR   rJ   rJ   rK   
author_raw   s    zDocumentInformation.author_rawc                 C   s   |  tjS )z
        Read-only property accessing the document's subject.

        Returns a ``TextStringObject`` or ``None`` if the subject is not
        specified.
        )rX   r[   SUBJECTrR   rJ   rJ   rK   subject   s    zDocumentInformation.subjectc                 C   s   |  tjS )z@The "raw" version of subject; can return a ``ByteStringObject``.)rU   r[   rc   rR   rJ   rJ   rK   subject_raw   s    zDocumentInformation.subject_rawc                 C   s   |  tjS )ac  
        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 ``TextStringObject`` or
        ``None`` if the creator is not specified.
        )rX   r[   CREATORrR   rJ   rJ   rK   creator   s    
zDocumentInformation.creatorc                 C   s   |  tjS )z@The "raw" version of creator; can return a ``ByteStringObject``.)rU   r[   rf   rR   rJ   rJ   rK   creator_raw   s    zDocumentInformation.creator_rawc                 C   s   |  tjS )aG  
        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 ``TextStringObject`` or ``None`` if the producer is not
        specified.
        )rX   r[   PRODUCERrR   rJ   rJ   rK   producer   s    
zDocumentInformation.producerc                 C   s   |  tjS )zAThe "raw" version of producer; can return a ``ByteStringObject``.)rU   r[   ri   rR   rJ   rJ   rK   producer_raw   s    z DocumentInformation.producer_rawc                 C   s,   |  tj}|dkrdS t|dddS )z:Read-only property accessing the document's creation date.N' D:%Y%m%d%H%M%S%z)rX   r[   CREATION_DATEr   strptimereplacerS   textrJ   rJ   rK   creation_date   s    z!DocumentInformation.creation_datec                 C   s   |  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.
        )rU   r[   ro   rR   rJ   rJ   rK   creation_date_raw   s    z%DocumentInformation.creation_date_rawc                 C   s,   |  tj}|dkrdS t|dddS )z
        Read-only property accessing the document's modification date.

        The date and time the document was most recently modified.
        Nrl   rm   rn   )rX   r[   MOD_DATEr   rp   rq   rr   rJ   rJ   rK   modification_date   s    z%DocumentInformation.modification_datec                 C   s   |  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.
        )rU   r[   rv   rR   rJ   rJ   rK   modification_date_raw  s    	z)DocumentInformation.modification_date_raw)__name__
__module____qualname____doc__rQ   strr
   rX   rY   propertyr^   r_   ra   rb   rd   re   rg   rh   rj   rk   r   rt   ru   rw   rx   rJ   rJ   rJ   rK   rN   v   s@   				rN   c                	   @   s  e Zd ZdZdeeef eedee	f ddddZ
eeddd	Zeee dd
dZee dddZeee dddZeee dddZee dddZeee dddZedddZedddZeedddZeedddZeedd d!Zeeeef dd"d#Zeeeef dd$d%Z dee! eeeef  ee eeeef  d&d'd(Z"dee! eeeef  ee eeeef  d&d)d*Z#e$ed+d,d-Z%ee!e$f eeef eedd.d/d0Z&ee!e$f eedd&d1d2Z'eeedd3d4d5Z(deeeef d6d7d8Z)eeef dd9d:Z*dee!df ee eeef d;d<d=Z+dee!df ee eeef d;d>d?Z,ee-dd@dAZ.ee-ddBdCZ/dee$ ee e-dDdEdFZ0dee$ ee e-dDdGdHZ1eee2 ddIdJZ3edee4e5f edKdLdMZ6eedNdOdPZ7eedNdQdRZ8e9edSdTdUZ:e9edSdVdWZ;eee<ee=e5de4e$f   e9dXdYdZZ>e$ee9 d[d\d]Z?ee<e dd^d_Z@ee<e dd`daZAeee ddbdcZBee ddddeZCeee ddfdgZDeeeE ddhdiZFeeE ddjdkZGeeeE ddldmZHdede$ef eeeef  ee5 ddndodpZIe5eeeJef dKdqdrZKeeeeJ dsdtduZLeee5f eeJ dKdvdwZMe5eeJ dxdydzZNeOePeef d{d|d}ZQeOePeef d{d~dZReeeeJ dddZSeeeeJ dddZTeeeeJ eeJ dddZUeeeeJ eeJ dddZVeOdd{ddZWeOdd{ddZXeOdd{ddZYeOed{ddZZeOdd{ddZ[eOee eddddZ\eOee d{ddZ]eOeee dddZ^eOee_e`eaf d{ddZbeceOeedddZdeOdd{ddZee<e efegeeePedf f f efeeeePedf f gef ddddZge<e ehePeef  dddZideOee	dddZjdeOee	dddZkeee	f eldddZmeeeef dddZneedddZoedddZpeedddZqeeeeef  dddZreee$ dddZseee$ dddZtdS )	PdfReadera  
    Initialize a PdfReader object.

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

    Args:
        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.
        strict: Determines whether user should be warned of all
            problems and also causes some correctable problems to be fatal.
            Defaults to ``False``.
        password: Decrypt PDF file at initialization. If the
            password is None, the file will not be decrypted.
            Defaults to ``None``
    FN)streamstrictpasswordrE   c           	   	   C   s2  || _ d | _i | _d| _d | _t|dr<d|jkr<tdt t	|t
tfrlt|d}t| }W 5 Q R X | | || _d| _d | _| jrd| _| jtj}|r|d  jnd}tt| jtj  }t||| _|d k	r|nd}| j|tjkr|d k	rt d	d| _n|d k	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   ry   rV   r}   r   openr   readr   _override_encryption_encryptionis_encryptedtrailerrU   TKIDr]   original_bytesr   r3   ENCRYPTr   verifyr   ZNOT_DECRYPTEDr.   r,   )	rS   r   r   r   fhZid_entryZ	id1_entryZencrypt_entrypwdrJ   rJ   rK   rQ   '  sH    
 
zPdfReader.__init__rO   c                 C   s<   | j  }| j dd | j dd}| j |d |S )z
        The first 8 bytes of the file.

        This is typically something like ``'%PDF-1.6'`` and can be used to
        detect if the file is actually a PDF file and which version it is.
        r   rF   zutf-8)r   tellseekr   decode)rS   locZpdf_file_versionrJ   rJ   rK   
pdf_header[  s
    

zPdfReader.pdf_headerc                 C   sF   t j| jkrdS | jt j }t }t|tdr8t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.
        NzEtrailer not found or does not point to document information directory)r   INFOr   rN   rV   typer,   update)rS   objrW   rJ   rJ   rK   metadatak  s    	
zPdfReader.metadatac                 C   s   t ddd | jS )`
        Use the attribute :py:attr:`metadata` instead.

        .. deprecated:: 1.28.0
        getDocumentInfor   rZ   r   r   rR   rJ   rJ   rK   r     s    zPdfReader.getDocumentInfoc                 C   s   t ddd | jS )r   documentInfor   rZ   r   rR   rJ   rJ   rK   r     s    zPdfReader.documentInfoc                 C   s&   zd| _ | jtj jW S d| _ X dS )z(XMP (Extensible Metadata Platform) data.FTN)r   r   r   ROOTxmp_metadatarR   rJ   rJ   rK   r     s    zPdfReader.xmp_metadatac                 C   s   t ddd | jS )r   getXmpMetadatar   rZ   r   r   rR   rJ   rJ   rK   r     s    zPdfReader.getXmpMetadatac                 C   s   t ddd | jS )ze
        Use the attribute :py:attr:`xmp_metadata` instead.

        .. deprecated:: 1.28.0.
        xmpMetadatar   rZ   r   rR   rJ   rJ   rK   r     s    zPdfReader.xmpMetadatac                 C   s:   | j r| jtj d d S | jdkr,|   t| jS dS )a  
        Calculate the number of pages in this PDF file.

        Args:

        Returns:
            The number of pages of the parsed PDF file

        Raises:
            PdfReadError: if file is encrypted and restrictions prevent
                this action.
        /Pages/CountN)r   r   r   r   r   _flattenlenrR   rJ   rJ   rK   _get_num_pages  s
    
zPdfReader._get_num_pagesc                 C   s   t ddd |  S )X
        Use :code:`len(reader.pages)` instead.

        .. deprecated:: 1.28.0
        zreader.getNumPageslen(reader.pages)rZ   r   r   rR   rJ   rJ   rK   getNumPages  s    zPdfReader.getNumPagesc                 C   s   t ddd |  S )r   zreader.numPagesr   rZ   r   rR   rJ   rJ   rK   numPages  s    zPdfReader.numPages)
pageNumberrE   c                 C   s   t ddd | |S )z`
        Use :code:`reader.pages[page_number]` instead.

        .. deprecated:: 1.28.0
        zreader.getPage(pageNumber)zreader.pages[page_number]rZ   )r   	_get_page)rS   r   rJ   rJ   rK   getPage  s      zPdfReader.getPage)page_numberrE   c                 C   s.   | j dkr|   | j dk	s$td| j | S )z
        Retrieve a page by number from this PDF file.

        Args:
            page_number: The page number to retrieve
                (pages begin at zero)

        Returns:
            A :class:`PageObject<pypdf._page.PageObject>` instance.
        Nhint for mypy)r   r   AssertionError)rS   r   rJ   rJ   rK   r     s    
zPdfReader._get_pagec                 C   s   t ddd | jS )\
        Use :py:attr:`named_destinations` instead.

        .. deprecated:: 1.28.0
        namedDestinationsnamed_destinationsrZ   )r   r   rR   rJ   rJ   rK   r     s    zPdfReader.namedDestinationsc                 C   s   |   S )zu
        A read-only dictionary which maps names to
        :class:`Destinations<pypdf.generic.Destination>`
        )_get_named_destinationsrR   rJ   rJ   rK   r     s    zPdfReader.named_destinations)treerW   fileobjrE   c           
      C   s   t  }|t  |dkrXi }tt| jtj }t	j
|krTttt |t	j
 }ndS |dkrd|S | ||| |D ] }||krv| ||||  qqvd|krtt|d }|D ]}| }	| |	||| q|S )aX  
        Extract field data if this PDF contains interactive form fields.

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

        Args:
            tree:
            retval:
            fileobj: A file object (usually a text file) to write
                a report to on all interactive form fields found.

        Returns:
            A dictionary where each key is a field name, and each
            value is a :class:`Field<pypdf.generic.Field>` object. By
            default, the mapping name is used for keys.
            ``None`` if form data could not be located.
        N/Fields)r%   Zattributes_dictr   r"   r   r3   r   r   r   CDZ	ACRO_FORMr
   r>   _check_kids_build_fieldr/   r]   )
rS   r   rW   r   field_attributescatalogattrfieldsffieldrJ   rJ   rK   
get_fields  s*    
zPdfReader.get_fieldsc                 C   s   t ddd | |||S )zQ
        Use :meth:`get_fields` instead.

        .. deprecated:: 1.28.0
        	getFieldsr   rZ   )r   r   )rS   r   rW   r   rJ   rJ   rK   r   :  s    zPdfReader.getFields)parentrE   c                 C   sV   d|krt t|d S d|krD| t t|d d t t|d  S t t|d S d S )N/TM/Parent./T)r   r}   _get_qualified_field_namer3   )rS   r   rJ   rJ   rK   r   H  s    z#PdfReader._get_qualified_field_name)r   rW   r   r   rE   c                 C   s   |  ||| ztt|d }W nj tk
r   z<d|krT| tt|d d }nd}|tt|d 7 }W n tk
r   Y Y d S X Y nX |r| ||| |d t|||< d S )Nr   r   r   rm   r   
)	r   r   r}   KeyErrorr   r3   _write_fieldwriter5   )rS   r   rW   r   r   rT   rJ   rJ   rK   r   V  s(    
zPdfReader._build_fieldc                 C   s0   t j|kr,|t j D ]}| | || qd S rP   )PAKIDSr   r]   )rS   r   rW   r   kidrJ   rJ   rK   r   t  s    
zPdfReader._check_kids)r   r   r   rE   c           	   	   C   s  t  }|t  }|D ]}|t jt jfkr.q|| }z|t jkr|ddddd}|| |kr|| d|||   d nr|t jkrz|| t j }W n" t	k
r   || t j
 }Y nX || d| d n|| d||  d W q t	k
r   Y qX qd S )NZButtonTextZChoice	Signature)z/Btn/Txz/Chz/Sig: r   )r%   
attributesr"   ZKidsZAAZFTr   ZParentZTMr   T)	rS   r   r   r   Zfield_attributes_tupler   	attr_nametypesnamerJ   rJ   rK   r   |  s8    

 
zPdfReader._write_field)full_qualified_namerE   c                 C   s   t tt ddd}|  }|dkr&i S i }| D ]H\}}|ddkr2|r\|d||< q2|d||tt |d |< q2|S )	a  
        Retrieve form fields from the document with textual data.

        Args:
            full_qualified_name: to get full name

        Returns:
            A dictionary. 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, ...
        )kr   rE   c                    s6    |kr S  d t t fdd|D d  S d S )Nr   c                    s   g | ]}|  d  rdqS )r   r   )
startswith).0kkr   rJ   rK   
<listcomp>  s      zGPdfReader.get_form_text_fields.<locals>.indexed_key.<locals>.<listcomp>   )r}   sum)r   r   rJ   r   rK   indexed_key  s    z3PdfReader.get_form_text_fields.<locals>.indexed_keyNz/FTr   z/Vr   )r}   dictr   itemsrU   r   )rS   r   r   Z
formfieldsffr   valuerJ   rJ   rK   get_form_text_fields  s     zPdfReader.get_form_text_fieldsc                 C   s   t ddd |  S )z[
        Use :meth:`get_form_text_fields` instead.

        .. deprecated:: 1.28.0
        getFormTextFieldsr   rZ   )r   r   rR   rJ   rJ   rK   r     s      zPdfReader.getFormTextFields)r   rW   rE   c                 C   sz  |dkrni }t t| jtj }tj|kr:t t|tj }n4tj|krnt t|tj }tj|krnt t|tj }|dkrz|S t	j
|krt t|t	j
 D ]}| | | qntj|kr<t t|tj }tdt|dD ]`}t t||  }||d   }t|trd|kr|d }| ||}	|	dk	r|	||< qn:| D ]0\}
}| }| |
|}	|	dk	rD|	||
< qD|S )z
        Retrieve the named destinations present in the document.

        Args:
            tree:
            retval:

        Returns:
            A dictionary which maps names to
            :class:`Destinations<pypdf.generic.Destination>`.
        Nr   r   r   /D)r   r3   r   r   r   CAZDESTSr>   ZNAMESr   r   r/   r   r]   ranger   r}   rV   _build_destinationr   )rS   r   rW   r   namesr   irT   r   destZk__Zv__valrJ   rJ   rK   r     s<    




z!PdfReader._get_named_destinationsc                 C   s   t ddd | ||S )r   getNamedDestinationsr   rZ   )r   r   )rS   r   rW   rJ   rJ   rK   r     s    
  zPdfReader.getNamedDestinationsc                 C   s   |   S )z
        Read-only property for the outline present in the document.

        (i.e., a collection of 'outline items' which are also known as
        'bookmarks')
        )_get_outlinerR   rJ   rJ   rK   outline  s    zPdfReader.outlinec                 C   s   t ddd | jS )zP
        Use :py:attr:`outline` instead.

        .. deprecated:: 2.9.0
        outlinesr   rZ   )r   r   rR   rJ   rJ   rK   r   !  s    zPdfReader.outlines)noder   rE   c                 C   s   |d krng }t t| jtj }tj|krdt t|tj }t|trF|S |d k	rdd|krdt t|d }| 	 | _
|d krz|S | |}|r|| d|krg }| t t|d | |r|| d|krqt t|d }qz|S )N/Firstz/Next)r   r3   r   r   r   COZOUTLINESrV   r:   r   _namedDests_build_outline_itemappendr   )rS   r  r   r   linesZoutline_objZsub_outlinerJ   rJ   rK   r   +  s0    





zPdfReader._get_outlinec                 C   s   t ddd | ||S )zQ
        Use :py:attr:`outline` instead.

        .. deprecated:: 1.28.0
        getOutlinesr   rZ   )r   r   )rS   r  r   rJ   rJ   rK   r  T  s    zPdfReader.getOutlinesc                 C   s4   t t| jtj }tj|kr,t d|tj S dS dS )u   
        Read-only property for the list of threads.

        See §8.3.2 from PDF 1.7 spec.

        It's an array of dictionaries with "/F" and "/I" properties or
        None if there are no articles.
        r/   N)r   r3   r   r   r   r  ZTHREADS)rS   r   rJ   rJ   rK   threads_  s    

zPdfReader.threads)indirect_referencerE   c                 C   sp   | j dkr dd t| jD | _ |dks2t|tr6dS t|trF|}n|j}| j dk	s^td| j |d}|S )z
        Generate _page_id2num.

        Args:
            indirect_reference:

        Returns:
            The page number.
        Nc                 S   s   i | ]\}}|j j|qS rJ   )r
  idnum)r   r   xrJ   rJ   rK   
<dictcomp>|  s     z:PdfReader._get_page_number_by_indirect.<locals>.<dictcomp>r   )	r   	enumeratepagesrV   r:   intr  r   rU   )rS   r
  r  retrJ   rJ   rK   _get_page_number_by_indirecto  s    

z&PdfReader._get_page_number_by_indirect)pagerE   c                 C   s   |  |jS )a  
        Retrieve page number of a given PageObject.

        Args:
            page: The page to get page number. Should be
                an instance of :class:`PageObject<pypdf._page.PageObject>`

        Returns:
            The page number or -1 if page is not found
        )r  r
  rS   r  rJ   rJ   rK   get_page_number  s    zPdfReader.get_page_numberc                 C   s   t ddd | |S )zV
        Use :meth:`get_page_number` instead.

        .. deprecated:: 1.28.0
        getPageNumberr  rZ   )r   r  r  rJ   rJ   rK   r    s    zPdfReader.getPageNumber)destinationrE   c                 C   s   |  |jS )z
        Retrieve page number of a given Destination object.

        Args:
            destination: The destination to get page number.

        Returns:
            The page number or -1 if page is not found
        )r  r  rS   r  rJ   rJ   rK   get_destination_page_number  s    
z%PdfReader.get_destination_page_numberc                 C   s   t ddd | |S )zb
        Use :meth:`get_destination_page_number` instead.

        .. deprecated:: 1.28.0
        getDestinationPageNumberr  rZ   )r   r  r  rJ   rJ   rK   r    s      z"PdfReader.getDestinationPageNumber)r^   arrayrE   c                 C   s   d\}}t |ttfs4t |tr,t|dks4|d krJt }t||t S |dd \}}|dd  }zt||t||dW S  tk
r   t	d| d| t
 | jr | jd j}|d krt n|}t||t  Y S X d S )N)NNr   r   )Zfit_typeZfit_argszUnknown destination:  )rV   r:   r}   r/   r   r2   r6   Zfitr,   r   ry   r   r  r
  )rS   r^   r  r  typtmpr
  rJ   rJ   rK   r     s,    	
zPdfReader._build_destination)r  rE   c                 C   s  d\}}}zt d|d }W n, tk
rH   | jr@td|d}Y nX d|krt t|d }t t|tj }|dkr|tj }n*d|kr|d }t	|trd	|kr|d	 }t	|t
r| ||}nt	|trz| || j| j}W n" tk
r   | |d }Y nX nN|d kr(| ||}n6| jr@td
|ntd|dt | |d }|rd|krt
dd |d D |td< d|kr|d |td< d|kr|d |td< ||_|S )N)NNNr}   z/Titlez(Outline Entry Missing /Title attribute: rm   z/Az/GoToz/Destr   zUnexpected destination zRemoved unexpected destination z from destinationz/Cc                 s   s   | ]}t |V  qd S rP   )r7   )r   crJ   rJ   rK   	<genexpr>  s     z0PdfReader._build_outline_item.<locals>.<genexpr>z/Fr   )r   r   r   r,   r3   r9   r&   SDrV   r/   r   r}   r  Z
dest_arrayr   ry   r  )rS   r  r   r^   Zoutline_itemactionZaction_typerJ   rJ   rK   r    sX    


 





zPdfReader._build_outline_itemc                 C   s   t | j| jS )zVRead-only property that emulates a list of :py:class:`Page<pypdf._page.Page>` objects.)r   r   r   rR   rJ   rJ   rK   r    s    zPdfReader.pagesc                    s    fddt t jD S )z
        A list of labels for the pages in this document.

        This property is read-only. The labels are in the order that the pages
        appear in the document.
        c                    s   g | ]}t  |qS rJ   )page_index2page_label)r   r   rR   rJ   rK   r   (  s     z)PdfReader.page_labels.<locals>.<listcomp>)r   r   r  rR   rJ   rR   rK   page_labels   s    zPdfReader.page_labelsc                 C   s0   t t| jtj }tj|kr,t t|tj S dS )a  
        Get the 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   ZPAGE_LAYOUTr9   )rS   r   rJ   rJ   rK   page_layout*  s    
zPdfReader.page_layoutc                 C   s   t ddd | jS )U
        Use :py:attr:`page_layout` instead.

        .. deprecated:: 1.28.0
        getPageLayoutr'  rZ   r   r'  rR   rJ   rJ   rK   r)  F  s    zPdfReader.getPageLayoutc                 C   s   t ddd | jS )r(  
pageLayoutr'  rZ   r*  rR   rJ   rJ   rK   r+  O  s    zPdfReader.pageLayoutc                 C   s.   z| j tj d W S  tk
r(   Y dS X dS )a2  
        Get the 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   rR   rJ   rJ   rK   	page_modeY  s    zPdfReader.page_modec                 C   s   t ddd | jS )S
        Use :py:attr:`page_mode` instead.

        .. deprecated:: 1.28.0
        getPageModer,  rZ   r   r,  rR   rJ   rJ   rK   r.  s  s    zPdfReader.getPageModec                 C   s   t ddd | jS )r-  pageModer,  rZ   r/  rR   rJ   rJ   rK   r0  |  s    zPdfReader.pageMode)r  inheritr
  rE   c                 C   s(  t tjt tjt tjt tjf}|d kr0i }|d krZ| jtj 	 }|d 	 }g | _
d}tj|krr|tj }|dkr|D ]}||kr~|| ||< q~|tj D ].}i }	t|tr||	d< | j|	 |f|	 qnP|dkr$t| D ]\}
}|
|kr|||
< qt| |}|| | j
| d S )Nr   r
  z/Page)r9   PGZ	RESOURCESZMEDIABOXZCROPBOXZROTATEr   r   r   r]   r   r   ZTYPEr   rV   r8   r   listr   r   r   r  )rS   r  r1  r
  Zinheritable_page_attributesr   tr   r  ZaddtZattr_inr   Zpage_objrJ   rJ   rK   r     s<    






zPdfReader._flattenc                 C   s  | j |j \}}t|d|  }tt|d dks6t||d k sFttt|	 }t
|d D ]}t| |dd t|}t| |dd t|}t| |dd ||jkrqb| jr||krtd|t|d | d t| |dd zt|| }	W nf tk
rz }
 zFtd	| d
|j d|j d|
 t | jrdtd|
 t }	W 5 d }
~
X Y nX |	  S | jrtdt S )Nr   /Typez/ObjStmz/Nr  r   zObject is in wrong index.r  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_objStmr  r8   r]   r   r}   r   r   r   get_datar   r   r   r;   Zread_from_streamr   r,   r  r?   r-   r   
generationry   r:   )rS   r
  ZstmnumidxZobj_stmstream_datar   Zobjnumoffsetr   excrJ   rJ   rK   _get_object_from_stream  sF    


z!PdfReader._get_object_from_stream)numgenrE   c                 C   s   t |||  S )z
        Used to ease development.

        This is equivalent to generic.IndirectObject(num,gen,self).get_object()

        Args:
            num:
            gen:

        Returns:
            A PdfObject
        )r8   r]   )rS   r>  r?  rJ   rJ   rK   _get_indirect_object  s    zPdfReader._get_indirect_objectc           	   
   C   s@  t |trt|d| }| |j|j}|d k	r2|S |jdkrV|j| jkrV| |}n|j| jkr|j| j|j kr| j	
|ji 
|jdrt S | j|j |j }| j|d z| | j\}}W n tk
r   t| jdrt| j }n2| j }| jdd | jd}| j|d td|j d|j d |}|d k	rtd|j d	|j d
t |dd | j|j |j< | j|dd  | | j\}}nd}Y nX ||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rX||jksXtt| j| }| j s*| j!d k	r*| j!" st#dt$t%|}| j!&||j|j}n|t| jdrt| j }n2| j }| jdd | jd}| j|d td|j d|j d |}|d k	rtd|j d|j dt |j| jkr`i | j|j< |dd | j|j |j< | j|'dd  t(| j | jdd t| j| }| j s*| j!d k	r*| j!" st#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 (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.)*rV   r  r8   cache_get_indirect_objectr8  r  r6  r=  xrefxref_free_entryrU   r:   r   r   read_object_header	Exceptionr   bytesrA  r   r   researchencoder   ry   startr   r   r,   r   r?   r   r   Zis_decryptedr+   r   r<   Zdecrypt_objectendr   cache_indirect_object)	rS   r
  rW   rL  r  r8  bufpmrJ   rJ   rK   r]     s    
 

 



  
  



    zPdfReader.get_object)indirectReferencerE   c                 C   s   t ddd | |S )zQ
        Use :meth:`get_object` instead.

        .. deprecated:: 1.28.0
        	getObjectr]   rZ   )r   r]   )rS   rR  rJ   rJ   rK   rS  {  s    zPdfReader.getObject)r   rE   c                 C   s   d}t | |t|O }|dd t|}|t|O }|dd t|}|t|O }|dd |d}t| |dd |r| jrtd| d| t t	|t	|fS )NFr  r      z.Superfluous whitespace found in object header r  )
r   r   r   r   r   r   r   r   ry   r  )rS   r   extrar  r8  _objrJ   rJ   rK   rF    s&    

zPdfReader.read_object_headerc                 C   s   t ddd | |S )zY
        Use :meth:`read_object_header` instead.

        .. deprecated:: 1.28.0
        readObjectHeaderrF  rZ   )r   rF  )rS   r   rJ   rJ   rK   rW    s    zPdfReader.readObjectHeader)r8  r  rE   c                 C   s   | j ||fS rP   )r   rU   rS   r8  r  rJ   rJ   rK   rC    s    z#PdfReader.cache_get_indirect_objectc                 C   s   t ddd | ||S )z`
        Use :meth:`cache_get_indirect_object` instead.

        .. deprecated:: 1.28.0
        cacheGetIndirectObjectrC  rZ   )r   rC  rX  rJ   rJ   rK   rY    s      z PdfReader.cacheGetIndirectObject)r8  r  r   rE   c                 C   s^   ||f| j kr6d| d| }| jr,t|t|t || j ||f< |d k	rZt||| |_|S )NzOverwriting cache for r  )r   r   r,   r   ry   r8   r
  )rS   r8  r  r   msgrJ   rJ   rK   rN    s    
zPdfReader.cache_indirect_objectc                 C   s   t dd | |||S )z\
        Use :meth:`cache_indirect_object` instead.

        .. deprecated:: 1.28.0
        cacheIndirectObjectrN  )r   rN  )rS   r8  r  r   rJ   rJ   rK   r[    s    
zPdfReader.cacheIndirectObjectc              
   C   s0  |  | | | | |}| ||}|dkrV| jrD|rDtdtd| dt | ||| | j	r,| js,|
 }| j D ]\}}|dkrqt| }|D ]t}||| d z| |\}	}
W n tk
r   Y  qY nX |	|| j	 kr| j| | | j| |	< | j| |= qq||d d S )Nr   zBroken xref tablezincorrect startxref pointer()  )_basic_validation_find_eof_marker_find_startxref_pos_get_xref_issuesr   r,   r   ry   _read_xref_tables_and_trailersr   r   rD  r   sortedkeysr   rF  
ValueError)rS   r   	startxrefxref_issue_nrr   r?  Z
xref_entryZxref_kidpidZ_pgenrJ   rJ   rK   r     s6    



zPdfReader.readc                 C   sl   | dtj | std| jrh| dtj |d}|dkrZtd|	d d| dtj 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   )rS   r   Zheader_byterJ   rJ   rK   r^    s    
zPdfReader._basic_validationc                 C   s:   d}d}|d d dkr6|  |k r,tdt|}qd S )NrF   r   rj  s   %%EOFzEOF marker not found)r   r,   r   )rS   r   Zlast_mblinerJ   rJ   rK   r_  
  s    zPdfReader._find_eof_markerc                 C   s~   t |}zt|}W nD tk
rX   |ds6tdt|dd  }tdt Y n"X t |}|dd dkrztd|S )z
        Find startxref entry - the location of the xref table.

        Args:
            stream:

        Returns:
            The bytes offset
        s	   startxrefzstartxref not found	   Nz startxref on same line as offset)r   r  re  r   r,   stripr   ry   )rS   r   ro  rf  rJ   rJ   rK   r`    s    

zPdfReader._find_startxref_posc                 C   s  | d}|d d dkr"tdt| |dd d}ttt|| }|rl|dkrl|| _| jrlt	d	t
 d
}t| |dd ttt|| }t| |dd d}||k r| d}|d dkr|dd | d}q|d dkr|dd z8|d d d\}}	|dd }
t|t|	 }}W n tk
r   t|dr`t| }n(| }|dd | d}|| t| d |}|d krt	d| dt
 d}d}n(t	d| dt
 t|d}| }Y nX || jkri | j|< i | j|< || j| kr$nj|| j| |< z|
dk| j| |< W n tk
r^   Y nX z|
dk| jd |< W n tk
r   Y nX |d7 }|d7 }qt| |dd | d}|dkr|dd q:qq:d S )N   rT  s   refzxref table read errorr  r   Tr   zFXref table not zero-indexed. ID numbers for objects will be corrected.F      
is   0123456789t             rA  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   ry   splitrG  r   rH  rA  r   rI  rJ  rK  grouprL  rD  rE  )rS   r   refZ	firsttimer>  rD   Zcntro  Zoffset_bZgeneration_bZentry_type_br;  r8  rO  rP  r   Z
trailertagrJ   rJ   rK   _read_standard_xref_table+  s    












z#PdfReader._read_standard_xref_table)r   rf  rg  rE   c           
   
   C   s  i | _ i | _i | _t | _|d k	r||d |d}|dkrL|d}|dkr`| |}q|rz| | W qW n t	k
r   d}Y nX q|
 rz| |}W n^ t	k
r
 } z>tj| jkrtd|j t W Y qntd|j W 5 d }~X Y nX tjtjtjtjf}|D ]0}||kr$|| jkr$||| jt|< q$d|kr| }	|tt|d d d | | ||	d d|krtt|d }nqq| ||}qd S )	Nr   r   rt     xz!Previous trailer can not be read ztrailer can not be read /XRefStm/Prev)rD  rE  r6  r3   r   r   r   
_read_xref_rebuild_xref_tablerG  isdigit_read_pdf15_xref_streamr   r   r   argsry   r,   r   r   r   Zraw_getr9   r   r   r  _read_xref_other_error)
rS   r   rf  rg  r  
xrefstreameZtrailer_keysrT   rP  rJ   rJ   rK   rb    sR    






"


z(PdfReader._read_xref_tables_and_trailersc                 C   s   |  | t| |dd ttttf t|| }| D ]\}}|| j	kr>|| j	|< q>d|kr|
 }|tt|d d d z| | W n* tk
r   td|d  dt Y nX ||d d|kr|d }|S 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  rG  r   ry   )rS   r   new_trailerrT   r   rP  rf  rJ   rJ   rK   r    s,    


zPdfReader._read_xref)r   rf  rE   c                 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 rp||7 }|  S qpd| j	kr| j stdt z| 
| W d S  tk
r   tdY nX tdd S )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   rs     xrefr  
   rj  z/Rootz"Invalid parent xref., rebuild xrefzcan not rebuild xrefz/Could not find xref table at specified location)r   r,   r   ry   r   r   findr   r  r   r  rG  )rS   r   rf  r  Zxref_locZlookrJ   rJ   rK   r    s:    




z PdfReader._read_xref_other_errorc                    s  | dd |\}}ttt|}tt|d dks@t||| tt	|
 |dd|dg}ttttf |d t d	kstjrt d	krtd
  tttttdf f d fdd}tttttdf f tdfdd}||| |S )Nr  r   r5  z/XRefz/Indexr   z/Sizez/WrT  zToo many entry sizes: .)r   rE   c                    s<    |  dkr(  |  }t| |  S | dkr4dS dS d S )Nr   r   )r   rL   )r   rC   )entry_sizesr:  rJ   rK   	get_entry  s    z4PdfReader._read_pdf15_xref_stream.<locals>.get_entry)r>  r8  rE   c                    s   |  j |g kp|  jkS rP   )rD  rU   r6  )r>  r8  rR   rJ   rK   used_before+  s    z6PdfReader._read_pdf15_xref_stream.<locals>.used_before)r   rF  r   r0   r?   r}   r   rN  r   r   r7  rU   r   r   r   r   r,   r  r   r   bool_read_xref_subsections)rS   r   r  r8  r  	idx_pairsr  r  rJ   )r  rS   r:  rK   r    s    &&z!PdfReader._read_pdf15_xref_streamc                 C   s~   |  |d d | d}|dkr&dS | d}|dkrzd}|dkr\| d}|dkr<dS q<|| d7 }| d	krzd
S dS )z
        Return an int which indicates an issue. 0 means there is no issue.

        Args:
            stream:
            startxref:

        Returns:
            0 means no issue, other values represent specific issues.
        r   r   s   
 	rr  r  r   s   0123456789 	r   s   objrT  )r   r   lower)r   rf  ro  rJ   rJ   rK   ra  3  s    


zPdfReader._get_xref_issuesc           	      C   s   i | _ |dd |d}td|D ]H}t|d}t|d}|| j kr\i | j |< |d| j | |< q(|dd td|D ]N}||dd tt	t
t
f t|| }t| D ]\}}|| j|< qqd S )Nr   r  s(   [\r\n \t][ \t]*(\d+)[ \t]+(\d+)[ \t]+objr   r   s$   [\r\n \t][ \t]*trailer[\r\n \t]*(<<))rD  r   r   rI  finditerr  r|  rL  r   r   r   r?   r3  r   r   )	rS   r   Zf_rQ  r  r8  r  rT   r   rJ   rJ   rK   r  P  s    


zPdfReader._rebuild_xref_table.)r  r  r  rE   c                 C   s   |  |D ]\}}t||| D ]}|d}|dkrF|d}|d}	q |dkr|d}
|d}|| jkrri | j|< |||s|
| j| |< q |dkr|d}|d}d}|||s||f| j|< q | jr td| q q
d S )Nr   r   r   zUnknown xref type: )_pairsr   rD  r6  r   r,   )rS   r  r  r  rL  rD   r>  Z	xref_typeZnext_free_objectZnext_generationZbyte_offsetr8  Z
objstr_numZ	obstr_idxrJ   rJ   rK   r  c  s*    




z PdfReader._read_xref_subsections)r  rE   c                 c   s:   d}|| ||d  fV  |d7 }|d t |krq6qd S )Nr   r   r   )r   )rS   r  r   rJ   rJ   rK   r    s
    zPdfReader._pairsr   )r   limit_offsetrE   c                 C   s   t ddd g }| dks(| |kr0td|d}| dk rNtd|d	d |d
krd}|d
kr|d}|d
kr|dd d}| dk rtd|d	d qf||rdndd qq|| q|  d|S )z.. deprecated:: 2.1.0read_next_end_linez4.0.0)Z
removed_inr   z!Could not read malformed PDF filer   r   zEOL marker not found)   
   Fr  Tr   )r   r   r,   r   r   r  reversejoin)rS   r   r  Z
line_partsr  ZcrlfrJ   rJ   rK   r    s4    


 zPdfReader.read_next_end_linec                 C   s   t dd | ||S )z.. deprecated:: 1.28.0readNextEndLinerZ   )r   r  )rS   r   r  rJ   rJ   rK   r    s    
zPdfReader.readNextEndLine)r   rE   c                 C   s   | j std| j |S )a}  
        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.

        Args:
            password: The password to match.

        Returns:
            A `PasswordType`.
        r   )r   r,   r   )rS   r   rJ   rJ   rK   decrypt  s    zPdfReader.decrypt)permissions_coderE   c                 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 )Nrr  r   printrF   modifyru  copy    annotations   Zformsi   Zaccessabilityi   Zassemblei   Zprint_high_qualityrJ   )rS   r  permissionsrJ   rJ   rK   decode_permissions  s    
zPdfReader.decode_permissionsc                 C   s   t j| jk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()<pypdf.PdfReader.decrypt>` method is called.
        )r   r   r   rR   rJ   rJ   rK   r     s    zPdfReader.is_encryptedc                 C   s   t ddd | jS )V
        Use :py:attr:`is_encrypted` instead.

        .. deprecated:: 1.28.0
        getIsEncryptedr   rZ   r   r   rR   rJ   rJ   rK   r    s    zPdfReader.getIsEncryptedc                 C   s   t ddd | jS )r  isEncryptedr   rZ   r  rR   rJ   rJ   rK   r    s    zPdfReader.isEncryptedc           
      C   s   d }i }t t| jtj }d|ks*|d s.d S t t|d }d|krt t|d }t|}|D ]D}|}t|}t	|t
r^t tt | }|r^t|j}	|	||< q^|S )N	/AcroFormz/XFA)r   r3   r   r   r   r>   r/   iternextrV   r8   r
   r4   r]   zlib
decompress_data)
rS   r   rW   r   r   r   r   tagr   esrJ   rJ   rK   xfa  s$    

zPdfReader.xfa)r   rE   c                 C   s  t t| jtj }d|ks(t|d ts,dS t t|td }d|krJdS t }t||td< |td |td< | dt	dd | j
 D d	 | t }||j ||td< t t|d D ]6}| }d
|krtd|j dt |j|td
< q|S )z
        Add a top level form that groups all form fields below it.

        Args:
            name: text string of the "/T" Attribute of the created object

        Returns:
            The created object. ``None`` means no object was created.
        r  Nr   r   z/Kidsr   c                 S   s   g | ]\}}|d kr|qS )r   rJ   )r   gr   rJ   rJ   rK   r   *  s      z.PdfReader.add_form_topname.<locals>.<listcomp>r   r   zTop Level Form Field z have a non-expected parent)r   r3   r   r   r   rV   r9   r=   rN  maxr   rd  r/   r  r
  r]   r   ry   )rS   r   r   acroforminterimZarror   rJ   rJ   rK   add_form_topname  s:    

 zPdfReader.add_form_topnamec                 C   s~   t t| jtj }d|ks(t|d ts,dS t t|td }d|krJdS t tt t|td d  }t	||td< |S )z
        Rename top level form field that all form fields below it.

        Args:
            name: text string of the "/T" field of the created object

        Returns:
            The modified object. ``None`` means no object was modified.
        r  Nr   r   r   )
r   r3   r   r   r   rV   r9   r/   r]   r=   )rS   r   r   r  r  rJ   rJ   rK   rename_form_topname:  s    

 zPdfReader.rename_form_topname)FN)NNN)NNN)F)NN)NN)NN)NN)NNN)r   )r   )ury   rz   r{   r|   r   r   r   r  r}   rH  rQ   r~   r   r
   rN   r   r   r   rB   r   r   r   r  r   r   r   r   r   r   r   r   r   r   r>   r   r   r3   r   r   r   r   r   r   r   r   r@   r   r   r   r  r/   r	  r:   r8   r  r  r  r2   r  r  r	   r;   r   r  r  r&  r'  r)  r+  rA   r,  r.  r0  r   r<   r=  r@  r]   rS  r   r   rF  rW  rC  rY  rN  r[  r   r^  r_  r`  r~  rb  r  r  r0   r4   r1   r  staticmethodra  r  r   r  r   r  r  r  r   r  r  r   r  r  r  r  r  rJ   rJ   rJ   rK   r     s    
4							   4   


  %&  

8  

	
    *    	!C				   /6
 
      &n  1 *(" 	  "  			*r   c                       s&   e Zd Zeedd fddZ  ZS )PdfFileReaderN)r  kwargsrE   c                    s:   t ddd d|kr(t|dk r(d|d< t j|| d S )Nr  r   rZ   r   r   T)r   r   superrQ   )rS   r  r  	__class__rJ   rK   rQ   W  s    zPdfFileReader.__init__)ry   rz   r{   r   rQ   __classcell__rJ   rJ   r  rK   r  V  s   r  )_rl  rI  rG   r  r   ior   pathlibr   typingr   r   r   r   r	   r
   r   r   r   r   r   r   Z_pager   r   Z_page_labelsr   r%  _utilsr   r   r   r   r   r   r   r   r   r   r   r   	constantsr    r   r!   r   r"   r#   r  r$   r[   r%   r&   r'   r2  r(   r   r)   r   errorsr*   r+   r,   r-   r.   Zgenericr/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r   r@   rA   xmprB   rH  r  rL   rM   rN   r   r  rJ   rJ   rJ   rK   <module>   sX   ,8L""               P