
    )i                     H   S SK r S SKrS SKJr  S SKJrJrJrJr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  SS	KJr  SS
KJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSK J!r!  SSK"J#r#  SSK"J$r$  SSK"J%r%  SSK"J&r&  SSK"J'r'  SSK"J(r(  SSK"J)r)  SSK*J+r+  SSK*J,r,  SSK*J-r-  SSK*J.r.  SSK*J/r/J0r0  SS K*J1r1  SS!K*J2r2  SS"K*J3r3  SS#K*J4r4  SS$K5J6r6  SS%K5J7r7J8r8J9r9J:r:  SS&K5J;r;  SS'K5J<r<  \ Rz                  " \>5      r? " S( S)\#5      r@ " S* S+\#5      rA\," S,5      rB\," S-5      rC\," S.5      rD\," S/5      rE\," S05      rF " S1 S25      rG\\H\
\H\H\H4   \
\H\H\H\H4   4   rI " S3 S45      rJ " S5 S65      rK " S7 S8\1\\.\%4      5      rL\2\%   rM  " S9 S:5      rNg);    N)BytesIO)DictListMappingOptionalSequenceTupleUnioncast   )settings)CMap)CMapBase)CMapDB)PDFColorSpace)PREDEFINED_COLORSPACE)	PDFDevice)
PDFTextSeq)
PDFCIDFont)PDFFont)PDFFontError)PDFTrueTypeFont)PDFType1Font)PDFType3Font)PDFPage)PDFException)	PDFObjRef)	PDFStream)
dict_value)
list_value)resolve1)stream_value)KWD)LIT)PSEOF)	PSKeyword)	PSLiteralPSTypeError)PSStackParser)PSStackType)keyword_name)literal_name)MATRIX_IDENTITY)MatrixPointPathSegmentRect)choplist)mult_matrixc                       \ rS rSrSrg)PDFResourceError-    N__name__
__module____qualname____firstlineno____static_attributes__r7       R/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/pdfminer/pdfinterp.pyr5   r5   -       r>   r5   c                       \ rS rSrSrg)PDFInterpreterError1   r7   Nr8   r7   r>   r?   rB   rB   1   r@   r>   rB   PDFTextFontFormImagec                   V    \ rS rSr% \\S'   \\S'   SS jrS\4S jr	SS jr
SS	 jrS
rg)PDFTextState<   matrix
linematrixreturnNc                     S U l         SU l        SU l        SU l        SU l        SU l        SU l        SU l        U R                  5         g )Nr   d   )	fontfontsize	charspace	wordspacescalingleadingrenderriseresetselfs    r?   __init__PDFTextState.__init__@   sC    '+	  ! !!	

r>   c                     SU R                   < SU R                  < SU R                  < SU R                  < SU R                  < SU R
                  < SU R                  < SU R                  < S	U R                  < S
U R                  < S3$ )Nz<PDFTextState: font=z, fontsize=z, charspace=z, wordspace=z
, scaling=z
, leading=z	, render=z, rise=z	, matrix=z, linematrix=>)
rQ   rR   rS   rT   rU   rV   rW   rX   rL   rM   rZ   s    r?   __repr__PDFTextState.__repr__M   sT     					
r>   c                 n   [        5       nU R                  Ul        U R                  Ul        U R                  Ul        U R                  Ul        U R
                  Ul        U R                  Ul        U R                  Ul        U R                  Ul        U R                  Ul	        U R                  Ul
        U$ N)rJ   rQ   rR   rS   rT   rU   rV   rW   rX   rL   rM   r[   objs     r?   copyPDFTextState.copy`   s|    n99}}llll[[
99[[

r>   c                 (    [         U l        SU l        g )Nr   r   )r-   rL   rM   rZ   s    r?   rY   PDFTextState.resetn   s    % r>   )
rS   rQ   rR   rV   rM   rL   rW   rX   rU   rT   rN   N)rN   rJ   )r9   r:   r;   r<   r.   __annotations__r/   r\   strr`   rf   rY   r=   r7   r>   r?   rJ   rJ   <   s(    N	
# 
&!r>   rJ   c                   6    \ rS rSrSS jrS	S jrS\4S jrSrg)
PDFGraphicStatez   rN   Nc                     SU l         S U l        S U l        S U l        S U l        S U l        S U l        S U l        S U l        g Nr   		linewidthlinecaplinejoin
miterlimitdashintentflatnessscolorncolorrZ   s    r?   r\   PDFGraphicState.__init__{   sE     !)-*.,059	(,*. (, (,r>   c                 L   [        5       nU R                  Ul        U R                  Ul        U R                  Ul        U R                  Ul        U R
                  Ul        U R                  Ul        U R                  Ul        U R                  Ul        U R                  Ul	        U$ rc   )
ro   rt   ru   rv   rw   rx   ry   rz   r{   r|   rd   s     r?   rf   PDFGraphicState.copy   sr    ll}}99[[
}}[[
[[

r>   c                    SU R                   < SU R                  < SU R                  < SU R                  < SU R                  < SU R
                  < SU R                  < SU R                  < S	U R                  < S
3$ )Nz<PDFGraphicState: linewidth=z
, linecap=z, linejoin=z,  miterlimit=z, dash=z	, intent=z, flatness=z,  stroking color=z, non stroking color=r_   rs   rZ   s    r?   r`   PDFGraphicState.__repr__   sM     			
r>   )	rx   rz   ry   ru   rv   rt   rw   r|   r{   rk   )rN   ro   )	r9   r:   r;   r<   r\   rf   rm   r`   r=   r7   r>   r?   ro   ro   z   s    ,
# 
r>   ro   c                       \ rS rSrS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\4S jrSrg)PDFResourceManager   zRepository of shared resources.

ResourceManager facilitates reuse of shared resources
such as fonts and images so that large objects are not
allocated multiple times.
cachingrN   Nc                     Xl         0 U l        g rc   )r   _cached_fonts)r[   r   s     r?   r\   PDFResourceManager.__init__   s    46r>   procsc                 B    U H  nU[         L a  M  U[        L a  M  M     g rc   )LITERAL_PDFLITERAL_TEXT)r[   r   procs      r?   get_procsetPDFResourceManager.get_procset   s%    D{"% r>   cmapnamestrictc                      [         R                  " U5      $ ! [         R                   a    U(       a  e [        5       s $ f = frc   )r   get_cmapCMapNotFoundr   )r[   r   r   s      r?   r   PDFResourceManager.get_cmap   s8    	??8,,"" 	6M	s    &A Aobjidspecc                 T   U(       a   XR                   ;   a  U R                   U   nU$ [        R                  SX5        [        R                  (       a  US   [
        La  [        S5      eSU;   a  [        US   5      nO"[        R                  (       a  [        S5      eSnUS;   a  [        X5      nOUS:X  a  [        X5      nOUS	:X  a  [        X5      nOUS
;   a  [        X5      nOUS:X  ae  [        US   5      nU(       d   e[        US   5      R                  5       nS H  nXr;   d  M
  [        X'   5      Xg'   M     U R!                  S U5      nO.[        R                  (       a  [        SU-  5      e[        X5      nU(       a  U R"                  (       a  X0R                   U'   U$ )Nz#get_font: create: objid=%r, spec=%rTypezType is not /FontSubtypezFont Subtype is not specified.Type1)r   MMType1TrueTypeType3)CIDFontType0CIDFontType2Type0DescendantFontsr   )Encoding	ToUnicodezInvalid Font spec: %r)r   logdebugr   STRICTLITERAL_FONTr   r,   r   r   r   r   r    r   rf   r!   get_fontr   )r[   r   r   rQ   subtypedfontssubspecks           r?   r   PDFResourceManager.get_font   st   U000%%e,DP M II;UI<|3&':;;D &tI7??&'GHH!..#D/J&&t2G##D/<<!$-G##D):$;<v$VAY/4462Ay%-dg%6
 3 }}T73??&'>'EFF#D/,0""5)r>   )r   r   )T)F)r9   r:   r;   r<   __doc__boolr\   r   objectr   rm   r   r   r   r   r   r=   r7   r>   r?   r   r      so    7 7 7&!1 d  d x *f *GCK,@ *W *r>   r   c            	           \ rS rSrS\\   SS4S jrSS jrS\SS4S jr	SS	 jr
SS\S\S\\\4   4S jjrSS jr\" S5      r\" S5      r\" S
5      rS\S\SS4S jrSrg)PDFContentParser   streamsrN   Nc                 L    Xl         SU l        [        R                  " U S 5        g rr   )r   istreamr)   r\   )r[   r   s     r?   r\   PDFContentParser.__init__   s      	tT*r>   c                 0   U R                   (       d  U R                  [        U R                  5      :  a8  [	        U R                  U R                     5      nU =R                  S-  sl        O[        S5      e[        UR                  5       5      U l         g g )Nr   zUnexpected EOF, file truncated?)fpr   lenr   r"   r%   r   get_data)r[   strms     r?   fillfpPDFContentParser.fillfp   sf    ww||c$,,//#DLL$>?!=>>dmmo.DG r>   posc                 P    U R                  5         [        R                  " X5        g rc   )r   r)   seek)r[   r   s     r?   r   PDFContentParser.seek  s    4%r>   c                 D   U R                   [        U R                  5      :  a  g  U R                  5         U R                  R                  5       U l        U R                  R                  U R                  5      U l        U R                  (       a  O	S U l        Mt  SU l         g rr   )	charposr   bufr   r   tellbufposreadBUFSIZrZ   s    r?   fillbufPDFContentParser.fillbuf
  sm    <<#dhh-'KKM'',,.DKww||DKK0DHxxDG  r>      EItargetc                 N   U R                  U5        SnSnU[        U5      ::  Ga  U R                  5         U(       a  U R                  U R                     n[        U45      nXF-  nU =R                  S-  sl        [        U5      U::  a  UR                  5       (       a  US-  nO~U[        U5      :  a  U[        X#   45      :X  a  US-  nOWSnOT U R                  R                  US   U R                  5      nX@R                  U R                  US-    -  nUS-   U l        SnU[        U5      ::  a  GM  US [        U5      S-   *  n[        R                  " SSU5      nX4$ ! [         a8    X@R                  U R                  S  -  n[        U R                  5      U l         Nf = f)Nr   r>   r   s   (\x0d\x0a|[\x0d\x0a])$)r   r   r   r   r   bytesisspaceindex
ValueErrorresub)r[   r   r   idatacicjs           r?   get_inline_data PDFContentParser.get_inline_data  so   		#3v;LLNXXdll+2%L	!v;!#		FAV_ufi\/B)CFAA1vay$,,?AHHT\\AE::D#$q5DLA% 3v;, (Fa()vv0#t<{ " 1HHT\\^44D#&txx=DL1s   AE" "?F$#F$c                 >    U R                   " U R                  5       6   g rc   )add_resultspopallrZ   s    r?   flushPDFContentParser.flush4  s    $++-(r>   s   BIs   IDtokenc                 h   X R                   L a  U R                  US5        g X R                  L a   U R                  S5      u  p4[	        U5      S-  S:w  a  SR                  U5      n[        U5      e[        SU5       VVs0 s H  u  pg[        U5      U_M     nnnU R                  U[	        S5      -   5      u  p[        X5      n
U R                  X45        U R                  XR                  45        g U R                  X45        g s  snnf ! [         a    [        R                  (       a  e  g f = f)Ninline   r   z"Invalid dictionary construct: {!r}s   ID )
KEYWORD_BI
start_type
KEYWORD_IDend_typer   formatr(   r2   r,   r   r   push
KEYWORD_EIr   r   )r[   r   r   _objs	error_msgr   vdr   re   s              r?   
do_keywordPDFContentParser.do_keyword;  s   OO#OOC*oo% MM(3	t9q=A% D K KD QI%i006>q$6GH6GFQ\!_a'6GH"223V3DE(		3*%		301
 IIsl# I
  ?? #s%   AD DAD D  D10D1)r   r   r   r   r   r   rk   )r   )r9   r:   r;   r<   r   r   r\   r   intr   r   r   r	   r   r   r#   r   r   r   r&   r   r=   r7   r>   r?   r   r      s    + 0 +T +/& & &
3  %U
BS <) UJUJUJ$c $) $ $r>   r   c                      \ rS rSrSrS\S\SS4S jrSS jrS	\	\
\
4   SS4S
 jrS\SS4S jrS\SS4S jrS\S\\   4S jrS\\\\4   4S jrS\\\\4   SS4S jrSS jrSS jrS\S\S\S\S\S\SS4S jrS\SS4S jrS\SS4S  jrS!\SS4S" jrS#\SS4S$ jrS%\S&\SS4S' jrS(\SS4S) jr S*\SS4S+ jr!S,\SS4S- jr"S.\S/\SS4S0 jr#S.\S/\SS4S1 jr$S2\S3\S4\S5\S6\S7\SS4S8 jr%S4\S5\S6\S7\SS4
S9 jr&S2\S3\S6\S7\SS4
S: jr'SS; jr(S.\S/\S<\S=\SS4
S> jr)SS? jr*SS@ jr+SSA jr,SSB jr-SSC jr.SSD jr/SSE jr0SSF jr1SSG jr2SSH jr3SSI jr4SSJ jr5S,\SS4SK jr6S,\SS4SL jr7SM\SS4SN jr8SM\SS4SO jr9SP\SQ\SR\SS4SS jr:SP\SQ\SR\SS4ST jr;SU\SV\S/\SW\SS4
SX jr<SU\SV\S/\SW\SS4
SY jr=SSZ jr>SS[ jr?SS\ jr@SS] jrAS,\
SS4S^ jrBSS_ jrCSS` jrDSSa jrESSb jrFSc\SS4Sd jrGSc\Se\SS4Sf jrHSc\SS4Sg jrISc\Se\SS4Sh jrJSSi jrKSj\SS4Sk jrLSj\SS4Sl jrMSm\SS4Sn jrNSo\SS4Sp jrOSq\Sr\SS4Ss jrPSt\SS4Su jrQSv\SS4Sw jrRSx\Sy\SS4Sz jrSSx\Sy\SS4S{ jrTS|\SR\SU\S}\S~\S\SS4S jrUSS jrVS\SS4S jrWS\SS4S jrXS\SS4S jrYS\S\S\SS4S jrZSS jr[SS jr\S\SS4S jr]S\SS4S jr^S\_SS4S jr`\a4S	\	\
\
4   S\b\
   S\SS4S jjrcS\b\
   SS4S jrdSreg)PDFPageInterpreteriU  z`Processor for the content of a PDF page

Reference: PDF Reference, Appendix A, Operator Summary
rsrcmgrdevicerN   Nc                     Xl         X l        g rc   )r   r   )r[   r   r   s      r?   r\   PDFPageInterpreter.__init__[  s    r>   c                 N    U R                  U R                  U R                  5      $ rc   )	__class__r   r   rZ   s    r?   dupPDFPageInterpreter.dup`  s    ~~dllDKK88r>   	resourcesc                 |   Xl         0 U l        0 U l        [        R                  " 5       U l        U(       d  gS[        S[        [           4S jn[        U5      R                  5        GHP  u  p4[        R                  SX45        US:X  az  [        U5      R                  5        H[  u  pVSn[        U[        5      (       a  UR                  n[        U5      nU R                   R#                  Xv5      U R                  U'   M]     M  US:X  aH  [        U5      R                  5        H)  u  pU" [%        U5      5      n	U	c  M  XR
                  U'   M+     M  US:X  a'  U R                   R'                  [)        U5      5        GM  US	:X  d  GM   [        U5      R                  5        H  u  pXR                  U
'   M     GMS     g)
z@Prepare the fonts and XObjects listed in the Resource attribute.Nr   rN   c           	         [        U [        5      (       a  [        U S   5      nO[        U 5      nUS:X  a?  [        U [        5      (       a*  S[        U 5      ::  a  [	        U[        U S   5      S   5      $ US:X  aE  [        U [        5      (       a0  S[        U 5      ::  a!  [	        U[        [        U S   5      5      5      $ [        R                  " U5      $ )Nr   ICCBasedr   r   NDeviceN)	
isinstancelistr,   r   r   r"   r    r   get)r   names     r?   get_colorspace9PDFPageInterpreter.init_resources.<locals>.get_colorspacel  s    $%%#DG,#D)z!jt&<&<c$i$T<Q+@+EFF"z$'='=!s4y.$T3z$q'/B+CDD,0066r>   zResource: %r: %rrF   
ColorSpaceProcSetXObject)r   fontmapxobjmapr   rf   csmapr   r   r   r   itemsr   r   r  r   r   r   r   r!   r   r    )r[   r   r	  r   r   fontidr   r   csid
colorspacexobjidxobjstrms               r?   init_resources!PDFPageInterpreter.init_resourcesc  se   ".0/D/I/I/K

	7 
	7H],C 
	7 !+113FQII(!/F{&0m&9&9&;NV E!$	22 $

%d+D+/<<+@+@+MDLL( '< l"$.qM$7$7$9LT!/!?J!-+5

4( %: i((A7i*4Q-*=*=*?&V+3LL( +@# 4& 	r>   ctmc                 n   / U l         Xl        U R                  R                  U R                  5        [	        5       U l        [        5       U l        / U l        / U l	        SU l
        SU l        U R                  (       a8  [        [        U R                  R                  5       5      5      =U l
        U l        g)z<Initialize the text and graphic states for rendering a page.N)gstackr  r   set_ctmrJ   	textstatero   graphicstatecurpathargstackscsncsr  nextitervalues)r[   r  s     r?   
init_statePDFPageInterpreter.init_state  s     KMDHH%%+-*,)+,0,0::"&tDJJ,=,=,?'@"AADHtxr>   re   c                 :    U R                   R                  U5        g rc   )r   appendrd   s     r?   r   PDFPageInterpreter.push  s    S!r>   nc                 `    US:X  a  / $ U R                   U* S  nU R                   S U*  U l         U$ rr   )r   )r[   r+  xs      r?   popPDFPageInterpreter.pop  s9    6IMM1"#cr*r>   c                     U R                   U R                  R                  5       U R                  R                  5       4$ rc   )r  r  rf   r  rZ   s    r?   get_current_state$PDFPageInterpreter.get_current_state  s/    $..--/1B1B1G1G1IJJr>   statec                 x    Uu  U l         U l        U l        U R                  R	                  U R                   5        g rc   )r  r  r  r   r  )r[   r3  s     r?   set_current_state$PDFPageInterpreter.set_current_state  s0     9>54>4#4DHH%r>   c                 V    U R                   R                  U R                  5       5        g)zSave graphics stateN)r  r)  r1  rZ   s    r?   do_qPDFPageInterpreter.do_q  s     41134r>   c                 x    U R                   (       a)  U R                  U R                   R                  5       5        g)zRestore graphics stateN)r  r5  r.  rZ   s    r?   do_QPDFPageInterpreter.do_Q  s%    ;;""4;;??#45r>   a1b1c1d1e1f1c                     [        [        [        XX4XV45      U R                  5      U l        U R                  R                  U R                  5        g)z3Concatenate matrix to current transformation matrixN)r3   r   r.   r  r   r  )r[   r=  r>  r?  r@  rA  rB  s          r?   do_cmPDFPageInterpreter.do_cm  s=     tFRRR,DEtxxPDHH%r>   rt   c                 B    [        [        U5      U R                  l        g)zSet line widthN)r   floatr  rt   )r[   rt   s     r?   do_wPDFPageInterpreter.do_w  s    &*5)&<#r>   ru   c                 $    XR                   l        g)zSet line cap styleN)r  ru   )r[   ru   s     r?   do_JPDFPageInterpreter.do_J  s    $+!r>   rv   c                 $    XR                   l        g)zSet line join styleN)r  rv   )r[   rv   s     r?   do_jPDFPageInterpreter.do_j      %-"r>   rw   c                 $    XR                   l        g)zSet miter limitN)r  rw   )r[   rw   s     r?   do_MPDFPageInterpreter.do_M  s    '1$r>   rx   phasec                 (    X4U R                   l        g)zSet line dash patternN)r  rx   )r[   rx   rT  s      r?   do_dPDFPageInterpreter.do_d  s    "&r>   ry   c                 $    XR                   l        g)zSet color rendering intentN)r  ry   )r[   ry   s     r?   do_riPDFPageInterpreter.do_ri  s    #) r>   rz   c                 $    XR                   l        g)zSet flatness toleranceN)r  rz   )r[   rz   s     r?   do_iPDFPageInterpreter.do_i  rP  r>   r  c                     g)z7Set parameters from graphics state parameter dictionaryNr7   r[   r  s     r?   do_gsPDFPageInterpreter.do_gs  s     	r>   r-  yc                 x    U R                   R                  S[        [        U5      [        [        U5      45        g)zBegin new subpathmNr  r)  r   rG  r[   r-  rb  s      r?   do_mPDFPageInterpreter.do_m  *    S$ua.$ua.ABr>   c                 x    U R                   R                  S[        [        U5      [        [        U5      45        g)z$Append straight line segment to pathlNre  rf  s      r?   do_lPDFPageInterpreter.do_l  ri  r>   x1y1x2y2x3y3c                     U R                   R                  S[        [        U5      [        [        U5      [        [        U5      [        [        U5      [        [        U5      [        [        U5      45        g)z4Append curved segment to path (three control points)r   Nre  )r[   rn  ro  rp  rq  rr  rs  s          r?   do_cPDFPageInterpreter.do_c  sY     	UBUBUBUBUBUB
	
 	r>   c           
          U R                   R                  S[        [        U5      [        [        U5      [        [        U5      [        [        U5      45        g)z8Append curved segment to path (initial point replicated)r   Nre  )r[   rp  rq  rr  rs  s        r?   do_vPDFPageInterpreter.do_v  @    $ub/4r?DOT%QS_U	
 	r>   c           
          U R                   R                  S[        [        U5      [        [        U5      [        [        U5      [        [        U5      45        g)z6Append curved segment to path (final point replicated)rb  Nre  )r[   rn  ro  rr  rs  s        r?   do_yPDFPageInterpreter.do_y  rz  r>   c                 :    U R                   R                  S5        g)zClose subpathhN)r  r)  rZ   s    r?   do_hPDFPageInterpreter.do_h$  s    F#r>   wr  c                    [        [        U5      n[        [        U5      n[        [        U5      n[        [        U5      nU R                  R                  SX45        U R                  R                  SX-   U45        U R                  R                  SX-   X$-   45        U R                  R                  SXU-   45        U R                  R                  S5        g)zAppend rectangle to pathrd  rk  r  N)r   rG  r  r)  )r[   r-  rb  r  r  s        r?   do_rePDFPageInterpreter.do_re)  s    NNNNS!K(S!%O,S!%/0S!UO,F#r>   c                 x    U R                   R                  U R                  SSSU R                  5        / U l        g)zStroke pathTFNr   
paint_pathr  r  rZ   s    r?   do_SPDFPageInterpreter.do_S6  s0    t00$udllSr>   c                 D    U R                  5         U R                  5         g)zClose and stroke pathN)r  r  rZ   s    r?   do_sPDFPageInterpreter.do_s<      				r>   c                 x    U R                   R                  U R                  SSSU R                  5        / U l        g)z+Fill path using nonzero winding number ruleFTNr  rZ   s    r?   do_fPDFPageInterpreter.do_fB  s0    t00%udllSr>   c                 "    U R                  5       $ )z6Fill path using nonzero winding number rule (obsolete))r  rZ   s    r?   do_FPDFPageInterpreter.do_FH  s    yy{r>   c                 x    U R                   R                  U R                  SSSU R                  5        / U l        g)zFill path using even-odd ruleFTNr  rZ   s    r?   do_f_aPDFPageInterpreter.do_f_aL  s0    t00%tT\\Rr>   c                 x    U R                   R                  U R                  SSSU R                  5        / U l        g)z6Fill and stroke path using nonzero winding number ruleTFNr  rZ   s    r?   do_BPDFPageInterpreter.do_BR  s0    t00$eT\\Rr>   c                 x    U R                   R                  U R                  SSSU R                  5        / U l        g)z(Fill and stroke path using even-odd ruleTNr  rZ   s    r?   do_B_aPDFPageInterpreter.do_B_aX  s0    t00$dDLLQr>   c                 D    U R                  5         U R                  5         g)z>Close, fill, and stroke path using nonzero winding number ruleN)r  r  rZ   s    r?   do_bPDFPageInterpreter.do_b^  r  r>   c                 D    U R                  5         U R                  5         g)z0Close, fill, and stroke path using even-odd ruleN)r  r  rZ   s    r?   do_b_aPDFPageInterpreter.do_b_ad  s    		r>   c                     / U l         g)z$End path without filling or strokingN)r  rZ   s    r?   do_nPDFPageInterpreter.do_nj  s    r>   c                     g)z3Set clipping path using nonzero winding number ruleNr7   rZ   s    r?   do_WPDFPageInterpreter.do_Wo      r>   c                     g)z%Set clipping path using even-odd ruleNr7   rZ   s    r?   do_W_aPDFPageInterpreter.do_W_as  r  r>   c                      U R                   [        U5         U l        g! [         a&    [        R
                  (       a  [        SU-  5      e gf = f)z?Set color space for stroking operations

Introduced in PDF 1.1
Undefined ColorSpace: %rN)r  r,   r!  KeyErrorr   r   rB   r_  s     r?   do_CSPDFPageInterpreter.do_CSw  sU    
	Mzz,t"45DH 	  	M)*Dt*KLL 	M     -AAc                      U R                   [        U5         U l        g! [         a&    [        R
                  (       a  [        SU-  5      e gf = f)z*Set color space for nonstroking operationsr  N)r  r,   r"  r  r   r   rB   r_  s     r?   do_csPDFPageInterpreter.do_cs  sU    	Mzz,t"45DH 	  	M)*Dt*KLL 	Mr  grayc                 j    [        [        U5      U R                  l        U R                  S   U l        g)z&Set gray level for stroking operations
DeviceGrayNr   rG  r  r{   r  r!  r[   r  s     r?   do_GPDFPageInterpreter.do_G  *    #'t#4 ::l+r>   c                 j    [        [        U5      U R                  l        U R                  S   U l        g)z)Set gray level for nonstroking operationsr  Nr   rG  r  r|   r  r"  r  s     r?   do_gPDFPageInterpreter.do_g  r  r>   rgbc                     [        [        U5      [        [        U5      [        [        U5      4U R                  l        U R                  S   U l        g)z%Set RGB color for stroking operations	DeviceRGBNr  r[   r  r  r  s       r?   do_RGPDFPageInterpreter.do_RG  =    $(NDNDPQN#S ::k*r>   c                     [        [        U5      [        [        U5      [        [        U5      4U R                  l        U R                  S   U l        g)z(Set RGB color for nonstroking operationsr  Nr  r  s       r?   do_rgPDFPageInterpreter.do_rg  r  r>   r   rd  r   c                     [        [        U5      [        [        U5      [        [        U5      [        [        U5      4U R                  l        U R                  S   U l        g)z&Set CMYK color for stroking operations
DeviceCMYKNr  r[   r   rd  rb  r   s        r?   do_KPDFPageInterpreter.do_K  M     NNNN	$
  ::l+r>   c                     [        [        U5      [        [        U5      [        [        U5      [        [        U5      4U R                  l        U R                  S   U l        g)z)Set CMYK color for nonstroking operationsr  Nr  r  s        r?   do_kPDFPageInterpreter.do_k  r  r>   c                     U R                   (       a  U R                   R                  nO"[        R                  (       a  [	        S5      eSn[        [        U R                  U5      5      U R                  l	        g)z"Set color for stroking operations.No colorspace specified!r   N)
r!  ncomponentsr   r   rB   r   Colorr.  r  r{   r[   r+  s     r?   do_SCNPDFPageInterpreter.do_SCN  P    88$$A)*DEEA#'txx{#; r>   c                     U R                   (       a  U R                   R                  nO"[        R                  (       a  [	        S5      eSn[        [        U R                  U5      5      U R                  l	        g)$Set color for nonstroking operationsr  r   N)
r"  r  r   r   rB   r   r  r.  r  r|   r  s     r?   do_scnPDFPageInterpreter.do_scn  r  r>   c                 $    U R                  5         g)z!Set color for stroking operationsN)r  rZ   s    r?   do_SCPDFPageInterpreter.do_SC      r>   c                 $    U R                  5         g)r  N)r  rZ   s    r?   do_scPDFPageInterpreter.do_sc  r  r>   c                     g)z%Paint area defined by shading patternNr7   r_  s     r?   do_shPDFPageInterpreter.do_sh  r  r>   c                 8    U R                   R                  5         g)zBegin text object

Initializing the text matrix, Tm, and the text line matrix, Tlm, to
the identity matrix. Text objects cannot be nested; a second BT cannot
appear before an ET.
N)r  rY   rZ   s    r?   do_BTPDFPageInterpreter.do_BT  s     	r>   c                     g)zEnd a text objectNr7   rZ   s    r?   do_ETPDFPageInterpreter.do_ET  r  r>   c                     g)zBegin compatibility sectionNr7   rZ   s    r?   do_BXPDFPageInterpreter.do_BX  r  r>   c                     g)zEnd compatibility sectionNr7   rZ   s    r?   do_EXPDFPageInterpreter.do_EX  r  r>   tagc                 V    U R                   R                  [        [        U5      5        g)zDefine marked-content pointNr   do_tagr   r'   r[   r  s     r?   do_MPPDFPageInterpreter.do_MP  s    4	3/0r>   propsc                 X    U R                   R                  [        [        U5      U5        g)z.Define marked-content point with property listNr  r[   r  r  s      r?   do_DPPDFPageInterpreter.do_DP  s     4	3/7r>   c                 V    U R                   R                  [        [        U5      5        g)zBegin marked-content sequenceNr   	begin_tagr   r'   r  s     r?   do_BMCPDFPageInterpreter.do_BMC  s    d9c23r>   c                 X    U R                   R                  [        [        U5      U5        g)z0Begin marked-content sequence with property listNr  r  s      r?   do_BDCPDFPageInterpreter.do_BDC  s     d9c2E:r>   c                 8    U R                   R                  5         g)zEnd marked-content sequenceN)r   end_tagrZ   s    r?   do_EMCPDFPageInterpreter.do_EMC  s    r>   spacec                 B    [        [        U5      U R                  l        g)zSet character spacing.

Character spacing is used by the Tj, TJ, and ' operators.

:param space: a number expressed in unscaled text space units.
N)r   rG  r  rS   r[   r  s     r?   do_TcPDFPageInterpreter.do_Tc       $(u#5 r>   c                 B    [        [        U5      U R                  l        g)zSet the word spacing.

Word spacing is used by the Tj, TJ, and ' operators.

:param space: a number expressed in unscaled text space units
N)r   rG  r  rT   r  s     r?   do_TwPDFPageInterpreter.do_Tw  r  r>   scalec                 B    [        [        U5      U R                  l        g)zeSet the horizontal scaling.

:param scale: is a number specifying the percentage of the normal width
N)r   rG  r  rU   )r[   r  s     r?   do_TzPDFPageInterpreter.do_Tz!  s    
 "&eU!3r>   rV   c                 D    [        [        U5      * U R                  l        g)zSet the text leading.

Text leading is used only by the T*, ', and " operators.

:param leading: a number expressed in unscaled text space units
N)r   rG  r  rV   )r[   rV   s     r?   do_TLPDFPageInterpreter.do_TL)  s     #'ug"6!6r>   r  rR   c                 N    U R                   [        U5         U R                  l        [        [        U5      U R                  l        g! [         aQ    [
        R                  (       a  [        SU-  5      eU R                  R                  S0 5      U R                  l         Nzf = f)zSet the text font

:param fontid: the name of a font resource in the Font subdictionary
    of the current resource dictionary
:param fontsize: size is a number representing a scale factor.
zUndefined Font id: %rN)r  r,   r  rQ   r  r   r   rB   r   r   r   rG  rR   )r[   r  rR   s      r?   do_TfPDFPageInterpreter.do_Tf3  s    	B"&,,|F/C"DDNN
 #'uh"7  	B)*AF*JKK"&,,"7"7b"ADNN	Bs   'A	 	AB$#B$rW   c                 B    [        [        U5      U R                  l        g)zSet the text rendering modeN)r   r   r  rW   )r[   rW   s     r?   do_TrPDFPageInterpreter.do_TrC  s     $S& 1r>   rX   c                 B    [        [        U5      U R                  l        g)zPSet the text rise

:param rise: a number expressed in unscaled text space units
N)r   rG  r  rX   )r[   rX   s     r?   do_TsPDFPageInterpreter.do_TsH  s    
 #5$/r>   txtyc                     [        [        U5      n[        [        U5      nU R                  R                  u  p4pVpxX4XVX-  X%-  -   U-   X-  X&-  -   U-   4U R                  l        SU R                  l        g)zMove text positionri   N)r   rG  r  rL   rM   	r[   r,  r-  ar  r   r   efs	            r?   do_TdPDFPageInterpreter.do_TdP  sm    %_%_!^^22qQ!"qRVbf_q-@"&26/TUBU V$*!r>   c                    [        [        U5      n[        [        U5      nU R                  R                  u  p4pVpxX4XVX-  X%-  -   U-   X-  X&-  -   U-   4U R                  l        X R                  l        SU R                  l        g)z"Move text position and set leadingri   N)r   rG  r  rL   rV   rM   r/  s	            r?   do_TDPDFPageInterpreter.do_TDY  sw    %_%_!^^22qQ!"qRVbf_q-@"&26/TUBU V!#$*!r>   r0  r   r1  r2  c           	      j    [        [        XX4XV45      U R                  l        SU R                  l        g)z$Set text matrix and text line matrixri   N)r   r.   r  rL   rM   r[   r0  r  r   r   r1  r2  s          r?   do_TmPDFPageInterpreter.do_Tmc  s-     !%VaA!-? @$*!r>   c                     U R                   R                  u  pp4pVUUUUU R                   R                  U-  U-   U R                   R                  U-  U-   4U R                   l        SU R                   l        g)zMove to start of next text lineri   N)r  rL   rV   rM   r9  s          r?   do_T_aPDFPageInterpreter.do_T_aq  sq    !^^22qQNN""Q&*NN""Q&*!
 %+!r>   seqc                 B   U R                   R                  c!  [        R                  (       a  [	        S5      egU R
                  c   eU R                  R                  U R                   [        [        U5      U R
                  U R                  R                  5       5        g)z0Show text, allowing individual glyph positioningNzNo font specified!)r  rQ   r   r   rB   r"  r   render_stringr   r   r  rf   )r[   r?  s     r?   do_TJPDFPageInterpreter.do_TJ  sv    >>&)*>??xx###!!NNDS1488T=N=N=S=S=U	
 	r>   sc                 (    U R                  U/5        g)z	Show textN)rB  r[   rD  s     r?   do_TjPDFPageInterpreter.do_Tj  s    

A3r>   c                 H    U R                  5         U R                  U/5        g)z@Move to next line and show text

The ' (single quote) operator.
N)r=  rB  rF  s     r?   do__qPDFPageInterpreter.do__q  s    
 	

A3r>   awacc                 l    U R                  U5        U R                  U5        U R                  U/5        g)zaSet word and character spacing, move to next line, and show text

The " (double quote) operator.
N)r  r  rB  )r[   rL  rM  rD  s       r?   do__wPDFPageInterpreter.do__w  s*    
 	

2

2

A3r>   c                     g)zBegin inline image objectNr7   rZ   s    r?   do_BIPDFPageInterpreter.do_BI  r  r>   c                     g)zBegin inline image dataNr7   rZ   s    r?   do_IDPDFPageInterpreter.do_ID  r  r>   c                    [        U[        5      (       aw  SU;   aq  SU;   ak  [        [        U5      5      nU R                  R                  US[        5        U R                  R                  X!5        U R                  R                  U5        g)zEnd inline image objectWHr   r   r   r   N)	r  r   rm   idr   begin_figurer-   render_image
end_figure)r[   re   iobjids      r?   do_EIPDFPageInterpreter.do_EI  se    c9%%#*C\FKK$$V\?KKK$$V1KK""6*r>   
xobjid_argc           	         [        [        [        U5      5      n [        U R                  U   5      n[        R                  SU5        UR                  S5      nU[        L a  SU;   a  U R                  5       n[        [        [        US   5      5      n[        [         [        UR                  S["        5      5      5      nUR                  S5      nU(       a  [%        U5      n	OU R&                  R)                  5       n	U R*                  R-                  X&U5        UR/                  X/[1        XpR2                  5      S9  U R*                  R5                  U5        gU[6        L ad  S	U;   a^  S
U;   aX  U R*                  R-                  US["        5        U R*                  R9                  X#5        U R*                  R5                  U5        g g! [
         a&    [        R                  (       a  [        SU-  5      e gf = f)zInvoke named XObjectzUndefined xobject id: %rNzProcessing xobj: %rr   BBoxr.   	Resourcesr  WidthHeightrZ  )r   rm   r,   r"   r  r  r   r   rB   r   r   r  LITERAL_FORMr   r1   r    r.   r-   r   r   rf   r   r\  render_contentsr3   r  r^  LITERAL_IMAGEr]  )
r[   rb  r  xobjr   interpreterbboxrL   xobjresr   s
             r?   do_DoPDFPageInterpreter.do_Do  s   c<
34	V 45D
 			'.((9%l"v~((*Kjf67D&*TXXh-P"QRF hh{+G&w/	 NN//1	KK$$V6:''6{688'D (  KK""6* 	 %'T/h$>NKK$$V\?KKK$$V2KK""6* 	 =  	)*Dv*MNN	s   G -G;:G;pagec                    [         R                  SU5        UR                  u  p#pEUR                  S:X  a
  SSSSU* U4nO;UR                  S:X  a  SSSSXE4nO#UR                  S:X  a	  SSSSXR* 4nO
SSSSU* U* 4nU R                  R                  X5        U R                  UR                  UR                  US9  U R                  R                  U5        g )	NzProcessing page: %rZ   r   r      i  rf  )
r   r   mediaboxrotater   
begin_pagerj  r   contentsend_page)r[   rr  x0y0rn  ro  r  s          r?   process_pagePDFPageInterpreter.process_page  s    		'.==;;"b!QR(C[[Cq!R(C[[CaQC(CaAsRC(Ct)T^^T]]DT"r>   r   c                     [         R                  SXU5        U R                  U5        U R                  U5        U R	                  [        U5      5        g)zDRender the content streams.

This method may be called recursively.
z1render_contents: resources=%r, streams=%r, ctm=%rN)r   r   r  r&  executer    )r[   r   r   r  s       r?   rj  "PDFPageInterpreter.render_contents  sH     			?UX	
 	I&Z()r>   c                     [        U5      n  UR                  5       u  p4[        U[        5      (       a  [        U5      nSUR                  SS5      R                  SS5      R                  SS5      -  n[        X5      (       a  [        X5      nUR                  R                  S-
  nU(       a<  U R                  U5      n	[        R                  S	XY5        [        U	5      U:X  a  U" U	6   OU[        R                  S
U5        U" 5         O7[        R                   (       a  SU-  n
[#        U
5      eOU R%                  U5        GM7  ! [         a     g f = f! [         a     g f = f)Nr   zdo_%s*_a"_w'_qzexec: %s %rzexec: %szUnknown operator: %r)r   r%   
nextobjectr  r&   r+   replacehasattrgetattr__code__co_argcountr.  r   r   r   r   r   rB   r   )r[   r   parserr   re   r  methodfuncnargsargsr   s              r?   r  PDFPageInterpreter.execute  sG   	%g.F !,,. #y))#C( 4<<T#:#B#B3#M#U#U$  4(("40D MM559E#xx		-<t9- $K		*d3$:T$A	1)<< ' 		#5   		  . 	1s"   E E 
EE
E"!E")r   r  r  r  r   r  r  r  r"  r   r   r!  r  r  )rN   r   rk   )fr9   r:   r;   r<   r   r   r   r\   r   r   r   r  r.   r&  	PDFStackTr   r   r   r.  r	   rJ   ro   r1  r5  r8  r;  rD  rH  rK  rN  rR  rV  rY  r\  r`  rg  rl  ru  rx  r|  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r  r
  r  r  r  r  r  r!  r$  r'  r*  r3  r6  r:  r=  rB  rG  rJ  rO  rR  rU  r`  rp  r   r~  r-   r   rj  r  r=   r7   r>   r?   r   r   U  s`   
 2 I $ 
9(VV^(< ( (Tf  $	 d S T)_ K5)N#O K6<@A	
  	
    
i D 
I $ 
Y 4 
y T 
 9  
I $ 
Y 4 
)  
i I $ 
i I $ 
  	
    
.y i Y I RV y i Y I RV 
y Y 9  t 

) 
 
)   t  t y Y 9  y Y 9  	i 	I 	) 		 	d 		i 	I 	) 		 	d 			

& T  t 
 9  
)  
) I $ 

9  9  9  Y 4 I  t  I $ 
)  	 y T 	 y T   	
    

 
t 
y T 
y T 	 y Y 4  t #	 #d #J T ( &	' &! 	
 
$!x/ !D !r>   r   )Ologgingr   ior   typingr   r   r   r   r   r	   r
   r    r   cmapdbr   r   r   pdfcolorr   r   	pdfdevicer   r   pdffontr   r   r   r   r   r   pdfpager   pdftypesr   r   r   r   r    r!   r"   psparserr#   r$   r%   r&   r'   r(   r)   r*   r+   r,   utilsr-   r.   r/   r0   r1   r2   r3   	getLoggerr9   r   r5   rB   r   r   r   ri  rk  rJ   rG  r  ro   r   r   r  r   r7   r>   r?   <module>r     sj    	  N N N     # +   !   ! $ ! !  "        "     , # ! " " " 3 3  !	| 		, 	 %j6{6{6{G4! 4!n 			%
	%u
$%'	-
 -
`G GTZ$}U9i+?%@A Z$z 	"	 6G Gr>   