
    ,h@                       U d dl Z d dlZd dl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 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 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)m*Z* ddl+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6 da7e8e9d<   da:e8e9d<   g a;ee8   e9d<   	 	 	 d/dee<e8df   dee<e8df   dee<ee8   df   dee8e8ee8   f   fdZ=dede<de	e<   de5fdZ>dede<de	e<   de5fdZ?dede<dee5e@f   ddfdZAdede<dee5e@f   ddfdZBdede<ddfd ZCdede<ddfd!ZDde<d"e	e<   deEfd#ZFde<d"e	e<   deEfd$ZG G d% d&      ZH G d' d(e.      ZI G d) d*      ZJ	 	 d0d+e.d,eee<      d-eee<      deee<   ee<   f   fd.ZKy)1    N)Decimal)AnyCallableDictIterableIteratorListOptionalSetTupleUnioncast   )build_char_mapunknown_char_map)PdfReaderProtocol)CompressedTransformationMatrixFileTransformationMatrixTypedeprecation_no_replacementdeprecation_with_replacementlogger_warningmatrix_multiply)AnnotationDictionaryAttributes)ImageAttributes)PageAttributes)
Ressources)PageSizeNotDefinedError)_xobj_to_image)ArrayObjectContentStreamDictionaryObjectEncodedStreamObjectFloatObjectIndirectObject
NameObject
NullObjectNumberObjectRectangleObjectencode_pdfdocencodingCUSTOM_RTL_MINCUSTOM_RTL_MAXCUSTOM_RTL_SPECIAL_CHARS_min_maxspecialsreturnc                 ^   t        | t              r| ant        | t              rt	        |       at        |t              r|ant        |t              rt	        |      at        |t              r|D cg c]  }t	        |       c}ant        |t              r|at        t
        t        fS c c}w )a  
    Change the Right-To-Left and special characters custom parameters.

    Args:
        _min: The new minimum value for the range of custom characters that
            will be written right to left.
            If set to `None`, the value will not be changed.
            If set to an integer or string, it will be converted to its ASCII code.
            The default value is -1, which sets no additional range to be converted.
        _max: The new maximum value for the range of custom characters that will be written right to left.
            If set to `None`, the value will not be changed.
            If set to an integer or string, it will be converted to its ASCII code.
            The default value is -1, which sets no additional range to be converted.
        specials: The new list of special characters to be inserted in the current insertion order.
            If set to `None`, the current value will not be changed.
            If set to a string, it will be converted to a list of ASCII codes.
            The default value is an empty list.

    Returns:
        A tuple containing the new values for `CUSTOM_RTL_MIN`, `CUSTOM_RTL_MAX`, and `CUSTOM_RTL_SPECIAL_CHARS`.
    )
isinstanceintr,   strordr-   r.   list)r/   r0   r1   xs       N/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/PyPDF2/_page.pyset_custom_rtlr;   T   s    6 $	D#	T$	D#	T(C 4<#=qCF#= 	Hd	##+ >+CCC $>s   1B*selfnamedefaultsc                    | j                  |      }t        |t              r|S ||D ]  }| j                  |      }| n t        |t              r| j                  j                  |      }t        |      }t        | ||       |S N)getr4   r)   r%   pdf
get_object_set_rectangle)r<   r=   r>   retvalds        r:   _get_rectanglerG   ~   s    ;?88D>F&/*~ 	AXXa[F!	 &.)$$V,V$F4v&M    c                 4    t        dd       t        | ||      S )NgetRectangle3.0.0)r   rG   )r<   r=   r>   s      r:   rJ   rJ      s     ~w7$h//rH   valuec                 $    t        |      }|| |<   y r@   r&   r<   r=   rL   s      r:   rD   rD      s    dDDJrH   c                 6    t        dd       t        | ||       y )NsetRectanglerK   )r   rD   rO   s      r:   rQ   rQ      s     ~w74u%rH   c                 
    | |= y r@    r<   r=   s     r:   _delete_rectanglerU      s	    T
rH   c                 "    t        dd       | |= y )NdeleteRectanglerK   )r   rT   s     r:   rW   rW      s    0':T
rH   fallbackc                 4     t         fd fd fd      S )Nc                     t        |       S r@   )rG   )r<   rX   r=   s    r:   <lambda>z,_create_rectangle_accessor.<locals>.<lambda>   s    ^D$9 rH   c                     t        | |      S r@   )rD   )r<   rL   r=   s     r:   r[   z,_create_rectangle_accessor.<locals>.<lambda>   s    N4u= rH   c                     t        |       S r@   )rU   rT   s    r:   r[   z,_create_rectangle_accessor.<locals>.<lambda>   s    &tT2 rH   )propertyr=   rX   s   ``r:   _create_rectangle_accessorr`      s    9=2 rH   c                 2    t        dd       t        | |      S )NcreateRectangleAccessorrK   )r   r`   r_   s     r:   rb   rb      s     8'B%dH55rH   c                       e Zd ZdZddefdZedefd       Ze	dedefd       Z
dded	edd fd
Z	 ddee   dee   dd fdZdedd fdZdefdZdeeeef   eeef   ee   f   deeeef   ee   f   fdZy)Transformationu  
    Represent a 2D transformation.

    The transformation between two coordinate systems is represented by a 3-by-3
    transformation matrix matrix with the following form::

        a b 0
        c d 0
        e f 1

    Because a transformation matrix has only six elements that can be changed,
    it is usually specified in PDF as the six-element array [ a b c d e f ].

    Coordinate transformations are expressed as matrix multiplications::

                                 a b 0
     [ x′ y′ 1 ] = [ x y 1 ] ×   c d 0
                                 e f 1


    Example
    -------

    >>> from PyPDF2 import Transformation
    >>> op = Transformation().scale(sx=2, sy=3).translate(tx=10, ty=20)
    >>> page.add_transformation(op)
    ctmc                     || _         y r@   re   r<   re   s     r:   __init__zTransformation.__init__   s	    rH   r2   c                     | j                   d   | j                   d   df| j                   d   | j                   d   df| j                   d   | j                   d   dffS )z
        Return the transformation matrix as a tuple of tuples in the form:
            ((a, b, 0), (c, d, 0), (e, f, 1))
        r   r               rg   r<   s    r:   matrixzTransformation.matrix   s\     XXa[$((1+q)XXa[$((1+q)XXa[$((1+q)
 	
rH   rp   c                 Z    | d   d   | d   d   | d   d   | d   d   | d   d   | d   d   fS )a  
        Compresses the transformation matrix into a tuple of (a, b, c, d, e, f).

        Args:
            matrix: The transformation matrix as a tuple of tuples.

        Returns:
            A tuple representing the transformation matrix as (a, b, c, d, e, f)
        r   r   rk   rS   )rp   s    r:   compresszTransformation.compress   sP     1IaL1IaL1IaL1IaL1IaL1IaL
 	
rH   txtyc           	      n    | j                   }t        |d   |d   |d   |d   |d   |z   |d   |z   f      S )z
        Translate the contents of a page.

        Args:
            tx: The translation along the x-axis.
            ty: The translation along the y-axis.

        Returns:
            A new `Transformation` instance
        r   r   rk   rl   rm   rn   rg   )re   rd   )r<   rs   rt   ms       r:   	translatezTransformation.translate   sE     HH1Q41qtQqT1Q4"9adRi"PQQrH   Nsxsyc                     ||t        d      ||}||}|J |J |ddfd|dfdf}t        j                  t        | j                  |            }t        |      S )a  
        Scale the contents of a page towards the origin of the coordinate system.

        Typically, that is the lower-left corner of the page. That can be
        changed by translating the contents / the page boxes.

        Args:
            sx: The scale factor along the x-axis.
            sy: The scale factor along the y-axis.

        Returns:
            A new Transformation instance with the scaled matrix.
        z!Either sx or sy must be specifiedr   r   r   r   )
ValueErrorrd   rr   r   rp   )r<   rx   ry   opre   s        r:   scalezTransformation.scale	  s{      :"*@AA:B:B~~)+Q
QAJ	'J%%odkk2&FGc""rH   rotationc                 D   t        j                  |      }t        j                  |      t        j                  |      dft        j                  |       t        j                  |      dfdf}t        j                  t        | j                  |            }t	        |      S )z
        Rotate the contents of a page.

        Args:
            rotation: The angle of rotation in degrees.

        Returns:
            A new `Transformation` instance with the rotated matrix.
        r   r{   )mathradianscossinrd   rr   r   rp   )r<   r   r}   re   s       r:   rotatezTransformation.rotate%  s     <<)XXh(!3Q7hhx  $((8"4a8(

 %%odkk2&FGc""rH   c                 "    d| j                    dS )NzTransformation(ctm=)rg   ro   s    r:   __repr__zTransformation.__repr__8  s    $TXXJa00rH   ptc                 p   t        |d         | j                  d   z  t        |d         | j                  d   z  z   | j                  d   z   t        |d         | j                  d   z  t        |d         | j                  d   z  z   | j                  d   z   f}t        |t              rt        |      S |S )a  
        Apply the transformation matrix on the given point.

        Args:
            pt: A tuple or list representing the point in the form (x, y)

        Returns:
            A tuple or list representing the transformed point in the form (x', y')
        r   r   rk   rm   rl   rn   )floatre   r4   r8   )r<   r   pt1s      r:   apply_onzTransformation.apply_on;  s     "Q%L488A;&r!u)CCdhhqkQ"Q%L488A;&r!u)CCdhhqkQ
 'r40tCy9c9rH   ))r   r   r   r   r   r   )r   r   NN)__name__
__module____qualname____doc__r   ri   r^   r   rp   staticmethodrr   r   rw   r
   r~   r   r6   r   r   r   r   r	   r   rS   rH   r:   rd   rd      s   <:  	
0 	
 	
 
1 
6T 
 
&RE R5 R9I R AE#5/#.6uo#	#8#u #)9 #&1# 1:gw./ue|1Dd5kQR:	uUE\"DK/	0:rH   rd   c                   	    e Zd ZU dZd ed<   	 	 	 dndee   dee   dee   ddfdZe	dee   fd	       Z
e
j                  d
ee   ddfd       Z
def fdZe	defd       Ze	 	 	 dndee   deeedf   deeedf   dd fd       Ze	 	 	 dndee   deeedf   deeedf   dd fd       Ze	dee   fd       Ze	defd       Zej                  deeef   ddfd       ZdodZdedd fdZdedd fdZdedd fdZdedd fdZede de dede!e"e#ef   e"e#ef   f   fd       Z$ed e%d!e"eef   dede%fd"       Z&ed#edede%fd$       Z'ed#eded%e(de%fd&       Z)dee%   fd'Z*dee%   fd(Z+dpd)d d*e,ddfd+Z-dqd,Z.	 	 	 drd)d d-ee/ege%f      d%ee(   d*e,ddf
d.Z0d)d d%ee(   ddfd/Z1	 dpd)d d%ee(e2f   d*e,ddfd0Z3	 dpd)d d1ed*e,ddfd2Z4	 dpd)d d3ed*e,ddfd4Z5	 dpd)d d5ed6ed*e,ddf
d7Z6	 dpd)d d3ed5ed6ed*e,ddfd8Z7	 dpd)d d3ed1ed*e,ddf
d9Z8	 dpd)d d1ed5ed6ed*e,ddfd:Z9	 dpd)d d3ed1ed5ed6ed*e,ddfd;Z:	 dpd%ee2e(f   d*e,ddfd<Z;d%e(ddfd=Z<d>ed?eddfd@Z=dAeddfdBZ>dAeddfdCZ?dededdfdDZ@dededdfdEZAdodFZBdodGZCde#fdHZDdIdJeEj                  dddfdKededLe!edMf   dNedOee#   dPee/eeeegdf      dQee/eeeegdf      dRee/eeeeegdf      de#fdSZGdddIdJddddTdUedVe#dWe#dLeee!edMf   f   dNedPee/eeeegdf      dQee/eeeegdf      dRee/eeeeegdf      de#fdXZH	 	 	 	 	 dsdYeIdLe!edMf   dNedPee/eeeegdf      dQee/eeeegdf      dRee/eeeeegdf      de#fdZZJ	 dtdVe#dWe#de#fd[ZKde!eLe#   eLe#   f   fd\ZM eNeEj                  d]      ZP	 e	deQfd^       ZReRj                  d
eQddfd_       ZR eNd`eEj                  f      ZS	 e	deQfda       ZTeTj                  d
eQddfdb       ZT eNdcd`eEj                  f      ZU	 e	deQfdd       ZVeVj                  d
eQddfde       ZV eNdfd`eEj                  f      ZW	 e	deQfdg       ZXeXj                  d
eQddfdh       ZX eNdid`eEj                  f      ZY	 e	deQfdj       ZZeZj                  d
eQddfdk       ZZe	dee[   fdl       Z\e\j                  d
ee[   ddfdm       Z\ xZ]S )u
PageObjecta)  
    PageObject represents a single page within a PDF file.

    Typically this object will be created by accessing the
    :meth:`get_page()<PyPDF2.PdfReader.get_page>` method of the
    :class:`PdfReader<PyPDF2.PdfReader>` class, but it is
    also possible to create an empty page with the
    :meth:`create_blank_page()<PyPDF2._page.PageObject.create_blank_page>` static method.

    Args:
        pdf: PDF file the page belongs to.
        indirect_reference: Stores the original indirect reference to
            this object in its source PDF
    original_pageNrB   indirect_referenceindirect_refr2   c                     t        j                  |        || _        |)t        j                  dt
               |t        d      |}|| _        y )Nzoindirect_ref is deprecated and will be removed in PyPDF2 4.0.0. Use indirect_reference instead of indirect_ref.z/Use indirect_reference instead of indirect_ref.)r"   ri   rB   warningswarnDeprecationWarningr|   r   )r<   rB   r   r   s       r:   ri   zPageObject.__init__`  sX     	!!$'03#MMT # "- !RSS!-"4rH   c                 N    t        j                  dt               | j                  S )Nzmindirect_ref is deprecated and will be removed in PyPDF2 4.0.0Use indirect_reference instead of indirect_ref.)r   r   r   r   ro   s    r:   r   zPageObject.indirect_refv  s'    B 	
 &&&rH   rL   c                     || _         y r@   )r   r<   rL   s     r:   r   zPageObject.indirect_ref  s
    "'rH   c                 F    t         |          }|dt        |       z  z  }|S )Ns   %d)superhash_value_dataid)r<   data	__class__s     r:   r   zPageObject.hash_value_data  s(    w&(4  rH   c                 B    | j                  t        j                  d      S )a  
        A read-only positive number giving the size of user space units.

        It is in multiples of 1/72 inch. Hence a value of 1 means a user space
        unit is 1/72 inch, and a value of 3 means that a user space unit is
        3/72 inch.
        r   )rA   PG	USER_UNITro   s    r:   	user_unitzPageObject.user_unit  s     xxa((rH   widthheightc           	         t        |       }|j                  t        t        j                        t        d             |j                  t        t        j
                        t                      |j                  t        t        j                        t                      ||r| jt        | j                        dkD  rR| j                  t        | j                        dz
     }|j                  j                  }|j                  j                  }nt        |j                  t        t        j                        t!        dd||f             |S )aB  
        Return a new blank page.

        If ``width`` or ``height`` is ``None``, try to get the page size
        from the last page of *pdf*.

        Args:
            pdf: PDF file the page belongs to
            width: The width of the new page expressed in default user
                space units.
            height: The height of the new page expressed in default user
                space units.

        Returns:
            The new blank page

        Raises:
            PageSizeNotDefinedError: if ``pdf`` is ``None`` or contains
                no page
        z/Pager   r   )r   __setitem__r&   r   TYPEPARENTr'   	RESOURCESr"   lenpagesmediaboxr   r   r   MEDIABOXr)   )rB   r   r   pagelastpages        r:   create_blank_pagezPageObject.create_blank_page  s    4 # 	BGG,j.ABBII.
=BLL13C3EF=FN3syy>A#599S^a%78 ))//!**11--r{{#_aE65J%K	
 rH   c                 J    t        ddd       t        j                  | ||      S )z\
        .. deprecated:: 1.28.0

            Use :meth:`create_blank_page` instead.
        createBlankPager   rK   )r   r   r   )rB   r   r   s      r:   r   zPageObject.createBlankPage  s'     	%%68KWU++C??rH   c                 l   g }t         j                  | t        j                     vr|S | t        j                     t         j                     j	                         }|D ]U  }||   t
        j                     dk(  st        ||         \  }}|1|dd  | }|j                  t        ||             W |S )z
        Get a list of all images of the page.

        This requires pillow. You can install it via 'pip install PyPDF2[image]'.

        For the moment, this does NOT include inline images. They will be added
        in future.
        /ImageNr   )r=   r   )
RESXOBJECTr   r   rC   IASUBTYPEr   appendr   )r<   images_extractedx_objectobj	extensionbyte_streamfilenames          r:   imageszPageObject.images  s     (*;;d2<<00##%ckk2==? 	SC}RZZ(H4)7)F&	;("%ab'9+6H$++Dh[,QR	S  rH   c                 T    t        | j                  t        j                  d            S )z
        The VISUAL rotation of the page.

        This number has to be a multiple of 90 degrees: 0,90,180,270
        This property does not affect "/Contents"
        r   )r5   rA   r   ROTATEro   s    r:   r   zPageObject.rotation  s     488BIIq)**rH   rc                 x    t        t        |      dz   dz  dz  dz        | t        t        j                        <   y )N-   Z   h  )r(   r5   r&   r   r   )r<   r   s     r:   r   zPageObject.rotation  s2    &2c!frkb5HB4NRU3U&VZ		"#rH   c                    | j                    }d| _         t        | j                        }t               j	                  t        |j                  |j                  dz  z          t        |j                  |j                  dz  z                j                  |      }|j                  |j                        }|j                  |j                        }|j	                  t        |d   |d          t        |d   |d                }| j                  |d       dD ]  }|| v st        | |         }|j                  |j                        }|j                  |j                        }t        t        |d   |d         t        |d   |d         t!        |d   |d         t!        |d   |d         f      | t#        |      <    y)z
        Apply the rotation of the page to the content and the media/crop/... boxes.

        It's recommended to apply this function before page merging.
        r   rk   r   F)z	/MediaBox/CropBox	/BleedBox/TrimBox/ArtBoxN)r   r)   r   rd   rw   r   leftr   bottomr   r   r   
lower_leftupper_rightminadd_transformationmaxr&   )r<   r   mbtrsfr   pt2brrs           r:   transfer_rotation_to_contentz'PageObject.transfer_rotation_to_content  s    ]]NT]]+YrwwA-..ryy299q=7P1Q0Q VAY 	 mmBMM*mmBNN+~~s3q63q622SQQ5H4HIe,N 	ADy$T!W-mmBMM2mmBNN3&5CFCF+CFCF+CFCF+CFCF+	'Z]#	rH   anglec                     |dz  dk7  rt        d      | j                  t        j                  d      }t	        |t
              r|n|j                         }t        ||z         | t        t        j                        <   | S )z
        Rotate a page clockwise by increments of 90 degrees.

        Args:
            angle: Angle to rotate the page.  Must be an increment of 90 deg.
        r   r   z'Rotation angle must be a multiple of 90)	r|   rA   r   r   r4   r5   rC   r(   r&   )r<   r   
rotate_objcurrent_angles       r:   r   zPageObject.rotate  so     2:?FGGXXbii+
$Z5J:;P;P;R 	 '3=53H&IZ		"#rH   c                 >    t        ddd       | j                  |      S )Nrotate_clockwiser   rK   r   r   r<   r   s     r:   r   zPageObject.rotate_clockwise'  s    $%77K{{5!!rH   c                 >    t        ddd       | j                  |      S )z[
        .. deprecated:: 1.28.0

            Use :meth:`rotate_clockwise` instead.
        rotateClockwiser   rK   r   r   s     r:   r   zPageObject.rotateClockwise+  s      	%%6'J{{5!!rH   c                 @    t        ddd       | j                  |       S )zt
        .. deprecated:: 1.28.0

            Use :meth:`rotate_clockwise` with a negative argument instead.
        rotateCounterClockwiser   rK   r   r   s     r:   r   z!PageObject.rotateCounterClockwise4  s"     	%%=xQ{{E6""rH   res1res2resourcec                 &   t               }|j                  | j                  |t                     j                                t	        t         |j                  |t                     j                               }i }t        |j                               D ]y  }||v rZ|j                  |      |j                  |      k7  r7t        |t        t        j                               z         }|||<   ||   ||<   a||vsf|j                  |      ||<   { ||fS r@   )r"   updaterA   rC   r   r8   keysraw_getr&   r6   uuiduuid4)r   r   r   new_respage2res
rename_reskeynewnames           r:   _merge_resourceszPageObject._merge_resources=  s     #$txx*:*<=HHJKdhhx1A1CDOOQ
 
( 	5Cg~'//#"6(:J:J3:O"O$S3tzz|+<%<=")
3#+C= G#'//4	5 
""rH   streamrenamec                    |s| S t        | |      } | j                  D ]  \  }}t        |t              rEt	        t        |            D ]-  }||   }t        |t              s|j                  ||      ||<   / [t        |t              r3|D ]-  }||   }t        |t              s|j                  ||      ||<   / t        dt        |              | S )Nztype of operands is )r!   
operationsr4   r8   ranger   r&   rA   dictKeyErrortype)r   r   rB   operands	_operatorir}   s          r:   _content_stream_renamez!PageObject._content_stream_renameP  s     Mvs+#)#4#4 	HHi(D)s8}- 9A!!B!"j1&,jjR&89 Hd+! 9A!!B!"j1&,jjR&89
 !5d8n5EFGG	H rH   contentsc                     t        | |      }|j                  j                  dg df       |j                  j                  g df       |S )Nr   qQ)r!   r   insertr   )r  rB   r   s      r:   _push_pop_gszPageObject._push_pop_gsf  sG    
 x-  RI.  "c+rH   re   c                     |\  }}}}}}t        | |      } | j                  j                  dt        |      t        |      t        |      t        |      t        |      t        |      gdg       | S )Nr   z cm)r!   r   r  r$   )	r  rB   re   ar   crF   efs	            r:   _add_transformation_matrixz%PageObject._add_transformation_matrixp  s{     1aAq 3/""  NNNNNN 
	
 rH   c                 j    t         j                  | v r!| t         j                     j                         S y)z
        Access the page contents.

        :return: the ``/Contents`` object, or ``None`` if it doesn't exist.
            ``/Contents`` is optional, as described in PDF Reference  7.7.3.3
        N)r   CONTENTSrC   ro   s    r:   get_contentszPageObject.get_contents  s+     ;;$$//11rH   c                 <    t        ddd       | j                         S )zW
        .. deprecated:: 1.28.0

            Use :meth:`get_contents` instead.
        getContentsr  rK   )r   r  ro   s    r:   r  zPageObject.getContents  s     	%]NGL  ""rH   page2expandc                 *    | j                  ||       y)a  
        Merge the content streams of two pages into one.

        Resource references
        (i.e. fonts) are maintained from both pages.  The mediabox/cropbox/etc
        of this page are not altered.  The parameter page's content stream will
        be added to the end of this page's content stream, meaning that it will
        be drawn after, or "on top" of this page.

        Args:
            page2: The page to be merged into this one. Should be
                an instance of :class:`PageObject<PageObject>`.
            expand: If true, the current page dimensions will be
                expanded to accommodate the dimensions of the page to be merged.
        )r  N)_merge_page)r<   r  r  s      r:   
merge_pagezPageObject.merge_page  s      	v.rH   c                 >    t        ddd       | j                  |      S )zU
        .. deprecated:: 1.28.0

            Use :meth:`merge_page` instead.
        	mergePager  rK   )r   r  )r<   r  s     r:   r  zPageObject.mergePage  s     	%[,Hu%%rH   page2transformationc                    t               }i }	 t        t         | t        j                     j	                               }	 t        t         |t        j                     j	                               }t               }	| |fD ]Q  }
t        j                  |
v s|
t        j                     }t        |t              s:|D ]  }|	j                  |        S t        j                  t        j                  t        j                  t        j                  t        j                  t        j                   t        j"                  fD ]>  }t$        j'                  |||      \  }}|s ||t)        |      <   |j+                  |       @ t        t-        |j/                  t        j0                  t                     j	                               j3                  t-        |j/                  t        j0                  t                     j	                                           |t)        t        j0                        <   t               }| j5                         }|/|j                  t$        j7                  || j8                               |j5                         }|t;        || j8                        }|j<                  }|j>                  jA                  dtC        tD        |jF                  |jH                  |jJ                  |jL                  g      df       |j>                  jA                  dg df       |j>                  jA                  dg df       | ||      }t$        jO                  ||| j8                        }t$        j7                  || j8                        }|j                  |       |r| jQ                  ||       t;        || j8                        | t)        t        jR                        <   || t)        t        j                        <   |	| t)        t        j                        <   y # t
        $ r t               }Y w xY w# t
        $ r t               }Y w xY w)Nr   rer   Wrk   n)*r"   r   r   r   rC   r  r    ANNOTSr4   r   r   EXT_G_STATEFONTr   COLOR_SPACEPATTERNSHADING
PROPERTIESr   r   r&   r   	frozensetrA   PROC_SETunionr  r  rB   r!   trimboxr   r  mapr$   r   r   r   r   r  _expand_mediaboxr  )r<   r  r   re   r  new_resourcesr   original_resourcespage2resources
new_annotsr   annotsrefresnew	newrenamenew_content_arrayoriginal_contentpage2contentrects                       r:   r  zPageObject._merge_page  sw    )*	4!%&6R\\8J8U8U8W!X	0!"2E",,4G4R4R4TUN !]
5M 	/DyyD biifk2% /"))#./		/ OOHHKKOOKKKKNN
 	)C (88"NCNC 14jo.i(	)" 3>"&&s||[]CNNPe.,,S\\;=ITTVW3
j./ (M,,.'$$''(8$((C ))+#(txx@L==D##**# II KK JJ KK	  ##**1r3i8##**1r3i8".2<@%<<fdhhL &22<JL$$\2 !!%-(56G(RZ$%)6Z%&&0Z		"#g  	4!1!3	4  	0-/N	0s"   /P /P0 P-,P-0QQc           	      N   | j                   j                  j                         | j                   j                  j                         | j                   j                  j                         | j                   j
                  j                         f}|j                   j                  j                         |j                   j                  j                         |j                   j                  j                         |j                   j
                  j                         |j                   j                  j                         |j                   j
                  j                         |j                   j                  j                         |j                   j                  j                         fSt        d D              t        fdt        ddd      D              }t        fdt        ddd      D              }nddd   }ddd   }t        |      t        |      f}t        |      t        |      f}t        |d   |d         t        |d   |d         f}t        |d   |d         t        |d   |d         f}|| j                   _
        || j                   _        y )	Nc              3   2   K   | ]  }t        |        y wr@   r   .0r9   s     r:   	<genexpr>z.PageObject._expand_mediabox.<locals>.<genexpr>0       .Qa.   c              3   ^   K   | ]$  }d    |   z  d   |dz      z  z   d   z    & yw)r   rk   r   rm   NrS   rC  r  corners2re   s     r:   rD  z.PageObject._expand_mediabox.<locals>.<genexpr>1  E       A!$s1vQ'??#a&H   *-r      rk   c              3   ^   K   | ]$  }d    |   z  d   |d z      z  z   d   z    & yw)r   rl   rn   NrS   rH  s     r:   rD  z.PageObject._expand_mediabox.<locals>.<genexpr>5  rJ  rK  r   rl   )r   r   
as_numericr   righttoptupler   r   r   r   r   )	r<   r  re   corners1new_xnew_y	lowerleft
upperrightrI  s	     `     @r:   r1  zPageObject._expand_mediabox  s&    MM))+MM  ++-MM**,MM((*	
 NN**,NN!!,,.NN**,NN))+NN  ++-NN))+NN  ++-NN!!,,.	
 ?.#..C q!Q E  q!Q E
 QqUOEQqUOEZU,	%j#e*-
!il3S!iPQl5ST	Z]+Z]+


 $- $.!rH   c                     t        ddd       t        t              rj                  t	        t
              | j                  fd|       y)ah  
        mergeTransformedPage is similar to merge_page, but a transformation
        matrix is applied to the merged stream.

        :param PageObject page2: The page to be merged into this one. Should be
            an instance of :class:`PageObject<PageObject>`.
        :param tuple ctm: a 6-element tuple containing the operands of the
            transformation matrix
        :param bool expand: Whether the page should be expanded to fit the dimensions
            of the page to be merged.

        .. deprecated:: 1.28.0

            Use :meth:`add_transformation`  and :meth:`merge_page` instead.
        z%page.mergeTransformedPage(page2, ctm)z5page2.add_transformation(ctm); page.merge_page(page2)rK   c                 F    t         j                  | j                        S r@   )r   r  rB   )page2Contentre   r  s    r:   r[   z1PageObject.mergeTransformedPage.<locals>.<lambda>f  s    !F!Feii" rH   N)r   r4   rd   re   r   r   r  )r<   r  re   r  s    `` r:   mergeTransformedPagezPageObject.mergeTransformedPageG  sV    * 	%3C	

 c>*''C137 	
rH   r~   c                 x    t        ddd       t               j                  ||      }| j                  |||       y)a2  
        mergeScaledPage is similar to merge_page, but the stream to be merged
        is scaled by applying a transformation matrix.

        :param PageObject page2: The page to be merged into this one. Should be
            an instance of :class:`PageObject<PageObject>`.
        :param float scale: The scaling factor
        :param bool expand: Whether the page should be expanded to fit the
            dimensions of the page to be merged.

        .. deprecated:: 1.28.0

            Use :meth:`add_transformation` and :meth:`merge_page` instead.
        z*page.mergeScaledPage(page2, scale, expand)zWpage2.add_transformation(Transformation().scale(scale)); page.merge_page(page2, expand)rK   N)r   rd   r~   rZ  )r<   r  r~   r  r}   s        r:   mergeScaledPagezPageObject.mergeScaledPagem  s>    " 	%8e	

 ##E51!!%V4rH   r   c                 v    t        ddd       t               j                  |      }| j                  |||       y)aJ  
        mergeRotatedPage is similar to merge_page, but the stream to be merged
        is rotated by applying a transformation matrix.

        :param PageObject page2: the page to be merged into this one. Should be
            an instance of :class:`PageObject<PageObject>`.
        :param float rotation: The angle of the rotation, in degrees
        :param bool expand: Whether the page should be expanded to fit the
            dimensions of the page to be merged.

        .. deprecated:: 1.28.0

            Use :meth:`add_transformation` and :meth:`merge_page` instead.
        z.page.mergeRotatedPage(page2, rotation, expand)z[page2.add_transformation(Transformation().rotate(rotation)); page.merge_page(page2, expand)rK   N)r   rd   r   rZ  )r<   r  r   r  r}   s        r:   mergeRotatedPagezPageObject.mergeRotatedPage  s<    " 	%<i	

 $$X.!!%V4rH   rs   rt   c                 x    t        ddd       t               j                  ||      }| j                  |||       y)aq  
        mergeTranslatedPage is similar to merge_page, but the stream to be
        merged is translated by applying a transformation matrix.

        :param PageObject page2: the page to be merged into this one. Should be
            an instance of :class:`PageObject<PageObject>`.
        :param float tx: The translation on X axis
        :param float ty: The translation on Y axis
        :param bool expand: Whether the page should be expanded to fit the
            dimensions of the page to be merged.

        .. deprecated:: 1.28.0

            Use :meth:`add_transformation` and :meth:`merge_page` instead.
        z/page.mergeTranslatedPage(page2, tx, ty, expand)z\page2.add_transformation(Transformation().translate(tx, ty)); page.merge_page(page2, expand)rK   N)r   rd   rw   rZ  )r<   r  rs   rt   r  r}   s         r:   mergeTranslatedPagezPageObject.mergeTranslatedPage  s>    $ 	%=j	

 ''B/!!%V4rH   c                     t        ddd       t               j                  | |       j                  |      j                  ||      }| j	                  |||      S )a  
        mergeRotatedTranslatedPage is similar to merge_page, but the stream to
        be merged is rotated and translated by applying a transformation matrix.

        :param PageObject page2: the page to be merged into this one. Should be
            an instance of :class:`PageObject<PageObject>`.
        :param float tx: The translation on X axis
        :param float ty: The translation on Y axis
        :param float rotation: The angle of the rotation, in degrees
        :param bool expand: Whether the page should be expanded to fit the
            dimensions of the page to be merged.

        .. deprecated:: 1.28.0

            Use :meth:`add_transformation` and :meth:`merge_page` instead.
        z@page.mergeRotatedTranslatedPage(page2, rotation, tx, ty, expand)zmpage2.add_transformation(Transformation().rotate(rotation).translate(tx, ty)); page.merge_page(page2, expand)rK   )r   rd   rw   r   rZ  )r<   r  r   rs   rt   r  r}   s          r:   mergeRotatedTranslatedPagez%PageObject.mergeRotatedTranslatedPage  s^    0 	%N{	

 ''bS188BLLRQST((F;;rH   c                     t        ddd       t               j                  |      j                  ||      }| j	                  |||       y)a  
        mergeRotatedScaledPage is similar to merge_page, but the stream to be
        merged is rotated and scaled by applying a transformation matrix.

        :param PageObject page2: the page to be merged into this one. Should be
            an instance of :class:`PageObject<PageObject>`.
        :param float rotation: The angle of the rotation, in degrees
        :param float scale: The scaling factor
        :param bool expand: Whether the page should be expanded to fit the
            dimensions of the page to be merged.

        .. deprecated:: 1.28.0

            Use :meth:`add_transformation` and :meth:`merge_page` instead.
        z;page.mergeRotatedScaledPage(page2, rotation, scale, expand)hpage2.add_transformation(Transformation().rotate(rotation).scale(scale)); page.merge_page(page2, expand)rK   N)r   rd   r   r~   rZ  )r<   r  r   r~   r  r}   s         r:   mergeRotatedScaledPagez!PageObject.mergeRotatedScaledPage  sI    $ 	%Iv	

 $$X.44UEB!!%V4rH   c                     t        ddd       t               j                  ||      j                  ||      }| j	                  |||      S )a  
        mergeScaledTranslatedPage is similar to merge_page, but the stream to be
        merged is translated and scaled by applying a transformation matrix.

        :param PageObject page2: the page to be merged into this one. Should be
            an instance of :class:`PageObject<PageObject>`.
        :param float scale: The scaling factor
        :param float tx: The translation on X axis
        :param float ty: The translation on Y axis
        :param bool expand: Whether the page should be expanded to fit the
            dimensions of the page to be merged.

        .. deprecated:: 1.28.0

            Use :meth:`add_transformation` and :meth:`merge_page` instead.
        z<page.mergeScaledTranslatedPage(page2, scale, tx, ty, expand)zipage2.add_transformation(Transformation().scale(scale).translate(tx, ty)); page.merge_page(page2, expand)rK   )r   rd   r~   rw   rZ  )r<   r  r~   rs   rt   r  r}   s          r:   mergeScaledTranslatedPagez$PageObject.mergeScaledTranslatedPage  sN    0 	%Jw	

 ##E51;;BC((F;;rH   c                     t        ddd       t               j                  |      j                  ||      j	                  ||      }| j                  |||       y)a  
        mergeRotatedScaledTranslatedPage is similar to merge_page, but the
        stream to be merged is translated, rotated and scaled by applying a
        transformation matrix.

        :param PageObject page2: the page to be merged into this one. Should be
            an instance of :class:`PageObject<PageObject>`.
        :param float tx: The translation on X axis
        :param float ty: The translation on Y axis
        :param float rotation: The angle of the rotation, in degrees
        :param float scale: The scaling factor
        :param bool expand: Whether the page should be expanded to fit the
            dimensions of the page to be merged.

        .. deprecated:: 1.28.0

            Use :meth:`add_transformation` and :meth:`merge_page` instead.
        zFpage.mergeRotatedScaledTranslatedPage(page2, rotation, tx, ty, expand)rd  rK   N)r   rd   r   r~   rw   rZ  )r<   r  r   r~   rs   rt   r  r}   s           r:    mergeRotatedScaledTranslatedPagez+PageObject.mergeRotatedScaledTranslatedPage  sW    6 	%Tv	

 $$X.44UEBLLRQST!!%V4rH   c           	         t        |t              r|j                  }| j                         }|]t        j                  || j                  |      }t        j                  || j                        }|| t        t        j                        <   |r3| j                  j                  j                         | j                  j                  j                         | j                  j                  j                         | j                  j                  j                         | j                  j                   j                         | j                  j                  j                         | j                  j                   j                         | j                  j                  j                         g}t#        d |D              }t%        ddd      D cg c]"  }|d   ||   z  |d   ||dz      z  z   |d   z   $ }}t%        ddd      D cg c]"  }|d   ||   z  |d   ||dz      z  z   |d	   z   $ }}t'        |      t'        |      f}t)        |      t)        |      f}	t'        |d   |d         t'        |d   |d         f}t)        |d   |	d         t)        |d   |	d         f}	|| j                  _        |	| j                  _        yyc c}w c c}w )
ab  
        Apply a transformation matrix to the page.

        Args:
            ctm: A 6-element tuple containing the operands of the
                transformation matrix. Alternatively, a
                :py:class:`Transformation<PyPDF2.Transformation>`
                object can be passed.

        See :doc:`/user/cropping-and-transforming`.
        Nc              3   2   K   | ]  }t        |        y wr@   rA  rB  s     r:   rD  z0PageObject.add_transformation.<locals>.<genexpr>Z  rE  rF  r   rL  rk   r   rm   rl   rn   )r4   rd   re   r  r   r  rB   r  r&   r   r  r   r   rN  r   rP  rO  rQ  r   r   r   r   r   )
r<   re   r  contentcornersr  rS  rT  rU  rV  s
             r:   r   zPageObject.add_transformation6  s     c>*''C##% ;;GTXXsSG --gtxx@G,3DBKK()""--/$$//1""--/!!,,.##..0!!,,.##..0$$//1	G .#..C q!Q A#c!fwq1u~&==AFE  q!Q A#c!fwq1u~&==AFE 
 USZ0Ie*c%j1JWQZ16GAJ	RS8UVIGAJ
1.GAJ
1.J
 (1DMM$(2DMM%? s   
'K'Kc                 @    t        ddd       | j                  |       y)z]
        .. deprecated:: 1.28.0

            Use :meth:`add_transformation` instead.
        addTransformationr   rK   N)r   r   rh   s     r:   ro  zPageObject.addTransformationo  s!     	%%8:NPWX$rH   rx   ry   c           	      b   | j                  |dd|ddf       | j                  j                  ||      | _        | j                  j                  ||      | _        | j                  j                  ||      | _        | j
                  j                  ||      | _        | j                  j                  ||      | _        t        j                  | v r| t        j                     }t        |t              r|D ]  }|j                         }t        j                  |v s&|t        j                     }t        |t              sJt        t        |d         |z        |d<   t        t        |d         |z        |d<   t        t        |d         |z        |d<   t        t        |d         |z        |d<    t        j                   | v r| t        j                      }t        |t              r	|d   d   }n|d   }t#        t        |d         |z  t        |d         |z  t        |d         |z  t        |d         |z  f      }	t        |t              r5|	| t%        t        j                            t'        d         t%        d      <   y|	| t%        t        j                            t%        d      <   yy)a\  
        Scale a page by the given factors by applying a transformation
        matrix to its content and updating the page size.

        This updates the mediabox, the cropbox, and the contents
        of the page.

        Args:
            sx: The scaling factor on horizontal axis.
            sy: The scaling factor on vertical axis.
        r   r   rk   rl   z/BBoxN)r   cropboxr~   artboxbleedboxr/  r   r   r%  r4   r    rC   ADARectr$   r   VPr)   r&   r(   )
r<   rx   ry   annotations
annotationannotation_obj	rectangleviewportbboxscaled_bboxs
             r:   r~   zPageObject.scalez  sX    	Q2q! 45||))"b1kk''B/++B3||))"b1++B399ryy/K+{3"- QJ%/%:%:%<Nxx>1$2388$<	%i=+6uYq\7JR7O+PIaL+6uYq\7JR7O+PIaL+6uYq\7JR7O+PIaL+6uYq\7JR7O+PIaLQ 55D=BEE{H(K0{7+()$q'NR'$q'NR'$q'NR'$q'NR'	K (K0   Z&'Q8w' @KZ&'
7(;<' rH   factorc                 (    | j                  ||       y)z
        Scale a page by the given factor by applying a transformation
        matrix to its content and updating the page size.

        Args:
            factor: The scaling factor (for both X and Y axis).
        N)r~   r<   r~  s     r:   scale_byzPageObject.scale_by  s     	

66"rH   c                 B    t        ddd       | j                  ||       y)zS
        .. deprecated:: 1.28.0

            Use :meth:`scale_by` instead.
        scaleByr  rK   N)r   r~   r  s     r:   r  zPageObject.scaleBy  s     	%Y
GD

66"rH   c                     |t        | j                  j                        z  }|t        | j                  j                        z  }| j	                  ||       y)z
        Scale a page to the specified dimensions by applying a
        transformation matrix to its content and updating the page size.

        Args:
            width: The new width.
            height: The new height.
        N)r   r   r   r   r~   )r<   r   r   rx   ry   s        r:   scale_tozPageObject.scale_to  sD     U4==..//eDMM0011

2rrH   c                 B    t        ddd       | j                  ||       y)zS
        .. deprecated:: 1.28.0

            Use :meth:`scale_to` instead.
        scaleTor  rK   N)r   r  )r<   r   r   s      r:   r  zPageObject.scaleTo  s     	%Y
GDeV$rH   c                     | j                         }|Qt        |t              st        || j                        }|j	                         | t        t        j                        <   yy)a   
        Compress the size of this page by joining all content streams and
        applying a FlateDecode filter.

        However, it is possible that this function will perform no action if
        content stream compression becomes "automatic".
        N)r  r4   r!   rB   flate_encoder&   r   r  )r<   rl  s     r:   compress_content_streamsz#PageObject.compress_content_streams  sS     ##%g}5':,3,@,@,BDBKK() rH   c                 >    t        ddd       | j                          y)zc
        .. deprecated:: 1.28.0

            Use :meth:`compress_content_streams` instead.
        compressContentStreamsr  rK   N)r   r  ro   s    r:   r  z!PageObject.compressContentStreams  s"     	%$&@'	
 	%%'rH   c                 P   d}t        | d   j                         | j                  d      j                  D ]m  \  }}|dk(  r$|d   D cg c]  }t	        |t
              s| }}ng }||j                  d      dz   dj                  |      z   |j                         z   dz   z  }o |d	z  }	 | t        j                     d
   D ]  }||dz   z  }|| t        j                     d
   |   j                         dz   z  }	 | t        j                     d
   |   d   j                         }||dz   z  }	 || t        j                     d
   |   d   j                         j                         dz   z  } 	 |S c c}w # t        $ r Y Tw xY w# t        $ r Y w xY w# t        $ r	 |dz  }Y |S w xY w)N z	/Contentsbytes   TJr   zutf-8 
z
=============================
/Fontz	/Encodingz
/ToUnicodezNo Font
)r!   rC   rB   r   r4   r6   decodejoinr   r   r   	Exceptionget_datar  )r<   outoper}   r9   sfoenc_reprs           r:   _debug_for_extractzPageObject._debug_for_extract  s   $((*DHHg

*	QGC U{ #A=1*Q*<Q==299W%+bggaj83<<>IDPPC	Q 	22	2<<(1 rDy tBLL)'226??ADHH#BLL1':2># hj  8d?*C
R\\*73B7( "C0 
= > !  !   	;C
	sa   E0E0+AF :2E5->F+F 5	F>F  FF 	FF FF F%$F%)r   r              i@r   orientations.space_widthcontent_keyvisitor_operand_beforevisitor_operand_aftervisitor_textc	                 n   !" d ddi 	 |}	t        t        j                        |	vr/|	d   j                         }	t        t        j                        |	vr/t	        t
        |	t        j                           }
d|
v r(t	        t
        |
d         D ]  }t        |||      |<    di ddf	 t        |t              r||   j                         n|}t        |t              st        ||d      }g d	g g d	!g d	"d
d
ddddt        t           dt        t           dt        t           fddt        t           dt        fddt        ffddt        dt        ddf !"fd}|j                   D ]  \  }}| |||!       |dk(  r |dg         |d|       nk|dk(  r1 |d|d   g        |d|d   g        |dg         |d|dd        n5|d k(  r |d!|d    g        |d"|       n|d#k(  r|d   D ]}  }t        |t        t        f      r
 |d|g       t        |t        t        t"        t$        f      sDt'        t        |            k\  s\t)               dkD  sk d$   d%k7  st |dd%g        n|d&k(  r~ z    !d'          	 d$   d(k7  rd(z   d(!d'          	 |
d)   }||d      d*   d+k7  r2| j-                  ||d      |||        z    !d'          d n	 |||       | |||!         z   dk7  r  !d'          S # t        $ r Y yw xY w# t        $ r Y yw xY w# t*        $ r Y w xY w# t        $ r t/        d,|d    t0               Y w xY w# d w xY w)-a  
        See extract_text for most arguments.

        Args:
            content_key: indicate the default key where to extract data
                None = the object; this allow to reuse the function on XObject
                default = "/Content"
        r  Fz/Parentr  charmapNotInitializedNr        ?        r  r  r  r  r  g     @@r  g      (@rv   r$  r2   c           	      &   | d   |d   z  | d   |d   z  z   | d   |d   z  | d   |d   z  z   | d   |d   z  | d   |d   z  z   | d   |d   z  | d   |d   z  z   | d   |d   z  | d   |d   z  z   |d   z   | d   |d   z  | d   |d   z  z   |d   z   gS )Nr   r   rk   rl   rm   rn   rS   )rv   r$  s     r:   multz&PageObject._extract_text.<locals>.multd  s    !qtadQqTk)!qtadQqTk)!qtadQqTk)!qtadQqTk)!qtadQqTk)AaD0!qtadQqTk)AaD0 rH   c                 :    | d   dkD  ry| d   dk  ry| d   dkD  ryy)	Nrl   gư>r   gưr  r   r   r  rS   )rv   s    r:   orientz(PageObject._extract_text.<locals>.orientn  s/    td{11rH   c                       dz  S )Ng     @@rS   )_space_widths   r:   current_spacewidthz4PageObject._extract_text.<locals>.current_spacewidthx  s    &((rH   operatorr  c                    d}| dk(  rg d z  " " d          dy | dk(  rz  " " d          dn| dk(  rj                  f       n| dk(  r	 j                         \  n| d	k(  rqz  " " d          d t        |d
         t        |d         t        |d         t        |d         t        |d         t        |d         g      n"| dk(  rt        |d
         dz  n
| dk(  rdt        |d
         z   n| dk(  rt        |d
         n| dk(  rNdk7  rz  " " d          d	 |d
      }|d   |d   |d   |d
   |d   f	 t        |d         n| dk(  rXd}t        |d
         }t        |d         } dxx   | d
   z  | d   z  z   z  cc<    dxx   | d   z  | d   z  z   z  cc<   n-| dk(  rTd}t        |d
         t        |d         t        |d         t        |d         t        |d         t        |d         g n| dk(  rd} dxx   z  cc<   n| dk(  rd}        } |      }|v rt        |d
   t              r
|d
   z  nd}t        |d
   t              rt        |d
         n|d
   }	t        d
   t              r	 |	j                  d
   d      }nFdj                  |	D 
cg c]+  }
|
d
   v rd
   |
   nt        |
f      j                         - c}
      }dj                  |D 
cg c]  }
|
d   v rd   |
   n|
 c}
      D ]  }
t        |
      }|dk  s&d|k  r|d k  sd!|k  r|d"k  sd#|k  r|d$k  s|t        v rr|
z   n|
z   Fd%|k  r|d&k  s&d'|k  r|d(k  sd)|k  r|d*k  st        |k  r+|t        k  r"sdz  " " d          d|
z   rdz  " " d          d|
z    ny |rO        } |      }|d   !d   z
  }|d   !d   z
  }t!        j"                  t%        |d
   |d   z        t%        |d   |d   z        z         }|z  }|!|vry 	 |d
k(  rq|d+|z  k  r+z   d,   d-k7  rŉd-z   z  " "d-z    d          dy t%        |      |d.z  k  rt%        |              |z  d/z  kD  rxz   d,   d0k7  rkd0z  y |d1k(  ro|d2|z  kD  r+z   d,   d-k7  rKd-z   z  " "d-z    d          dy t%        |      |d.z  k  rt%        |              |z  d/z  kD  rz   d,   d0k7  rd0z  y |d3k(  rm|d2|z  kD  r*z   d,   d-k7  rԉd-z   z  " "d-z    d          dy t%        |      |d.z  k  rt%        |              |z  d/z  kD  rz   d,   d0k7  r}d0z  y |d4k(  rq|d+|z  k  r*z   d,   d-k7  r]d-z   z  " "d-z    d          dy t%        |      |d.z  k  r,t%        |              |z  d/z  kD  rz   d,   d0k7  rd0z  y y y y y y y y y y y y y y y y y y y # t        $ r g dY cw xY w# t        $ r' t
        d   t
        d   t
        d   d|d
   z   d fY 1w xY w# t        $ r Y w xY w# t        $ r  |	j                  d
   dk(  rdndd      }Y w xY wc c}
w c c}
w # t        $ r Y y w xY w)5NFs   BTr  rl   r  s   ET   q   Qs   cmr   r   rk   rm   rn   s   Tzg      Y@   Twr     TLs   Tfz???   TdTs   Tm   T*   Tjsurrogatepassr  z	utf-16-be/   :   @   i    io   i   i!  i  i  i  i  ip  i  gr+   r  g333333?   r  r  g?r   r  )r   popr  r   r  r   r4   r6   r*   r  r  r  r7   r.   r,   r-   r   sqrtabs)#r  r  check_crlf_spacecharMapTuplers   rt   rv   orientationtttr9   xxdelta_xdelta_ykr  TLr  
char_scale	cm_matrixcm_stackcmapcmapsr  	font_sizer  r  r  outputrtl_dirspace_scaletext	tm_matrixtm_prevr  s#                   r:   process_operationz3PageObject._extract_text.<locals>.process_operation|  s	    &+5 :	$+ y)T!WiP U"$+ y)T!WiP T!!!"#$
 T!? !!!"#$
 U"$+ y)T!WiP hqk*hqk*hqk*hqk*hqk*hqk* 
	 U""8A;/%7
U"!E(1+$66U"8A;'U"2:dNF#/$T9ia)T#(!#5L#/?L %Q$Q $Q	D %hqk 2I U"#'  8A;'8A;'!Yq\ 1B14E EE!Yq\ 1B14E EEU"#' (1+&(1+&(1+&(1+&(1+&(1+&	 U"#' !"U"#' I.$Qi,.!(1+s3+!#  *(1+s; 2(1+>!)! 
 &d1gs3"$&II$(G_%" !# .0!"() 34tAw,DGAJE1$KDVDVDX$X!"!A "$HIJ11Q<T!WQZQ>J" %0A "%QB "$t$(BJ2:$*bLR6\$*bLR6\#%)A#A3:q4xq!'2",$*bLR6\$*bLR6\$2b$8R>=Q (/.2G$*dNF'3'?(4T9iQUVWQXZc(d+-D'(4x $+.3G$*dNF'3'?(4T9iQUVWQXZc(d+-D'+axK%0P I.$QiA$+A$+IIc!A$1+.QqTAaD[1AABMl2N"a'"TAX- &r2d: &$+ 5#/#;$0(,t(1(1(,Q(1%& (*L1s72 #G/A/Ca/G"/L L &r2c9 $$+"S1W, &r2d: &$+ 5#/#;$0(,t(1(1(,Q(1%& (*L1s72 #G/A/Ca/G"/L L &r2c9 $$*"S1W, &r2d: &$+ 5#/#;$0(,t(1(1(,Q(1%& (*L1s72 #G/A/Ca/G"/L L &r2c9 $$+"TAX- &r2d: &$+ 5#/#;$0(,t(1(1(,Q(1%& (*L1s72 #G/A/Ca/G"/L L &r2c9 $  : !M 3  ; ,  : !M 3  ;	  : !M 3  ;	  : !M 3  ;  w ! ? >I?\   #3A#6L(+(++	D ! Z $- "$&II377i3GKY$3%""!" K~ ! s   *Y/ "Z Z6 [ :0[2 [77[< =[< 7[< =;[< 96[< 0:[< +6[< ":[< /Z ?Z ,Z32Z36	[[%[/.[/<	\\   'r  r     "r  r   s   Tcr   rk   s   TDr  r  r  r+   r  s   Dorl   r  z/XObjectz/Subtyper   z" impossible to decode XFormObject )r&   r   r   rC   r   r"   r  r   r4   r6   r!   r  r	   r   r5   r  r   r(   r$   r  r   
IndexErrorextract_xform_textr   r   )#r<   r   rB   r  r  r  r  r  r  objrresources_dictr  rl  r  r  r  r}   xobjr  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  s#      `    `         @@@@@@@@@@@@@@@@@r:   _extract_textzPageObject._extract_text  sy   &   		DR\\*$6I113 R\\*$6 ""2D4FGN n$*N7,CD ?)![#>a?
 	
 		1;K1MK ++-SV  g}5'g> "@	!?	 
 
#		DK 	DK 	DK 		d5k 	c 		)E 	)b	 b	 b	$ b	 b	 b	H	 #*"4"4 >	PHh%1&x9iP4!%,!%2T!!%(1+7!%(1+7!%,!%!"6U"!%8A;,8!%2U""1+ 	<B!"sEl3)%"6!"sE<&MN r^|;!$TQ!%bS-ecU;	< U"$+ y)T!WiPbzT)$'3(y)T!WiX)*5DHQK(4@#66 !-('21(  $'3(y)T!WiX D!(H5$0%h)YO}>	P~ 	$2:,2y)T!WiHQ  		&  		l " " ! "<Xa[MJ  Dsb   AM )!M =AM- ?M<AN	M*)M*-	M98M9<	NNN-*N0,N--N00N4)Tj_sepTJ_sepr  r  r  r  r  argsr  r  c          
      T   t        |      dk\  r9t        |d   t              r|d   }t        |      dk\  r*t        |d   t              r|d   }nt        d|d          t        |      dk\  r0t        |d   t        t
        f      r|d   }nt        d|d          t        |      dk\  rt        |d   t        t
        f      r|d   }n~t        d|d          t        |d   t        t
        f      rC|d   }t        |      dk\  rAt        |d   t        t
        f      r|d   }n"t        d|d          t        d|d          ||t        j                  dt               t        |t
              r|f}| j                  | | j                  ||t        j                  |||      S )a`  
        Locate all text drawing commands, in the order they are provided in the
        content stream, and extract the text.

        This works well for some PDF files, but poorly for others, depending on
        the generator used. This will be refined in the future.

        Do not rely on the order of text coming out of this function, as it
        will change if this function is made more sophisticated.

        Arabic, Hebrew,... are extracted in the good order.
        If required an custom RTL range of characters can be defined; see function set_custom_rtl

        Additionally you can provide visitor-methods to get informed on all operands and all text-objects.
        For example in some PDF files this can be useful to parse tables.

        Args:
            Tj_sep: Deprecated. Kept for compatibility until PyPDF2 4.0.0
            TJ_sep: Deprecated. Kept for compatibility until PyPDF2 4.0.0
            orientations: list of orientations text_extraction will look for
                default = (0, 90, 180, 270)
                note: currently only 0(Up),90(turned Left), 180(upside Down),
                270 (turned Right)
            space_width: force default space width
                if not extracted from font (default: 200)
            visitor_operand_before: function to be called before processing an operand.
                It has four arguments: operand, operand-arguments,
                current transformation matrix and text matrix.
            visitor_operand_after: function to be called after processing an operand.
                It has four arguments: operand, operand-arguments,
                current transformation matrix and text matrix.
            visitor_text: function to be called when extracting some text at some position.
                It has five arguments: text, current transformation matrix,
                text matrix, font-dictionary and font-size.
                The font-dictionary may be None in case of unknown fonts.
                If not None it may e.g. contain key "/BaseFont" with value "/Arial,Bold".

        Returns:
            The extracted text
        r   r   rk   zInvalid positional parameter rl   rm   zKparameters Tj_Sep, TJ_sep depreciated, and will be removed in PyPDF2 4.0.0.)r   r4   r6   	TypeErrorrQ  r5   r   r   r   r   r  rB   r   r  )	r<   r  r  r  r  r  r  r  r  s	            r:   extract_textzPageObject.extract_text  s   f t9>$q'3'at9>!$q'3/!%a'*GQy(QRRt9>!$q'E3<8'+Aw'*GQy(QRRt9>!$q'E3<8&*1g'*GQy(QRRDGeS\2#Awt9>!$q'E3<8&*1g'*GQy(QRR"?Qy IJJ!3MM]"
 lC((?L!!HHKK"!	
 		
rH   xformc           
      F    | j                  || j                  ||d|||      S )z
        Extract text from an XObject.

        Args:
            space_width:  force default space width (if not extracted from font (default 200)

        Returns:
            The extracted text
        N)r  rB   )r<   r  r  r  r  r  r  s          r:   r  zPageObject.extract_xform_textF  s3    $ !!HH"!	
 		
rH   c                 <    t        ddd       | j                         S )zW
        .. deprecated:: 1.28.0

            Use :meth:`extract_text` instead.
        extractTextr  rK   )r   r  )r<   r  r  s      r:   r  zPageObject.extractTextc  s     	%]NGL  ""rH   c                     | j                         }t        |t              sJ t        t	        t        |t
        j                                 \  }}||z
  }||fS )z
        Get the names of embedded fonts and unembedded fonts.

        :return: (Set of embedded fonts, set of unembedded fonts)
        )rC   r4   r"   _get_fonts_walkr   r   r   )r<   r   fontsembedded
unembeddeds        r:   
_get_fontszPageObject._get_fontsn  sR     oo#/00)$/?R\\AR*STxX%
##rH   rS   c                 4    t        ddd       | j                  S )V
        .. deprecated:: 1.28.0

            Use :py:attr:`mediabox` instead.
        mediaBoxr   rK   r   r   ro   s    r:   r  zPageObject.mediaBox       	%ZWE}}rH   c                 ,    t        ddd       || _        y)r  r  r   rK   Nr  r   s     r:   r  zPageObject.mediaBox  s     	%ZWErH   r   c                 4    t        ddd       | j                  S )zU
        .. deprecated:: 1.28.0

            Use :py:attr:`cropbox` instead.
        cropBoxrq  rK   r   rq  ro   s    r:   r  zPageObject.cropBox       	%Y	7C||rH   c                 ,    t        ddd       || _        y )Nr  rq  rK   r  r   s     r:   r  zPageObject.cropBox      $Y	7CrH   r   c                 4    t        ddd       | j                  S )zV
        .. deprecated:: 1.28.0

            Use :py:attr:`bleedbox` instead.
        bleedBoxrs  rK   r   rs  ro   s    r:   r  zPageObject.bleedBox  r  rH   c                 ,    t        ddd       || _        y )Nr  rs  rK   r  r   s     r:   r  zPageObject.bleedBox  s    $ZWErH   r   c                 4    t        ddd       | j                  S )zU
        .. deprecated:: 1.28.0

            Use :py:attr:`trimbox` instead.
        trimBoxr/  rK   r   r/  ro   s    r:   r  zPageObject.trimBox  r  rH   c                 ,    t        ddd       || _        y )Nr  r/  rK   r  r   s     r:   r  zPageObject.trimBox  r  rH   r   c                 4    t        ddd       | j                  S )zT
        .. deprecated:: 1.28.0

            Use :py:attr:`artbox` instead.
        artBoxrr  rK   r   rr  ro   s    r:   r	  zPageObject.artBox  s     	%XxA{{rH   c                 ,    t        ddd       || _        y )Nr	  rr  rK   r
  r   s     r:   r	  zPageObject.artBox  s    $XxArH   c                 2    d| vry t        t        | d         S )N/Annots)r   r    ro   s    r:   rw  zPageObject.annotations  s    D T)_55rH   c                 >    || t        d      = y|| t        d      <   y)z
        Set the annotations array of the page.

        Typically you don't want to set this value, but append to it.
        If you append to it, don't forget to add the object first to the writer
        and only add the indirect object.
        Nr  rN   r   s     r:   rw  zPageObject.annotations  s%     =Z	*+*/DI&'rH   NNN)r2   N)F)r  r   r2   N)NNF))r   r   r  r   r  NNN)r  r  )^r   r   r   r   __annotations__r
   r   r%   ri   r^   r   setterr  r   r   r   r   r   r   r   r   r   r	   r   r   r5   r   r   r   r   r   r   r"   r   r   r6   r   r!   r  r  r   r  r  r  boolr  r  r   r  r1  rd   rZ  r\  r^  r`  rb  re  rg  ri  r   ro  r~   r  r  r  r  r  r  r  r   r  r  r  r#   r  r  r   r  r`   r   r   r)   r  rq  r  rs  r  r/  r  rr  r	  r    rw  __classcell__)r   s   @r:   r   r   N  sX      ,07;15	5'(5 %^45 ~.	5
 
5, 'h~6 ' ' ((>": (t ( ( 
 )5 ) ) !-1.2*c]*UGT)** eWd*+* 
	* *X !-1.2@c]@UGT)*@ eWd*+@ 
	@ @  T
    , +# + + __W%U
+ W W W DC L  "c "l ""S "\ "#C #L # ##&6#BE#	tCH~tCH~-	.# #$ '+CH~<?	 * s     &D	 .
h}5 
#Xm4 #/ /d /t /$& IM8<b1b1 &hum/C&DEb1 45	b1
 b1 
b1H)/!)/(01O(P)/	)/^ 	$
$
 1>AB$
 	$

 
$
N AF5!5*/59=5	54 DI5!5-25<@5	54 IN5!5',5275AE5	5@ << < 	<
 < < 
<B RW5!5-25;@5JN5	5@ << < 	<
 < < 
<N !5!5 !5 	!5
 !5 !5 !5 
!5L 73>#AAB73 73 
	73r	%1	%		%3K 3K5 3KT 3Kj#u # ##e # #e U t %U %E %d %C	($C $T ):"%'[[QUPTLPKK K CHo	K
 K c]K !)3S#2F2L)M NK  (#sC1Et1K(LMK xc3S(A4(GHIK 
K` 4E"QUPTLP`
`
 `
 	`

 CsCx01`
 `
 !)3S#2F2L)M N`
  (#sC1Et1K(LM`
 xc3S(A4(GHI`
 
`
J ):"QUPTLP
"
 CHo
 	

 !)3S#2F2L)M N
  (#sC1Et1K(LM
 xc3S(A4(GHI
 

< /1	#	#(+	#		#
$E#c(CH"45 
$ *"++r:H /   __o $   )bkk^DG    ^^_    *+
BKK7PQH /   __o $   )j"++5NOG
    ^^_    (	J3LMF    ]]O    6Xk2 6 6 0+!6 04 0 0rH   r   c                   d    e Zd Zdeg ef   deegef   ddfdZdefdZdedefdZde	e   fd	Z
y)
_VirtualListlength_functionget_functionr2   Nc                 .    || _         || _        d| _        y )Nr+   )r  r  current)r<   r  r  s      r:   ri   z_VirtualList.__init__  s    
  /(rH   c                 "    | j                         S r@   )r  ro   s    r:   __len__z_VirtualList.__len__  s    ##%%rH   indexc                 V    t        |t              rBt        |j                  t	                      t               } |j                   fd      S t        |t              st        d      t	               }|dk  r||z   }|dk  s||k\  rt        d       j                  |      S )Nc                     |       S r@   rS   )idxindicesr<   s    r:   r[   z*_VirtualList.__getitem__.<locals>.<lambda>  s    D4F rH   z!sequence indices must be integersr   zsequence index out of range)r4   slicer   r   r   r  r  r5   r  r  r  )r<   r  clslen_selfr   s   `   @r:   __getitem__z_VirtualList.__getitem__  s    eU#U]]3t956Gt*Cw(FGG%%?@@t919u$E19):;;  ''rH   c              #   L   K   t        t        |             D ]	  }| |     y wr@   )r   r   )r<   r  s     r:   __iter__z_VirtualList.__iter__   s'     s4y! 	Aq'M	s   "$)r   r   r   r   r5   r   ri   r  r$  r   r&  rS   rH   r:   r  r    sh    !"c'* uj01 
	& &( ( ((:. rH   r  r   fntembc                    |
t               }|
t               }t        | d      st               t               fS d}d| v r"|j                  t        t        | d                d| v r7|D cg c]	  }|| v s| c}r"|j                  t        t        | d                | j                         D ]   }t        t        t        | |         ||       " ||fS c c}w )a_  
    If there is a key called 'BaseFont', that is a font that is used in the document.
    If there is a key called 'FontName' and another key in the same dictionary object
    that is called 'FontFilex' (where x is null, 2, or 3), then that fontname is
    embedded.

    We create and add to two sets, fnt = fonts used and emb = fonts embedded.
    r   )z	/FontFilez
/FontFile2z
/FontFile3z	/BaseFontz	/FontName)sethasattraddr   r6   r   r  r"   )r   r'  r(  fontkeysr9   r   s         r:   r  r  %  s     {e
{e3uce|8HcS#k*+,c,!18A,GGDc+./0xxz D-s3x8#sCD 8O -s   )	C3Cr  r   )Lr   r   r   decimalr   typingr   r   r   r   r   r	   r
   r   r   r   r   _cmapr   r   
_protocolsr   _utilsr   r   r   r   r   r   r   	constantsr   rt  r   r   r   r   r   r   errorsr   filtersr   genericr    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r,   r5   r  r-   r.   r6   r;   rG   rJ   r   rD   rQ   rU   rW   r^   r`   rb   rd   r   r  r  rS   rH   r:   <module>r7     s  <        4 )   = , + ( + #      &( $s) ( #'"&,0'D
S$
'D
S$
'D CcD()'D 3T#Y	'DT C 8C= _  0
00$,SM00 C ou6L0M RV 
&
&&!&'=!>&	&C s t # S T 
S HSM h 6
6!#66R: R:js0! s0l5 F #"		#c(	 
#c(	 3s8SX	rH   