
    j:j                    0   S r SrSSKrSSKrSSKrSSKrSSKJrJr  SSK	J
r
  SSKJr  SSKJrJrJrJrJr  SS	KJrJrJr  SS
KJrJrJrJrJrJrJrJrJ r   SSK!J"r"J#r#J$r$J%r%  SSK!J&r'  SSK!J(r)  SSK!J*r+  SSK,J-r-J.r.J/r/J0r0  SSK1J2r2J3r3J4r4J5r5J6r6J7r7J8r8J9r9J:r:J;r;  SSK<J=r=  SSK>J?r?J@r@JArAJBrBJCrC  SSKJDrDJErE  \R                  S:  a  SSKJGrG  OSSKHJGrG  \R                  " \J5      rK\R                  " S5      rM " S S\N\   \95      rO " S S\P\\4   \95      rQ " S S\Q5      rRS\SS4S  jrS " S! S"\Q5      rT " S# S$\T5      rU " S% S&\T5      rVS'rW " S( S)\U5      rX S2S*\S+\\   S,\S\Y\N\Y   \P\Z\Y4   4   S\\9\Z\Y\X4   4S- jjr[ " S. S/\R5      r\ " S0 S1\R5      r]g)3zMathieu Fenniakzbiziqe@mathieu.fenniak.net    N)IterableSequence)BytesIO)ceil)AnyCallableOptionalUnioncast   )PdfReaderProtocolPdfWriterProtocolXmpInformationProtocol)	WHITESPACESBinaryStreamType
StreamTypedeprecation_no_replacementlogger_warningread_non_whitespaceread_until_regexread_until_whitespaceskip_over_comment)CheckboxRadioButtonAttributesFieldDictionaryAttributesOutlineFontFlagStreamAttributes)FilterTypes)TypArguments)TypFitArguments)STREAM_TRUNCATED_PREMATURELYLimitReachedErrorPdfReadErrorPdfStreamError   )
BooleanObjectByteStringObjectFloatObjectIndirectObject
NameObject
NullObjectNumberObject	PdfObjectTextStringObjectis_null_or_none)Fit)extract_inline__ascii85_decode extract_inline__ascii_hex_decodeextract_inline__dct_decode!extract_inline__run_length_decodeextract_inline_default)read_hex_string_from_streamread_string_from_stream)      )Selfs   [+-]?(\d+)\s+(\d+)\s+R[^a-zA-Z]c                   D   \ rS rSrS\SS 4S jr  SS\S\S\\\	\
\4         SS 4S jjrS\4S	 jrS\\   4S
 jrS\S\\   4S jrS\SS 4S jrS\S\4S jrS\S\4S jr SS\S\	S\
\4   SS4S jjr\ SS\S\\   S\	S\
\\
   \\\
4   4   SS 4S jj5       rSrg)ArrayObjecte   pdf_destreturnc                     [        SU R                  [        5       US5      5      nU  HG  n[        US5      (       a"  UR	                  UR                  U5      5        M6  UR	                  U5        MI     U$ )Nr;   F	replicate)r   _reference_cloner;   hasattrappendr@   )selfr=   arrdatas       T/var/www/website/venv/lib/python3.13/site-packages/pypdf/generic/_data_structures.pyr@   ArrayObject.replicatef   sf     !!+-5A
 Dt[))

4>>(34

4 	 
 
     force_duplicateignore_fieldsc           	          U R                   R                  U:X  a	  U(       d  U $ [        SU R	                  [        5       USS95      nU  GH  n[        U[        5      (       a@  UR	                  UR                  XU5      UU5      nUR                  UR                   5        MY  [        U[        5      (       ad  [        UR                  5       =n[        5      (       a?  UR	                  UR                  USUS9UU5      nUR                  UR                   5        M  [        US5      (       a$  UR                  UR                  XU5      5        GM  UR                  U5        GM     U$ ! [         a     GNQf = f)Clone object into pdf_dest.r;   T)rK   )rK   rL   clone)indirect_referencepdf	Exceptionr   rA   r;   
isinstanceStreamObjectrO   rC   r(   
get_objectrB   )rD   r=   rK   rL   rE   rF   dupresolveds           rG   rO   ArrayObject.cloneu   sG   	&&**h6 !!+-4!P
 D$--++JJx-H#
 

3112D.11jT__M^A^`l6m6m++NN8TQ^N_#
 

3112w''

4::hOP

4 % & 
3  		s   "E) )
E76E7c                 P    [        U R                  [        S U  5       5      45      $ )Q
Used to detect modified object.

Returns:
    Hash considering type and value.

c              3   @   #    U  H  oR                  5       v   M     g 7fNhash_bin).0xs     rG   	<genexpr>'ArrayObject.hash_bin.<locals>.<genexpr>   s     *FA::<<s   )hash	__class__tuplerD   s    rG   r^   ArrayObject.hash_bin   s#     T^^U*F*F%FGHHrI   c                     [        U 5      $ )z:Emulate DictionaryObject.items for a list (index, object).)	enumeraterf   s    rG   itemsArrayObject.items   s    rI   lstc                 V   [        U[        [        [        45      (       a  [        U5      nU$ [        U[        5      (       a  U/nU$ [        U[
        5      (       a&  US   S:X  a  [        U5      /nU$ [        U5      /n U$ [        U[        5      (       a  [        U5      /nU$ U/nU$ )Nr   /)
rS   listre   setr,   strr)   r-   bytesr&   )rD   rl   results      rG   _to_lstArrayObject._to_lst   s     cD%-..#YF  Y''UF  S!!1v}$S/*  +3/0
 	 U##&s+,F  UFrI   c                 \    [        U 5      nUR                  U R                  U5      5        U$ )aw  
Allow extension by adding list or add one element only

Args:
    lst: any list, tuples are extended the list.
    other types(numbers,...) will be appended.
    if str is passed it will be converted into TextStringObject
    or NameObject (if starting with "/")
    if bytes is passed it will be converted into ByteStringObject

Returns:
    ArrayObject with all elements

)r;   extendrt   )rD   rl   temps      rG   __add__ArrayObject.__add__   s(     4 DLL%&rI   c                 F    U R                  U R                  U5      5        U $ )aL  
 Allow extension by adding list or add one element only

Args:
    lst: any list, tuples are extended the list.
    other types(numbers,...) will be appended.
    if str is passed it will be converted into TextStringObject
    or NameObject (if starting with "/")
    if bytes is passed it will be converted into ByteStringObject

)rw   rt   )rD   rl   s     rG   __iadd__ArrayObject.__iadd__   s     	DLL%&rI   c                     U R                  U5       H  n U R                  U5      nX	 M     U $ ! [         a     M*  f = f)zAllow to remove items)rt   index
ValueError)rD   rl   r`   r   s       rG   __isub__ArrayObject.__isub__   sG    c"A

1K #   s   /
==Nstreamencryption_keyc                     Ub  [        SS5        UR                  S5        U  H%  nUR                  S5        UR                  U5        M'     UR                  S5        g )N/the encryption_key parameter of write_to_stream5.0.0   [    s    ])r   writewrite_to_stream)rD   r   r   rF   s       rG   r   ArrayObject.write_to_stream   sW     %&A7 	TDLL  (  	UrI   rQ   forced_encodingc                 
   [        5       nU R                  S5      nUS:w  a  [        S5      e U R                  S5      nUR                  5       (       a(  U R                  S5      nUR                  5       (       a  M(  US:X  a   U$ US:X  a  U R	                  SS5        [        U 5        M}  U R	                  SS5        U R                  S5      nUS:X  a   U$ U R	                  SS5        UR                  [        XU5      5        M  )Nr$   r   zCould not read arrayrI      %   ])r;   readr"   isspaceseekr   rC   read_object)r   rQ   r   rE   tmptok
peek_aheads          rG   read_from_streamArrayObject.read_from_stream   s     mkk!n$;566++a.C++--kk!n ++--cz 
 d{B"!&)KKAQJT! 
 KKAJJ{6@A% rI   FrJ   r\   )__name__
__module____qualname____firstlineno__r   r@   boolr	   r   r
   rq   intrO   r^   r   r   rj   ro   rt   ry   r9   r|   r   r   rr   r   staticmethodr   dictr   __static_attributes__rJ   rI   rG   r;   r;   e   s\   # 
$ !&=?	### #  sCx 9:	#
 
#JI# Ix} 3 49 $3 = &C D C D  MQ 27c58H2I	  HL'( tS$s)T#s(^CD 
	 rI   r;   c                      \ rS rSrS\SS 4S jr  S#S\S\S\\\	\
\4         SS 4S jjrS	S S\S\S\\\	\
\4         S
\\\\4      SS4S jrS\4S jrS\S\4S jrS$S\
S\S\4S jjrS\S\S\4S jrS$S\S\\   S\4S jjrS\S\4S jr\S\\   4S j5       r S$S\S\	S\
\4   SS4S jjr\S\S\S\\   S\ S\4
S j5       r!\S\"S\ S\S\4S  j5       r#\$ S$S\S\\    S!\	S\
\\
   \%\\
4   4   SS 4S" jj5       r&Sr'g)%DictionaryObjecti  r=   r>   c                     [        SU R                  U R                  5       US5      5      nU R                  5        H:  u  p4[	        US5      (       a  UR                  U5      OUX#R                  U5      '   M<     U$ )Nr   Fr@   )r   rA   rd   rj   rB   r@   )rD   r=   d__kvs        rG   r@   DictionaryObject.replicate  sp     !!$.."2HeD
 JJLDA)0K)@)@H%a H%& ! 
rI   rJ   rK   rL   c                 @    U R                   R                  U:X  a	  U(       d  U $ [        5       n[	        SU R                  U R                  5       X5      5      nUc  / n[        UR                  5       5      S:X  a  UR                  XX#U5        U$ ! [         a     Nwf = f)rN   r   r   )
rP   rQ   rR   rp   r   rA   rd   lenkeys_clonerD   r=   rK   rL   visitedr   s         rG   rO   DictionaryObject.clone"  s    	&&**h6 ),!!$.."2HN
  Msxxz?aJJtwO
  		s   "B 
BBsrcr   Nc           
        ^^ Tc   e[        T5      mSnU[        T5      :  aZ  [        TU   [        5      (       a,  [	        [        TU   5      S::  a  TU	 TU	 MF  TU==   S-  ss'   US-  nU[        T5      :  a  MZ  [        UU4S jS 5       5      (       Ga  [        T5      mS GH  nU GH  n/ n	UT;   d  M  X;  d  M  [        TR                  U5      [        5      (       d  M;  [        TU   [        5      (       d  MU  TR                  SS5      b]  [	        [        TU   5      R                  SS5      b9  TR                  SS5      [	        [        TU   5      R                  SS5      :X  d  M  [	        STU   5      n
U nU
b  [	        SU
R                  U
R                  5       X#5      5      nUR                  bH  UR                  R                  nUR                  R                  nX4U;   a  Sn
OaUR                  X45        U	R!                  X45        Uc   eUR                  U[#        U5      '   Un U
T:X  a  Sn
O[	        SX   5      n
 U
b  M  U	 H  u  nnUR'                  XUTU5        M     GM     GM     TR)                  5        H  u  nnUT;  d  M  [        U[*        5      (       aX  [-        US	5      (       d  SUl        UR/                  X#T5      nUR                  c   eUR                  XR/                  U5      '   M{  X;  d  M  [-        US
5      (       a  UR/                  X#T5      OUU [#        U5      '   M     g! [$         a    Sn
 GNf = f)zx
Update the object from src.

Args:
    src: "DictionaryObject":
    pdf_dest:
    force_duplicate:
    ignore_fields:

Nr   r$   c              3     >#    U  H  nUT;  =(       a    UT;   =(       a    [        TR                  U5      [        5      =(       a    [        TU   [        5      =(       a}    TR	                  S S5      SL =(       db    [        [        TU   5      R	                  S S5      SL =(       d6    TR	                  S S5      [        [        TU   5      R	                  S S5      :H  v   M     g7f)/TypeN)rS   raw_getr(   r   getr   )r_   fieldrL   r   s     rG   ra   *DictionaryObject._clone.<locals>.<genexpr>Z  s      
 8 & 		3;;u-~>	 3u:'78	
 &$. I(#e*599'4HDPI777D)(#e*599'4HI	 8s   C"C%)/Next/Prev/N/V))r   r   )r   r   r   r   rP   rO   )ro   r   rS   r   r   anyr   r(   r   r   rA   rd   rP   idnum
generationaddrC   r)   rR   r   rj   rT   rB   rO   )rD   r   r=   rK   rL   r   r`   rl   r   objscur_objprev_objclonr   r   scr   vvs    `  `              rG   r   DictionaryObject._clone:  sM   ( (((]+#m$$-*C00]1-.!3%a(%a(a A% FA #m$$  
 8
 
 
 !/M9ADSM&s{{1~~FF&s1v/?@@  GGGT2:#$4c!f=AA'4PX"www5#$4c!f=AA'4P Q ?C.A? @D%1#' 2 ' 8 8$+$5$5$7!"$D  $66B(,(?(?(E(E-1-D-D-O-O
$)#6'#A.2G$) 'U,? @ KK8#+#77#76:6M6MHZ]3'+H/#*c>.2G.23Ewz.RG/ &14 %)DAqHH !_mW %)]  :h IIKDAq%a.."1&:;;/3,MJB00<<<.0.C.CD*+] #1g.. =I A'   $- /*./s   7M MMMc                 l    [        U R                  [        S U R                  5        5       5      45      $ )rZ   c              3   H   #    U  H  u  pXR                  5       4v   M     g 7fr\   r]   )r_   r   r   s      rG   ra   ,DictionaryObject.hash_bin.<locals>.<genexpr>  s     #O,$!Q

$5,s    ")rc   rd   re   rj   rf   s    rG   r^   DictionaryObject.hash_bin  s.     ^^U#O$**,#OPQ
 	
rI   keyc                 ,    [         R                  X5      $ r\   )r   __getitem__rD   r   s     rG   r   DictionaryObject.raw_get  s    **rI   defaultc                     U n[        5       n [        U5      nXT;   a  [        SU< S35      eUR                  U5        X;   a  X1   $ SU;  a  U$ [	        SUS   R                  5       5      nMa  )z
Returns the value of a key or from the parent if not found.
If not found returns default.

Args:
    key: string identifying the field to return

    default: default value to return

Returns:
    Current key or inherited one, otherwise default value.

zBDetected cycle in /Parent hierarchy when retrieving value for key ./Parentr   )rp   idr!   r   r   rU   )rD   r   r   currentr   obj_ids         rG   get_inheritedDictionaryObject.get_inherited  s     E[F '*lmplsst(uvvKK~|#' "	"--/G rI   valuec                     [        U[        5      (       d  [        S5      e[        U[        5      (       d  [        S5      e[        R	                  XU5      $ NzKey must be a PdfObjectzValue must be a PdfObject)rS   r,   r   r   __setitem__rD   r   r   s      rG   r   DictionaryObject.__setitem__  sG    #y))677%++899511rI   c                     [        U[        5      (       d  [        S5      e[        U[        5      (       d  [        S5      e[        R	                  XU5      $ r   )rS   r,   r   r   
setdefaultr   s      rG   r   DictionaryObject.setdefault  sE    #y))677%++899t%00rI   c                 d    [        [        [        R                  X5      R	                  5       5      $ r\   )r   r,   r   r   rU   r   s     rG   r   DictionaryObject.__getitem__  s#    It//:EEGHHrI   c                     SSK Jn  U R                  SS5      n[        U5      (       a  gUc   S5       eUR	                  5       nU" U5      $ )uf  
Retrieve XMP (Extensible Metadata Platform) data relevant to this
object, if available.

See Table 347 — Additional entries in a metadata stream dictionary.

Returns:
  Returns a :class:`~pypdf.xmp.XmpInformation` instance
  that can be used to access XMP metadata from the document. Can also
  return None if no metadata was found on the document root.

r   )XmpInformationz	/MetadataNmypy)xmpr   r   r.   rU   )rD   r   metadatas      rG   xmp_metadataDictionaryObject.xmp_metadata  sO     	)88K.8$$#+V+#&&(h''rI   r   r   c                 f   Ub  [        SS5        UR                  S5        U R                  5        Hl  u  p4[        U5      S:  a  US   S:X  a  US   S:X  a  M(  UR	                  X5        UR                  S5        UR	                  U5        UR                  S	5        Mn     UR                  S
5        g )Nr   r      <<
r   r$   %r   r      
   >>)r   r   rj   r   r   )rD   r   r   r   r   s        rG   r    DictionaryObject.write_to_stream  s     %&A7 	W**,JC3x!|A##b'S.7LL!!&)LL ' 	UrI   position_beforeposition_endgenerationsrQ   c                     UnU HD  nUR                   U   R                  5        H   nXs=:  a  U::  d  M  O  M  [        XW5      nM"     MF     U$ r\   )xrefvaluesmin)clsr   r   r   rQ   outr   r`   s           rG   _get_next_object_position*DictionaryObject._get_next_object_position  sM     %JXXj)002"6,66c+C 3 & 
rI   lengthc                   UR                  5       n UR                  S[        R                  5        UR                  5       nUR                  U5        U R	                  XE[        UR                  5      US9nXd-
  nXs:  a  [        SU S35      eUR                  U5      nUR                  S5      n	U	S:  a  [        SU S35      eUR                  XI-   S-   5        US U	S	-
   $ ! UR                  U5        f = f)
Nr   )r   r   r   rQ   zRequested length of   exceeds maximum allowed length.	   endstreamz6Unable to find 'endstream' marker for obj starting at r   	   r$   )tellr   osSEEK_ENDr   ro   r   r!   r   findr"   )
r   r   rQ   r   current_positionstream_lengthobject_positionbytes_to_read
read_valueendstream_positions
             rG   _read_unsized_from_stream*DictionaryObject._read_unsized_from_stream"  s    ";;=	*KK2;;'"KKMMKK()77,VZ[^[c[cVdjm 8 
 (:"#&:=/Ii$jkk [[/
'__\:!HIYHZZ[\  	$9A=>2.233' KK()s   0C$ $C7r   c           	      D   U R                  S5      nUS:w  a&  [        S[        U R                  5       5       S35      e0 n [	        U 5      nUS:X  a  M  US:X  a  U R                  SS5        [        U 5        M9  U(       d  [        [        5      eUS	:X  a  U R                  S5        OU R                  SS5          [        X5      n[        U[        5      (       a  O[        U[        5      (       d  [        S
U< 35      e [	        U 5      nU R                  SS5        [        XU5      nUR-                  U5      (       d  XU'   OQSn
[        U R                  5       5      US.nUb  UR                  (       a  [        X-  5      e[        U
4S[        0UD6  GMX  U R                  5       n[	        U 5      nUS:X  Ga  U R                  S5      S:X  Ga  U R                  S5      nUS:X  a  U R                  S5      nUS:X  a  M  US;  a  [        S5      eUS:X  a'  U R                  S5      S:w  a  U R                  SS5        [.        R0                  U;  aa  Ub  UR                  (       a  [        S5      e[        S[        U R                  5       S9  [3        S5      U[        [.        R0                  5      '   U[.        R0                     n[        U[4        5      (       a=  U R                  5       nUc   S5       eUR7                  U5      nU R                  US5        Uc  SnU R                  5       nSSKJn  US:  a*  UU:  a  [#        SU S35      eU R                  U5      US '   O"[=        U [>        R@                  " S!5      US"9US '   [	        U 5      nU R                  S#5      nUU-   S!:w  a  U R                  5       nU R                  S$S5        U R                  S%5      nUS!:X  a  US    S S US '   OUbK  UR                  (       d:  U R                  US5        [(        RC                  XUS&9US '   U R                  5       nOSU R                  US5        [        S'[        U R                  5       5       S(U< S)U< S*35      eOU R                  US5        S U;   a  [D        RG                  U5      $ [)        5       n	U	R+                  U5        U	$ ! [         a0  nUb  UR                  (       a  e [        S[        US9   S nAGM  S nAff = f! [         ["        4 a  n[        UR%                  5       5      eS nAf[&         ac  nUb*  UR                  (       a  [        UR%                  5       5      e[        S[        US9  [)        5       n	U	R+                  U5        U	s S nA$ S nAff = f)+Nr      <<zDictionary read error at byte z: stream must begin with '<<'    r   r   r$      >z)Expecting a NameObject for key but found z%(exception)r)source	exceptionzGMultiple definitions in dictionary at byte %(position)s for key %(key)s)positionr   r     s   s   treamr   )r      z)Stream data must be followed by a newliner  r   zStream length not definedz+Stream length not defined @pos=%(position)d)r  r  r   r   )MAX_DECLARED_STREAM_LENGTHzDeclared stream length of r  __streamdata__r  r   regexr      ir  )r   rQ   r   z7Unable to find 'endstream' marker after stream at byte z (nd='z', end='z').)$r   r"   hexr  r   r   r   r#   r    r   rS   r*   r)   strictr   r   RecursionErrorr!   __repr__rR   r   updater   r   LENGTHr+   r(   rU   filtersr  r   recompiler  rT   initialize_from_dictionary)r   rQ   r   r   rF   r   r   excr   retvalmsgr   posr   eolr   tpstartr  endstreamends                         rG   r   !DictionaryObject.read_from_streamB  s!    kk!n%<0V[[]1C0D E. .   "%f-Cg~d{B"!&)$%ABBd{AKKA%f2C!#z22%c:66*GwO  7 *&1B"#FA 88C==!S	3  '*&++-&8E?szz&s|44s>8>v>k n kkm'9Q83++a.C +kk!n +.($%PQQe|A% 7B"&&d2?szz()DEEA##[[]
 =I<LZ 0 7 789*112F&.11KKM../Aq!~[[]F<{66+.HPp,qrr)/V)<%&)9!L)AJd*%& $F+A{{1~HH- kkmC#kk!n,&-12B-CCR-HD)*_SZZKK*-=-W-W%7Q .X .D)* !++-CKKQ'&Qv{{}-.fXLsT + .4 KKQt#::4@@!#dU $ 3::"?8sS	 #$56 3"3<<>22 ?szz&s||~66x3O)+d#sU   ; S	 $S	  *T 	
T$S>7T >TT VT//V<AVVVr   r\   )(r   r   r   r   r   r@   r   r	   r   r
   rq   r   rO   rp   re   r   r^   r   r   r   r   r   r,   r   propertyr   r   r   rr   r   classmethodro   r   r   r   r  r   r   r   r   rJ   rI   rG   r   r     sv   # 
" !&=?	#   sCx 9:	
 
0oo $o 	o
  sCx 9:o U38_%o 
ob

# 

+3 +3 +" "s "c "H2s 23 23 21c 1(3- 13 1Is Iy I (h'=> ( (. MQ 27c58H2I	" "%58GKCyWh	  4,43D4NQ4	4 4>  HLNN'(N tS$s)T#s(^CDN 
	N NrI   r   c                   2   \ rS rSrSS\\   SS4S jjrS\4S jrS\	4S jr
S\\	   4S jrS	\	S
\SS4S jrS\S\S 4   S\SS4S jrS\S\S 4   S\SS4S jr SS	\	S\	S
\S\\S\	4      S\4
S jjrS\	S\	S\	S\	SS4
S jrS	\	SS4S jrSS jrSS jrSrg)
TreeObjecti  Ndctr>   c                 `    [         R                  U 5        U(       a  U R                  U5        g g r\   )r   __init__r$  )rD   r9  s     rG   r;  TreeObject.__init__  s$    !!$'KK rI   c                     SU ;   $ )N/FirstrJ   rf   s    rG   has_childrenTreeObject.has_children  s    4rI   c                 "    U R                  5       $ r\   )childrenrf   s    rG   __iter__TreeObject.__iter__  s    }}rI   c              #     #    U R                  5       (       d  g U [        S5         nU [        S5         nUR                  5       n[        5       n [	        U5      nXT;   a  [        S[        US9  g UR                  U5        Uv   X2:X  a  g UR                  [        S5      5      n[        U5      (       a  g UR                  5       nMx  7f)Nr>  /Lastz1Detected cycle in outline structure for %(child)s)r  childr   )
r?  r)   rU   rp   r   r   r   r   r   r.   )rD   	child_reflastrG  r   child_ids         rG   rB  TreeObject.children  s       ""H-.	Jw'($$&E%yH"R[ckpqKK!K}		*W"56Iy))((*E s   CCrG  rQ   c                 *    U R                  US U5        g r\   )insert_child)rD   rG  rQ   s      rG   	add_childTreeObject.add_child  s    %s+rI   parentnc                 <   [        U5      (       a  g Uc   S5       e[        SUR                  5       5      nSU;   aa  [        [	        S[        [
        U[        S5         5      U-   5      5      U[        S5      '   U R                  UR                  SS 5      U5        g g )Nr   r8  /Countr   r   )	r.   r   rU   r+   maxr   r)   inc_parent_counter_defaultr   )rD   rP  rQ  s      rG   rU  %TreeObject.inc_parent_counter_default  s     6""!)6)!lF$5$5$78v+7AtC
8(<!=>BC,F:h'( ++FJJy$,GK	 rI   c                    [        U5      (       a  g Uc   S5       e[        SUR                  5       5      nUR                  SS5      S:H  n[        [        UR                  SS5      5      nUS:  a  [        U5      n[        XB-   U(       a  SOS-  5      U[        S5      '   U(       d  g U R                  UR                  S	S 5      U5        g )
Nr   r8  z
/%is_open%TrS  r   r$   r   r   )	r.   r   rU   r   r   absr+   r)   inc_parent_counter_outline)rD   rP  rQ  opnr   s        rG   rY  %TreeObject.inc_parent_counter_outline  s     6""!)6)!lF$5$5$78jjt,4fjj1-.q5AA'3QUCqR4P'Qz(#$''

9d(CQGrI   beforeinc_parent_counter.c                 H   Uc  U R                   nUR                  5       nUR                  c   S5       eUR                  nSU ;  au  X`[        S5      '   [	        S5      U [        S5      '   X`[        S5      '   U R                  U[        S5      '   U" XR                  SS5      5        SU;   a  US	 S	U;   a  US		 U$ [        S
U S   5      nUR                  U:w  a  SU;   a  [        SUS   5      nOx[        SU5      U[        S5      '   UR                  U[        S	5      '   U R                  U[        S5      '   SU;   a  US	 X`[        S5      '   U" XR                  SS5      5        U$ UR                  U:w  a  M   [        US	   [        5      (       d   eXgS	   [        S5      '   US	   U[        S	5      '   Xu[        S5      '   Xg[        S	5      '   U R                  U[        S5      '   U" XR                  SS5      5        U$ ! [         a    UR                  SS 5         Njf = f)Nr   r>  r   rS  rF  r   r$   r   r   r   r8  )rU  rU   rP   r)   r+   r   r   rS   r   rR   pop)rD   rG  r\  rQ   r]  	child_objchild_referenceprevs           rG   rM  TreeObject.insert_child  s1    %!%!@!@$$&	''3;V;3*/*B*B 4)8H%&)5aDH%&(7G$%/3/F/FIj+,t]]8Q%?@)#g&)#g&""&W6%%/$L$w-8,0,OZ()151H1H	*W-.373J3J	*Y/0i'!'*,;Z()"4x)CD&& %%/	)d7m-=>>>>1@M*W-.-1']Ij)* *.*W%&$3Z !+/+B+B	*Y'(4x!;<  	)MM'4(	)s   ;;H H! H!rb  prev_refcurrI  c                 ^   UR                  [        S5      S5      nUc  U(       aP  UR                  5       nU[        S5      	 XP[        S5      '   [        U [        S5         S-
  5      U [        S5      '   g[        S5      U [        S5      '   U [        S5      	 [        S5      U ;   a  U [        S5      	 ggU(       a+  UR                  5       nX&[        S5      '   XQ[        S5      '   O X4:X  d   eU[        S5      	 X [        S5      '   [        U [        S5         S-
  5      U [        S5      '   g)	zp
Adjust the pointers of the linked list and tree node count.

Args:
    prev:
    prev_ref:
    cur:
    last:

r   Nr   r>  rS  r$   r   rF  )r   r)   rU   r+   )rD   rb  rd  re  rI  next_refnext_objs          rG   _remove_node_from_tree!TreeObject._remove_node_from_treeL  s'    77:g.5<#..0Z01-5Z)*-9H-.2.Z)* .:!_Z)*H-.g&$.Z01 / #..008G,-,4Z() {"{G,-,4Z())5d:h;O6PST6T)UDH%&rI   c                    UR                  5       nUR                  n[        S5      U;  a  [        S5      eU[        S5         U :w  a  [        S5      eSnS nS nU [        S5         nUR                  5       nU [        S5         nUR                  5       n	UbU  Xr:X  a  U R	                  XTXy5        SnO;UnUn[        S5      U;   a  U[        S5         nUR                  5       nOS nS nUb  MU  U(       d  [        S	5      e[        U5        g )
Nr   /Removed child does not appear to be a tree itemz*Removed child is not a member of this treeFr>  rF  Tr   z"Removal couldn't find item in tree)rU   rP   r)   r   ri  _reset_node_tree_relationship)
rD   rG  r`  foundrd  rb  cur_refre  last_refrI  s
             rG   remove_childTreeObject.remove_childw  s   $$&	,,i 	1NOOZ	*+t3IJJ!%j&:!;(/(:(:(<
7+,""$o++DCF HD'"c)j12((* o  ABB%i0rI   c                 t    [        S5      U ;  a  [        S5      e[        SU S   5      R                  U 5        g)z)Remove the object from the tree it is in.r   rl  r8  N)r)   r   r   rq  rf   s    rG   remove_from_treeTreeObject.remove_from_tree  s4    i ,NOO\4	?+88>rI   c                     U  H  nUR                  5       n[        U5        M      [        S5      U ;   a  U [        S5      	 [        S5      U ;   a  U [        S5      	 [        S5      U ;   a  U [        S5      	 g g )NrS  r>  rF  )rU   rm  r)   )rD   rG  r`  s      rG   
empty_treeTreeObject.empty_tree  sw    E((*I))4  h4'Z)*h4'Z)*g$&Z() 'rI   rJ   r\   r>   N)r   r   r   r   r	   r   r;  r   r?  r   rC  r   rB  r   rN  r
   r(   r   rU  rY  r   rM  ri  rq  rt  rw  r   rJ   rI   rG   r8  r8    sT   H%56 $ 
 d  # +(3- +0,s ,): ,t ,LD.,>?LDGL	LHD.,>?HDGH	H, <@11 1 	1
 %Xc3h%781 
1f)V)V#&)V-0)V8;)V	)VV#1# #1$ #1J?
*rI   r8  r`  r>   c                     U [        S5      	 [        S5      U ;   a  U [        S5      	 [        S5      U ;   a  U [        S5      	 gg)z
Call this after a node has been removed from a tree.

This resets the nodes attributes in respect to that tree.

Args:
    child_obj:

r   r   r   N)r)   )r`  s    rG   rm  rm    sJ     	*Y'('i'j)*'i'j)* (rI   c                   b  ^  \ rS rSrSS jrS\SS 4S jrS\S\S\S	\	\
\\\4         S
\\\\4      SS4U 4S jjrS\4U 4S jjrS\4S jrS\SS4S jrS\4U 4S jjr SS\S\S\\4   SS4S jjr\S\\\4   S\S   4S j5       rSS\SS4S jjrSS\\\\4   S4   S\4S jjrSrU =r$ )rT   i  r>   Nc                      SU l         S U l        g NrI   _datadecoded_selfrf   s    rG   r;  StreamObject.__init__  s    
;?rI   r=   c                    [        SU R                  U R                  5       US5      5      nU R                  Ul         U R                  nUc  S U l        O![        SUR                  U5      5      U l         U R                  5        H:  u  pE[        US5      (       a  UR                  U5      OUX$R                  U5      '   M<     U$ ! [         a     N\f = f)NrT   FDecodedStreamObjectr@   )	r   rA   rd   r  r  r@   rR   rj   rB   rD   r=   r   r  r   r   s         rG   r@   StreamObject.replicate  s     !!$.."2HeD
 JJ			,,L#$(!$()<+A+A(+K%!
 JJLDA)0K)@)@H%a H%& ! 
  		s   C  C 
CCr   rK   rL   r   c                   > [        SU5      R                  U l         [        SU5      R                  nUc  SU l        O"[        SUR                  X#U5      5      U l         [
        TU ]  XX4U5        g! [         a     Nf = f)d
Update the object from src.

Args:
    src:
    pdf_dest:
    force_duplicate:
    ignore_fields:

rT   Nr  )r   r  r  rO   rR   superr   )rD   r   r=   rK   rL   r   r  rd   s          rG   r   StreamObject._clone  s    $ .#.44

	4AAL#$(!$() &&x-P%! 	sogN  		s    A3 !A3 3
B ?B c                 J   > [        [        TU ]	  5       U R                  45      $ )rZ   )rc   r  r^   r  )rD   rd   s    rG   r^   StreamObject.hash_bin  s!     UW%'455rI   c                     U R                   $ r\   r  rf   s    rG   get_dataStreamObject.get_data	  s    zzrI   rF   c                     Xl         g r\   r  )rD   rF   s     rG   set_dataStreamObject.set_data  s    
rI   c                 H   > [         TU ]  5       nXR                  5       -  nU$ r\   )r  hash_value_datar  rD   rF   rd   s     rG   r  StreamObject.hash_value_data  s#    w&(rI   r   r   c                 X   Ub  [        SS5        [        [        U R                  5      5      U [	        [
        R                  5      '   [        R                  X5        U [
        R                  	 UR                  S5        UR                  U R                  5        UR                  S5        g )Nr   r   s   
stream
s
   
endstream)
r   r+   r   r  r)   r   r%  r   r   r   )rD   r   r   s      rG   r   StreamObject.write_to_stream  s     %&A7 5ATZZ4QZ(//01((6!(()]#TZZ ^$rI   )EncodedStreamObjectr  c                     [         R                  U ;   a  [        5       nO
[        5       nU S   Ul        U S	 [         R
                  U ;   a  U [         R
                  	 UR                  U 5        U$ )Nr  )r   FILTERr  r  r  r%  r$  )rF   r+  s     rG   r)  'StreamObject.initialize_from_dictionary"  sf    
 ""d*(*F(*F,-!"""d*%,,-drI   levelr  c           	         SSK Jn  [        R                  U ;   a  U [        R                     n[	        U[
        5      (       ac  [        [        [        R                  5      /UQ5      n [        [        5       /U R                  [        R                  [        5       5      Q5      nO{[        [        [        R                  5      U/5      n[        [        5       U R                  [        R                  [        5       5      /5      nO[        [        R                  5      nS n[        5       nUR                  U 5        X5[        [        R                  5      '   Ub  XE[        [        R                  5      '   UR                  U R                   U5      Ul        U$ ! [         a>    [        [        5       U R                  [        R                  [        5       5      /5      n Nf = f)Nr   FlateDecode)r&  r  r   r  rS   r;   r)   FTFLATE_DECODEr*   r   DECODE_PARMS	TypeErrorr  r$  encoder  )rD   r  r  fparamsr+  s         rG   flate_encodeStreamObject.flate_encode2  sm   )""d*%,,-A![))BOO!< Aq AB(#_1A1N1NP[P](^_F  BOO!<a @A$\488,<,I,I:<#XY 2??+AF$&d67z*1123@F:.;;<="))$**e<' ! (#txx0@0M0M{}']^Fs   )<F AG G pillow_parametersc                     SSK Jn  U R                  SS5      S:w  a   [        S[        U R
                  S9  U" X5      u  p4nUc  g
U$ ! [         a    [        S[        U S	9   N,f = f)a  
Try to decode the stream object as an image

Args:
    pillow_parameters: parameters provided to Pillow Image.save() method,
        cf. <https://pillow.readthedocs.io/en/stable/reference/Image.html#PIL.Image.Image.save>

Returns:
    a PIL image if proper decoding has been found
Raises:
    Exception: Errors during decoding will be reported.
        It is recommended to catch exceptions to prevent
        stops in your program.

r$   )_xobj_to_imagez/Subtype z/Imagez3%(indirect_reference)s does not seem to be an Image)r  rP   z+%(obj)r object does not seem to be an Image)r  objN)_image_xobjectr  r   r   r   rP   AttributeError)rD   r  r  	extension_imgs         rG   decode_as_imageStreamObject.decode_as_imageR  sw      	388J#x/I#'+'>'> +4C	c
 " A#s   A A$#A$r~  ry  r\   )r   ) r   r   r   r   r;  r   r@   r   r   r	   r   r
   rq   r   rp   re   r   r^   rr   r  r  r  r   r   r   r   r   r)  r  r  r   __classcell__rd   s   @rG   rT   rT     s_   @# 
2OO $O 	O
  sCx 9:O U38_%O 
O@	6# 	6% U t   MQ% %27c58H2I%	% 38n	;	< # /D @"tCH~t7K1L "X[ " "rI   rT   c                       \ rS rSrSrg)r  iw  rJ   N)r   r   r   r   r   rJ   rI   rG   r  r  w  s    rI   r  c                   L   ^  \ rS rSrS	S jrS\4S jrS\SS4U 4S jjrSrU =r	$ )
r  i{  r>   Nc                     S U l         g r\   r  rf   s    rG   r;  EncodedStreamObject.__init__|  s
    ;?rI   c                 n   SSK Jn  U R                  b  U R                  R                  5       $ [	        5       nUR                  U" U 5      5        U R                  5        H>  u  p4U[        R                  [        R                  [        R                  4;  d  M:  XBU'   M@     X l        UR                  5       $ )Nr   )decode_stream_data)r&  r  r  r  r  r  rj   r   r%  r  r  )rD   r  decodedr   r   s        rG   r  EncodedStreamObject.get_data  s    0($$--// &'+D12**,JC+224D4K4KM]MjMjkk$ ' $!!rI   rF   c                   > SSK Jn  U R                  [        R                  S5      [
        R                  [
        R                  /4;   a  [        U[        5      (       d  [        S5      eU R                  c  U R                  5         U R                  c   S5       eU R                  R                  U5        [        TU ]1  UR                  U5      5        g [        S5      e)Nr   r  r  zData must be bytesr   zJStreams encoded with a filter different from FlateDecode are not supported)r&  r  r   r   r  r  r  rS   rr   r  r  r  r  r  r  r"   )rD   rF   r  rd   s      rG   r  EncodedStreamObject.set_data  s    )88$++R0R__rFW4XXdE** 455  ($$08&80&&t,G[//56\ rI   r  ry  )
r   r   r   r   r;  rr   r  r  r   r  r  s   @rG   r  r  {  s-    @"% ""U t  rI   r  i'  c                     ^  \ rS rSrSrSr SS\S\S\S\\	\   \
\\4   4   SS4U 4S	 jjjrS
\SS 4S jr  SS
\S\S\\\\\4         SS 4S jjrS\S
\S\S\\\\\4         S\\\\4      SS4U 4S jjrS\SS4S jrS\S\
\\4   4S jrS\4S jrS\SS4U 4S jjr\S\	\\\4      4S j5       r\R>                  S\	\\\4      SS4S j5       rS S jr  SS\S\S\\4   SS4U 4S jjjr!Sr"U =r#$ )!ContentStreami  au  
In order to be fast, this data structure can contain either:

* raw data in ._data
* parsed stream operations in ._operations.

At any time, ContentStream object can either have both of those fields defined,
or one field defined and the other set to None.

These fields are "rebuilt" lazily, when accessed:

* when .get_data() is called, if ._data is None, it is rebuilt from ._operations.
* when .operations is called, if ._operations is None, it is rebuilt from ._data.

Conversely, these fields can be invalidated:

* when .set_data() is called, ._operations is set to None.
* when .operations is set, ._data is set to None.
   Nr   rQ   r   r>   c                   > X l         / U l        Uc  [        TU ]  S5        GOeUR	                  5       n[        U[        5      (       Ga  SSKJn  [        U5      =n[        :  a  [        SU S[         S35      e[        5       nSnU H  nUR	                  5       n	[        U	[        5      (       a  M*  [        U	[        5      (       d#  [        S[         [#        U	5      R                   S9  O9U	R%                  5       n
U[        U
5      -  nXt:  a  [        S	U SU S
35      eXj-  n[        U5      S:X  d  USS  S:w  d  M  US-  nUS-  nM     [        TU ]  ['        U5      5        O$UR%                  5       nUc   e[        TU ]  U5        X0l        g )NrI   r   )$MAX_ARRAY_BASED_STREAM_OUTPUT_LENGTHzArray-based stream has z > z
 elements.zFExpected StreamObject, got %(type_name)s instead. Data might be wrong.)r  	type_namez Array-based stream has at least z output bytes.r   r   r$   )rQ   _operationsr  r  rU   rS   r;   pypdf.filtersr  r   CONTENT_STREAM_ARRAY_MAX_LENGTHr!   	bytearrayr*   rT   r   r   typer  rr   r   )rD   r   rQ   r   r  r
  rF   r   r   
s_resolvednew_datastream_datard   s               rG   r;  ContentStream.__init__  s    46 >GS!&&(F&+..N%([0M4SS+1-DcCddno  !{A!"J!*j99 %j,?? 'd#+&*:&6&?&? $.#6#6#8#h-/!H"3"B6(##G"H!X#  (4yA~bce);!1  2  t-$oo/"... -.rI   r=   c           	         [        SU R                  U R                  S S 5      US5      5      nU R                  Ul         U R                  nUc  S U l        O![        SUR                  U5      5      U l         U R                  5        H:  u  pE[        US5      (       a  UR                  U5      OUX$R                  U5      '   M<     U$ ! [         a     N\f = f)Nr  Fr  r@   )r   rA   rd   r  r  r@   rR   rj   rB   r  rQ   ro   r  r   r  s         rG   r@   ContentStream.replicate  s     !!$..t"<hN
 JJ			,,L#$(!$()<+A+A(+K%!
 JJLDA)0K)@)@H%a H%& ! 
  		s    C  C 
CCrK   rL   c           	      
    U R                   R                  U:X  a	  U(       d  U $ [        5       n[	        SU R                  U R                  SS5      X5      5      nUc  / nUR                  XX#U5        U$ ! [         a     N\f = f)z
Clone object into pdf_dest.

Args:
    pdf_dest:
    force_duplicate:
    ignore_fields:

Returns:
    The cloned ContentStream

r  N)rP   rQ   rR   rp   r   rA   rd   r   r   s         rG   rO   ContentStream.clone  s    $	&&**h6 ),!!tT*H
  M

4?7K
  		s   "A5 5
BBr   r   c                    > [        SU5      n[        TU ]	  UR                  5        X l        [        UR                  5      U l        UR                  U l        g)r  r  N)r   r  r  r  rQ   ro   r  r   )rD   r   r=   rK   rL   r   src_csrd   s          rG   r   ContentStream._clone5  sH    $ os+& 2 23%55rI   c                 F   UR                  SS5        / n [        U5      nUS;   a  g UR                  SS5        UR                  5       (       d  US;   a  [        U[        R
                  U R                  S9nUS:X  a7  U/ :X  d   eU R                  U5      nU R                  R                  US45        OkU R                  R                  X$45        / nOLUS	:X  a   US
;  a  UR                  S5      nUS
;  a  M  O&UR                  [        US U R                  5      5        GM  )Nr   )rI   r   r   r$   )   '   "r     BI   INLINE IMAGEr   )r  r   rI   )r   r   isalphar   r)   delimiter_pattern_OPERATOR_LENGTH_LIMIT_read_inline_imager  rC   r   r   r   )rD   r   operandspeekoperatoriis         rG   _parse_content_stream#ContentStream._parse_content_streamO  s   Aq57&v.DxKKA||~~!5+!)E)EdNiNi u$ $r>)>008B$$++R,AB$$++X,@A!H "55!;;q>D "55 FD$:N:N OP7 rI   c           	         [        5       n [        U5      nUR                  SS5        US:X  a  OM[        XR                  5      n[        U5      nUR                  SS5        [        XR                  5      nXRU'   Mq  UR                  S5      nUS S S:X  d   eUR                  SUR                  SS	5      5      nUR                  5       n[        U[        5      (       a  US
   nSU;   d  SU;   a  [        U5      n	GO2SU;   d  SU;   a  [        U5      n	GOSU;   d  SU;   a  [        U5      n	GO SU;   d  SU;   a  [        U5      n	OUS	:X  a  UR                  SS5      n
[        U
[        5      (       a  U
S
   n
SU
;   a  SnO<SU
;   a  SnO3UR                  SU
S;   a  SOS5      nUS
:  a  US-  nO[        U5      n	SnUS
:  aB  UR                  [        [!        ["        US   5      U-  5      [!        ["        US   5      -  5      n	[        U5      nUR                  SS5        O[        U5      n	UR                  S5      n[%        U5      S:X  a  UR                  SS5        USS nUS S S:w  d  US:w  a  U[&        ;  a|  UR                  US
5        [        U5      n	UR                  S5      n[%        U5      S:X  a  UR                  SS5        USS nUS S S:w  d  US:w  a  U[&        ;  a  [)        S U< 35      eUW	S!.$ )"Nr   r$      Ir7   r   s   ID/Fz/Filterznot setr   AHxASCIIHexDecodeA85ASCII85DecodeRLRunLengthDecodeDCT	DCTDecodez/CSr  RGBCMYK   z/BPC>   /G/I/Indexed/DeviceGrayr  g       @z/Wz/H   EIrI   zHCould not extract inline image, even using fallback. Expected 'EI', got )settingsrF   )r   r   r   r   rQ   r   r   r  rS   ro   r1   r0   r3   r2   r4   r   r   r   r   r   r#   )rD   r   r  r   r   r   r   filtrsavposrF   cslcsbitseiei_trailings                  rG   r   ContentStream._read_inline_imagep  s    $%%f-CKKAd{fhh/C%f-CKKA1E!SM  kk!n2Aw%T8<<	9#EFeT""!HEE>-63F;De^%71&9DU]/584V<De^{e3-f5DieR(B"d##U{2||FFAB !8*C1&9DCQw{{c8D>2S89Dhtn<UU %V,BKKA)&1D[[^ r7a<KKA1gbq6U?{c1k6TKK")&1DQB2w!|B"Qq'K"1vs"{+'E
 %^_a^de  %d33rI   c                 \   U R                   (       Gd  [        5       nU R                   H  u  p#US:X  a  UR                  S5        [        5       nUS   R	                  U5        UR                  UR                  5       SS 5        UR                  S5        UR                  US   5        UR                  S5        O<U H%  nUR	                  U5        UR                  S	5        M'     UR                  U5        UR                  S
5        M     UR                  5       U l         U R                   $ )Nr  r  r  r   s   ID rF   r  r   r   )r  r   r  r   r   getvalue)rD   r  r  r  	dict_textops         rG   r  ContentStream.get_data  s    zzzyH&*&6&6".NN5) '	IZ(88CNN9#5#5#7"#=>NN6*NN8F#34NN5)&**84 t, ' NN8,u% '7 "**,DJzzrI   rF   c                 2   > [         TU ]  U5        / U l        g r\   )r  r  r  r  s     rG   r  ContentStream.set_data  s    rI   c                     U R                   (       d<  U R                  (       a+  U R                  [        U R                  5      5        SU l        U R                   $ r}  )r  r  r  r   rf   s    rG   
operationsContentStream.operations  s;    DJJ&&wtzz':;DJrI   r  c                     Xl         SU l        g r}  )r  r  )rD   r  s     rG   r  r    s    %
rI   c                     U R                   (       a<  U R                   R                  S/ S45        U R                   R                  / S45        g U R                  (       a  SU R                  -   S-   U l        g g )Nr      q   Qs   q
s   
Q
)r  insertrC   r  rf   s    rG   isolate_graphics_state$ContentStream.isolate_graphics_state  s^    ##ADz2##RJ/ZZ$**,x7DJ rI   r   c                    > U R                   (       d!  U R                  (       a  U R                  5         [        TU ]  X5        g r\   )r  r  r  r  r   )rD   r   r   rd   s      rG   r   ContentStream.write_to_stream  s*     zzd..MMO7rI   )r  r  r  r   rQ   r\   r   ry  )$r   r   r   r   __doc__r  r   r
   rq   ro   r   r   r;  r   r@   r   r	   r   rO   r   rp   re   r   r   r  r  rr   r  r  r5  r  setterr  r   r   r  r  s   @rG   r  r    s   & ! HL	6/6/ 6/ tS$s)T#s(^CD	6/
 
6/ 6/p# 
B !&=?	"" "  sCx 9:	"
 
"H66 $6 	6
  sCx 9:6 U38_%6 
64QJ Q4 QBQ4 Q4S#X Q4h% ,U t   DsEz!23     T%U
*;%<   8 MQ8 827c58H2I8	8 8rI   r  r   rQ   r   c                 p   U R                  S5      nU R                  SS5        US:X  a  [        R                  " X5      $ US:X  aJ  U R                  S5      nU R                  SS5        US:X  a  [        R                  XU5      $ [        X5      $ US:X  a  [        R                  XU5      $ US	;   a  [        R                  " U 5      $ US
:X  a  [        X5      $ US:X  a  U R                  S5      S:X  a
  [        5       $ US:X  a  [        R                  " U 5      $ US:X  a4  [        U 5        [        U 5      nU R                  SS5        [        XU5      $ US;   ay  U R                  S5      nU R                  [        U5      * S5        [        R                  U5      b   Uc   S5       e[         R                  " X5      $ ["        R                  " U 5      $ U R%                  5       nU R                  SS5        U R                  S5      nU R                  U5        ['        U 5        [)        SU< SU SU< 35      e)Nr$   r      /   <r   r  r  r   )   t   f   (   e   s   endobj   nr   s   0123456789+-.   r   iP   z(Invalid Elementary Object starting with z @z: )r   r   r)   r   r   r5   r;   r%   r6   r*   r   r   r   r   IndirectPatternmatchr(   r+   r  r   r"   )r   rQ   r   r   r  r-  stream_extracts          rG   r   r     s   
 ++a.C
KKA
d{**677
d{{{1~B5=#44V/RR*6CC
d{++FII
l--f55
d{&v??
d{v{{1~2|
d{**622
d{&!!&)B688
{{2SYJ"  &2?*F*?!226??,,V44
++-C
KKQ[[_N
KK&!

23'C5>BTU rI   c                   V   \ rS rSrSrS\SS4S jr\S\\	   4S j5       r
\S\\   4S j5       r\S\S	   4S
 j5       r\S\\   4S j5       r\S\\   4S j5       r\S\\   4S j5       r\S\\   4S j5       r\S\\   4S j5       r\S\\   4S j5       r\S\\   4S j5       rSrg)Fieldi,  z{
A class representing a field dictionary.

This class is accessed through
:meth:`get_fields()<pypdf.PdfReader.get_fields>`
rF   r>   Nc                 6   [         R                  U 5        [        R                  " 5       [        R                  " 5       -   nUR
                  U l        U H  n X   U [        U5      '   M     [        U R                  S5      [        5      (       ay  [        [        U [        S5         5      R                  5       n[        U[        5      (       a  UR                  5       nOUc  SnO[        S5      e[!        U5      U [        S5      '   g g ! [         a     M  f = f)Nr   r  zShould never happen)r   r;  r   
attributesr   rP   r)   KeyErrorrS   r   r  r   r  rr   decoderR   r-   )rD   rF   field_attributesattrdd_strs         rG   r;  Field.__init__4  s    !!$'%002+6689 	 #'"9"9$D)-Z%& %
 dhhtn&9::($z$/?*@AJJLA!U##
 566%5e%<DD!" ;  s   D


DDc                 @    U R                  [        R                  5      $ )z4Read-only property accessing the type of this field.)r   r   r  rf   s    rG   
field_typeField.field_typeK       xx14455rI   c                 @    U R                  [        R                  5      $ )z6Read-only property accessing the parent of this field.)r   r   Parentrf   s    rG   rP  Field.parentP  s     xx18899rI   r;   c                 @    U R                  [        R                  5      $ )z4Read-only property accessing the kids of this field.)r   r   Kidsrf   s    rG   kids
Field.kidsU  s     xx16677rI   c                 @    U R                  [        R                  5      $ )z4Read-only property accessing the name of this field.)r   r   Trf   s    rG   name
Field.nameZ  s     xx13344rI   c                 @    U R                  [        R                  5      $ )z>Read-only property accessing the alternate name of this field.)r   r   TUrf   s    rG   alternate_nameField.alternate_name_  r6  rI   c                 @    U R                  [        R                  5      $ )z
Read-only property accessing the mapping name of this field.

This name is used by pypdf as a key in the dictionary returned by
:meth:`get_fields()<pypdf.PdfReader.get_fields>`
)r   r   TMrf   s    rG   mapping_nameField.mapping_named       xx14455rI   c                 @    U R                  [        R                  5      $ )z
Read-only property accessing the field flags, specifying various
characteristics of the field (see Table 8.70 of the PDF 1.7 reference).
)r   r   Ffrf   s    rG   flagsField.flagsn  s     xx14455rI   c                 @    U R                  [        R                  5      $ )z[
Read-only property accessing the value of this field.

Format varies based on field type.
)r   r   Vrf   s    rG   r   Field.valuev  s     xx13344rI   c                 @    U R                  [        R                  5      $ )z=Read-only property accessing the default value of this field.)r   r   DVrf   s    rG   default_valueField.default_value  r6  rI   c                 @    U R                  [        R                  5      $ )z
Read-only property accessing the additional actions dictionary.

This dictionary defines the field's behavior in response to trigger
events. See Section 8.5.2 of the PDF 1.7 reference.
)r   r   AArf   s    rG   additional_actionsField.additional_actions  rJ  rI   )rP   )r   r   r   r   r  r   r;  r5  r	   r)   r4  rP  r<  rq   r@  rD  rH  r   rM  r   r   rT  rX  r   rJ   rI   rG   r)  r)  ,  sW   =- =$ =. 6HZ0 6 6 :!12 : : 8h}- 8 8 5hsm 5 5 6 6 6 6hsm 6 6 6x} 6 6 5x} 5 5 6x} 6 6 6H-=$> 6 6rI   r)  c                      \ rS rSr% SrSr\\   \S'   S\	\
\4   S\	\\\\4   S\SS4S	 jr\SS j5       r SS\S\	S\
\4   SS4S jjr\S\\
   4S j5       r\S\\   4S j5       r\S\\
   4S j5       r\S\\   4S j5       r\S\\   4S j5       r\S\\   4S j5       r\S\\   4S j5       r\S\\   4S j5       r\S\S
   4S j5       r\S\\    4S j5       r!\S\\   4S j5       r"Sr#g)Destinationi  a  
A class representing a destination within a PDF file.

See section 12.3.2 of the PDF 2.0 reference.

Args:
    title: Title of this destination.
    page: Reference to the page of this destination. Should
        be an instance of :class:`IndirectObject<pypdf.generic.IndirectObject>`.
    fit: How the destination is displayed.

Raises:
    PdfReadError: If destination type is invalid.

Nnodetitlepagefitr>   c                    / U l         UR                  nUR                  n[        R	                  U 5        [        U5      U [        S5      '   X [        S5      '   X@[        S5      '   US:X  a  [        U5      S:  a  UR                  [        S5      5        [        U5      S:  a  UR                  [        S5      5        [        U5      S:  a  UR                  [        S5      5        US S u  U [        [        R                  5      '   U [        [        R                  5      '   U [        S	5      '   g [        U5      S
:X  a  g U[        R                  :X  Ga  [        U5      S:X  ap  Uu  U [        [        R                  5      '   U [        [        R                  5      '   U [        [        R                   5      '   U [        [        R                  5      '   g [#        5       [#        5       [#        5       [#        5       4u  U [        [        R                  5      '   U [        [        R                  5      '   U [        [        R                   5      '   U [        [        R                  5      '   g U[        R$                  [        R&                  4;   a    Uu  U [        [        R                  5      '   g U[        R*                  [        R,                  4;   a    Uu  U [        [        R                  5      '   g U[        R.                  [        R0                  4;   a  g [3        SU< 35      e! [(         a'    [#        5       U [        [        R                  5      '    g f = f! [(         a'    [#        5       U [        [        R                  5      '    g f = f)N/Title/Pager   z/XYZr$   g        r   r7   /Zoomr   r  zUnknown Destination Type: )_filtered_childrenfit_typefit_argsr   r;  r-   r)   r   rC   r+   TALEFTTOPTFFIT_RBOTTOMRIGHTr*   FIT_HFIT_BHrR   FIT_VFIT_BVFITFIT_Br"   )rD   r]  r^  r_  typargss         rG   r;  Destination.__init__  s    .0ll||!!$'%5e%<Z!"$(Z !$'Z ! &=4y1}L-.4y1}L-.4y1}L-. Ra	Z()Z'(Z()Y!^BHH_4yA~ BGG,-BII./BHH-.BFF+,  \:<z|LBGG,-BII./BHH-.BFF+,RXXryy))>.2+j() RXXryy))?/3,j)* RVVRXX&&!;C7CDD  >/9|j()>
  ?0:j)*?s$   L% M %.MM.N
	N
r;   c                     [        U R                  S5      U S   /S Vs/ s H  nX;   d  M
  X   PM     sn-   5      $ s  snf )Nrb  r   )/Left/Bottom/Right/Toprc  )r;   r   )rD   r`   s     rG   
dest_arrayDestination.dest_array  sU    \\'"DM2 IHA9 H
 	
s   	=
=
r   r   c                    Ub  [        SS5        UR                  S5        [        S5      nUR                  U5        UR                  S5        U R                  nUR                  U5        [        S5      nUR                  U5        UR                  S5        [        S5      nUR                  U5        UR                  S5        UR                  S	5        g )
Nr   r   r   z/Dr   z/Sz/GoTor   r   )r   r   r)   r   r|  )rD   r   r   r   r   value_ss         rG   r   Destination.write_to_stream  s     %&A7 	WF#Tf%F#TW%'UUrI   c                 $    U R                  S5      $ )z3Read-only property accessing the destination title.ra  r   rf   s    rG   r]  Destination.title  s     xx!!rI   c                 $    U R                  S5      $ )zHRead-only property accessing the IndirectObject of the destination page.rb  r  rf   s    rG   r^  Destination.page	       xx  rI   c                 $    U R                  S5      $ )z2Read-only property accessing the destination type.r   r  rf   s    rG   rt  Destination.typ  r  rI   c                 &    U R                  SS5      $ )z-Read-only property accessing the zoom factor.rc  Nr  rf   s    rG   zoomDestination.zoom       xx&&rI   c                 &    U R                  SS5      $ )z<Read-only property accessing the left horizontal coordinate.rx  Nr  rf   s    rG   leftDestination.left  r  rI   c                 &    U R                  SS5      $ )z=Read-only property accessing the right horizontal coordinate.rz  Nr  rf   s    rG   rightDestination.right  s     xx$''rI   c                 &    U R                  SS5      $ )z9Read-only property accessing the top vertical coordinate.r{  Nr  rf   s    rG   topDestination.top"  s     xx%%rI   c                 &    U R                  SS5      $ )z<Read-only property accessing the bottom vertical coordinate.ry  Nr  rf   s    rG   bottomDestination.bottom'  s     xx	4((rI   c                     [        SU R                  S[        [        S5      [        S5      [        S5      /5      5      5      $ )zHRead-only property accessing the color in (R, G, B) with values 0.0-1.0.r;   z/Cr   )r   r   r;   r'   rf   s    rG   colorDestination.color,  s;     HHT;AATU'WXY
 	
rI   c                 8    [        U R                  SS5      5      $ )zG
Read-only property accessing the font type.

1=italic, 2=bold, 3=both
r  r   )r   r   rf   s    rG   font_formatDestination.font_format4  s     txxa011rI   c                 &    U R                  SS5      $ )z
Read-only property accessing the outline count.

positive = expanded
negative = collapsed
absolute value = number of visible descendants at all levels
rS  Nr  rf   s    rG   outline_countDestination.outline_count=  s     xx$''rI   )rd  )r>   r;   r\   )$r   r   r   r   r  r\  r	   r   __annotations__r
   rq   rr   r+   r(   r*   r/   r;  r5  r|  r   r   r]  r^  rt  r   r  r'   r  r  r  r  r  r   r  r  r   rJ   rI   rG   r[  r[    s	   $ 	 	( <ES%Z <E L.*>NNO<E 	<E
 
<E| 
 
 MQ 27c58H2I	. "x} " " !h~. ! ! !Xc] ! ! 'hsm ' ' 'h{+ ' ' (x, ( ( &Xk* & & )- ) ) 
x. 
 
 2Xo6 2 2 (x} ( (rI   r[  r\   )^
__author____author_email__loggingr  r'  syscollections.abcr   r   ior   mathr   typingr   r   r	   r
   r   
_protocolsr   r   r   _utilsr   r   r   r   r   r   r   r   r   	constantsr   r   r   r   r   r  r   rg  r   rj  errorsr    r!   r"   r#   _baser%   r&   r'   r(   r)   r*   r+   r,   r-   r.   _fitr/   _image_inliner0   r1   r2   r3   r4   r5   r6   version_infor9   typing_extensions	getLoggerr   loggerr(  r%  ro   r;   r   r   r8  rm  rT   r  r  r  r  rq   r   r   r)  r[  rJ   rI   rG   <module>r     s  : 
/   	 	 
 .    V U
 
 
  * * - b b     Iw&			8	$**@Ak$s)Y k\~tCH~y ~BX*! X*v+S +T +"t# tn	, 	$, $N #) R8' R8p
 DH//	#	$/ 4d3ic3h?@/ 9c3-.	/d`6J `6Fw(* w(rI   