+
    5i~                        R t ^ RIt^ RIHtHt ^ RIHt ^ RIHtH	t	H
t
HtHtHtHtHt ^RIHtHtHtHt ^RIHt ^RIHtHt ^RIHt ^R	IHtHt ^R
IH t  ]'       d   ^RI!H"t" ^RIH#t#H$t$ ^RI%H&t& ^RIH't'  ! R R]
4      t( ! R R]4      t) ! R R]
4      t* ! R R4      t+ ! R R4      t, ! R R4      t- ! R R]4      t. ! R R].4      t/ ! R R ]4      t0 ! R! R"]/]04      t1R# )#zJ
Usage documentation at: <https://py-pdf.github.io/fpdf2/TextRegion.html>
N)ABCabstractmethod)TracebackType)TYPE_CHECKINGAny
NamedTupleOptionalSequenceTypeUnioncast)AlignWrapModeXPosYPos)FPDFException)RasterImageInfoVectorImageInfo)preload_image)	FORM_FEEDMultiLineBreak)get_scale_factor)FPDF)FragmentTextLine)	SVGObject)	ImageDatac                   ,   a  ] tR t^$t o V 3R ltRtV tR# )Extentsc                2   < V ^8  d   Qh/ S[ ;R&   S[ ;R&   # )   leftrightfloat)format__classdict__s   "V/Users/agent/.openclaw/workspace/venv/lib/python3.14/site-packages/fpdf/text_region.py__annotate__Extents.__annotate__$   s     
K L      N)__name__
__module____qualname____firstlineno____annotate_func____static_attributes____classdictcell__r&   s   @r'   r   r   $   s      r*   r   c                   x   a a ] tR t^)t oRtV3R lV 3R lltV3R lR ltV3R lR ltV3R lR	 ltR
t	Vt
V ;t# )TextRegionMixinz>Mix-in to be added to FPDF() in order to support text regions.c                *   < V ^8  d   QhRS[ RS[ RR/# )r    argskwargsreturnN)r   )r%   r&   s   "r'   r(   TextRegionMixin.__annotate__,   s"     * *c *S *T *r*   c                V   < R V n         V P                  4        \        SV `  ! V/ VB  R # N)%_TextRegionMixin__current_text_regionclear_text_regionsuper__init__)selfr7   r8   	__class__s   &*,r'   r@   TextRegionMixin.__init__,   s)    =A" $)&)r*   c                2   < V ^8  d   QhRS[ R,          RR/# )r    regionr9   N
TextRegionParagraphCollectorMixin)r   )r%   r&   s   "r'   r(   r:   1   s'     @ @CD@	@r*   c                (    \        R V4      V n        R# )rG   N)r   r=   rA   rE   s   &&r'   register_text_region$TextRegionMixin.register_text_region1   s     &*,%?"r*   c                4   < V ^8  d   QhRS[ R,          RS[/# )r    rE   r9   rF   )r   bool)r%   r&   s   "r'   r(   r:   6   s#     4 4CD4	4r*   c                     V P                   V8H  # r<   r=   rJ   s   &&r'   is_current_text_region&TextRegionMixin.is_current_text_region6   s     ))V33r*   c                   < V ^8  d   QhRR/# r    r9   Nr+   )r%   r&   s   "r'   r(   r:   ;   s     * *4 *r*   c                    R V n         R # r<   rP   rA   s   &r'   r>   !TextRegionMixin.clear_text_region;   s
    %)"r*   )__current_text_region)r,   r-   r.   r/   __doc__r@   rK   rQ   r>   r1   r2   __classcell__rB   r&   s   @@r'   r5   r5   )   s7     H* *
@ @
4 4
* * *r*   r5   c                   8   a  ] tR t^?t o RtRtRtV 3R ltRtV t	R# )LineWrapperzConnects each TextLine with the Paragraph it was written to.
This allows to access paragraph specific attributes like
top/bottom margins when rendering the line.
Fc                F   < V ^8  d   Qh/ R;R&   R;R&   S[ ;R&   S[ ;R&   # )r    r   line	Paragraph	paragraph
first_line	last_line)rN   )r%   r&   s   "r'   r(   LineWrapper.__annotate__?   s9             r*   r+   N)
r,   r-   r.   r/   rY   rb   rc   r0   r1   r2   r3   s   @r'   r]   r]   ?   s      JI  r*   r]   c                   D   a  ] tR t^Kt o V 3R lR ltV 3R lR ltRtV tR# )Bulletc                L   < V ^8  d   QhRS[ R,          RS[R,          RS[RR/# )r    bullet_fragmentsr   	text_liner   bullet_r_marginr9   N)r	   r   r$   )r%   r&   s   "r'   r(   Bullet.__annotate__L   s=     	) 	)":.	) J'	) 		)
 
	)r*   c                8    Wn         W n        W0n        R V n        R# )FN)	fragmentsri   r_marginrendered_flag)rA   rh   ri   rj   s   &&&&r'   r@   Bullet.__init__L   s     0@"'#(r*   c                    < V ^8  d   QhRS[ /# r    r9   r#   )r%   r&   s   "r'   r(   rk   W   s      U r*   c                \    ^ pV P                    F  pWP                  4       ,          pK  	  V#     )rm   	get_width)rA   fragments_widthfrags   &  r'   get_fragments_widthBullet.get_fragments_widthW   s*    !"NND~~//O #r*   )rm   rn   ro   ri   N)r,   r-   r.   r/   r@   ry   r1   r2   r3   s   @r'   rf   rf   K   s     	) 	) r*   rf   c                      a  ] tR t^^t o RV 3R lR lltV 3R lR ltV 3R lR ltV 3R lR	 ltRV 3R
 lR lltV 3R lR lt	RV 3R lR llt
V 3R lR ltRtV tR# )r`   Nc                   < V ^8  d   QhRS[ R,          RS[S[S[,          ,          RS[S[,          RS[RS[RS[RS[S[,          RS[R	S[R
S[S[,          RS[/# )r    rE   
text_alignline_height
top_marginbottom_marginindentrj   bullet_stringskip_leading_spaceswrapmodefirst_line_indentrF   )r   r   strr   r$   rN   r   )r%   r&   s   "r'   r(   Paragraph.__annotate___   s     33 33=>33 S5[)33 e_	33
 33 33 33 "%33 33 "33 8$33 !33r*   c                N   Wn         VP                  V n        R V n        V'       dy   \        P                  ! V4      pV\        P
                  \        P                  \        P                  \        P                  39  d   \        RVP                   R24      hWn        Vf   VP                  V n        MW0n        W@n        WPn        W`n        Wn        V
f   V P                   P                   V n        M\"        P                  ! V
4      V n        . V n        Vf.   ^\'        R4      ,          V P                  P(                  ,          pV'       dK   V P+                  W4      p\-        V\.        4      '       g   Q h\1        V^ ,          V^,          V4      V n        MR V n        Wn        R # )NAText_align must be 'LEFT', 'CENTER', 'RIGHT', or 'JUSTIFY', not ''.mm)_regionpdfr}   r   coerceLCRJ
ValueErrorvaluer~   r   r   r   r   r   r   _text_fragmentsr   kgenerate_bullet_frags_and_tl
isinstancetuplerf   bulletr   )rA   rE   r}   r~   r   r   r   rj   r   r   r   r   text_align_convbullet_frags_and_tls   &&&&&&&&&&&&  r'   r@   Paragraph.__init___   sT    !::+/%*\\*%=Ouww%''&JJ WXgXmXmWnnpq  .O%11D*$*#6  LL11DM$OOH5DM13"  "24"88488::EO"&"C"C# 159999,2#A&(;A(>-DK DK!2r*   c                    < V ^8  d   QhRS[ /# rr   )r   )r%   r&   s   "r'   r(   r      s     
 
 
r*   c                    R V P                    RV P                   RV P                   RV P                   RV P                   RV P
                   R\        V P                  4       R2# )zParagraph(text_align=z, line_height=z, top_margin=z, bottom_margin=z, skip_leading_spaces=z, wrapmode=z, #text_fragments=))r}   r~   r   r   r   r   lenr   rV   s   &r'   __str__Paragraph.__str__   s|    #DOO#4N4CSCSBTTabfbqbqar s"0011GH`H`Gaalmqmzmzl{ |  #D$8$8 9:!=	
r*   c                   < V ^8  d   QhRR/# )r    r9   r`   r+   )r%   r&   s   "r'   r(   r      s      ; r*   c                    V # r<   r+   rV   s   &r'   	__enter__Paragraph.__enter__   s    r*   c                p   < V ^8  d   QhRS[ S[S[,          ,          RS[ S[,          RS[ S[,          RR/# r    exc_type	exc_value	tracebackr9   Nr   r
   BaseExceptionr   )r%   r&   s   "r'   r(   r      sG     % %4./% M*% M*	%
 
%r*   c                :    V P                   P                  4        R # r<   )r   end_paragraphrA   r   r   r   s   &&&&r'   __exit__Paragraph.__exit__   s     	""$r*   c                J   < V ^8  d   QhRS[ RS[S[ S[,          ,          RR/# r    textlinkr9   Nr   r   int)r%   r&   s   "r'   r(   r      s+     / /# /XcCi%8 /D /r*   c                H   V P                   P                  '       g   \        R 4      hV P                   P                  V4      P	                  RR4      pV P                   P                  VRR7      pV'       d   V F	  pW%n        K  	  V P                  P                  V4       R# )3No font set, you need to call set_font() beforehand FmarkdownN)	r   font_familyr   normalize_textreplace_preload_font_stylesr   r   extend)rA   r   r   normalized_stringrm   rx   s   &&&   r'   writeParagraph.write   s    xx### UVV HH33D9AA$K HH))!E *  	
 ! 	 "##I.r*   c          
      n   < V ^8  d   QhRS[ RS[RS[S[S[R,          S[R,          3,          ,          /# )r    r   rj   r9   r   r   )r   r$   r   r   r	   )r%   r&   s   "r'   r(   r      s>     2 2 2382	%,hz.BBC	D2r*   c           
        V'       g   R # V P                   P                  V4      pV P                   P                  '       g   \        R4      hV P                   P	                  VRR7      p^ pV F  pWEP                  4       ,          pK  	  \        TV P                  P
                  V P                   P                  V P                  V,
          V,
          ,           V P                   P                  3V P                  ;'       g/    V P                  P                  ;'       g    \        P                  V P                  V P                  V P                  ;'       g    V P                  P                  R7      pVP!                  4       pW73# )Nr   Fr   )	max_widthmarginsalignr   r~   r   )r   r   r   r   r   rv   r   r   c_marginr   r}   r   r   r   r~   r   get_line)rA   r   rj   rh   rw   rx   bullet_line_breakbullet_text_lines   &&&     r'   r   &Paragraph.generate_bullet_frags_and_tl   s9    //>xx### UVVHH)) *  	
 "#$D~~//O %*ll,,!!T[[?%B_%TU!! //GGT\\%<%<GG]](( $ 8 8 !0 !0||//
 -55711r*   c                4   < V ^8  d   QhRS[ S[,          RR/# r    hr9   Nr   r$   )r%   r&   s   "r'   r(   r      s     . .HUO .t .r*   c                j   V P                   P                  '       g   \        R 4      hVf(   V P                   P                  V P                  ,          pV P                   P                  RRR7      ^ ,          pWP                  ,          VP                  n        V P                  P                  V4       R# )r   N
Fr   )r   r   r   	font_sizer~   r   r   graphics_statefont_size_ptr   append)rA   r   fragments   && r'   lnParagraph.ln   s    xx### UVV9""T%5%55A88005 1 
 

 01::~,##H-r*   c                6   < V ^8  d   QhRS[ RS[S[,          /# )r    print_shr9   )rN   listr]   )r%   r&   s   "r'   r(   r      s       D T+-> r*   c                   . p\        V P                  V P                  P                  V P                  P
                  V P                  ,           V P                  P
                  3V P                  V P                  ;'       g/    V P                  P                  ;'       g    \        P                  TV P                  V P                  V P                  ;'       g    V P                  P                  R 7	      p. V n        VP                  4       pRpVe1   VP                  \!        W@VR7      4       RpVP                  4       pK4  V'       d0   VR,          p\!        VP"                  WP$                  RR7      pWbR&   V# ))r   r   r   r   r   r   r~   r   T)rb   F)rb   rc   )r   r   r   rv   r   r   r   r   r}   r   r   r   r~   r   r   r   r]   r_   rb   )rA   r   
text_linesmulti_line_breakri   rb   lasts   &&     r'   build_linesParagraph.build_lines   s-   (*
)  ll,,XX&&4dhh6G6GH"44//GGT\\%<%<GG]](( $ 8 8 !0 !0||//
  "$--/	
#k)jQRJ(113Ib>D		4OOtD "rNr*   )r   r   r   r   r   r   r~   r   r   r}   r   r   )
NNru   ru   ru   Nr   FNru   r<   )r,   r-   r.   r/   r@   r   r   r   r   r   r   r   r1   r2   r3   s   @r'   r`   r`   ^   sW     33 33j
 
 % %/ /2 2@. . r*   r`   c                   Z   a  ] tR tRt o R
V 3R lR lltV 3R lR ltV 3R lR ltR	tV tR# )ImageParagraph   Nc                   < V ^8  d   QhRS[ R,          RS[RS[S[S[,          ,          RS[S[,          RS[S[,          RS[RS[RS[R	S[R
S[S[S[,          ,          RS[S[,          RS[S[,          RR/# )r    rE   namer   widthheight
fill_widthkeep_aspect_ratior   r   r   titlealt_textr9   NrF   )r   r   r   r   r$   rN   r   )r%   r&   s   "r'   r(   ImageParagraph.__annotate__  s     $) $)=>$) $) e$	$)
 $) $) $)  $) $) $) sSy!$) }$) 3-$) 
$)r*   c                   Wn         W n        R V n        V'       dj   \        P                  ! V4      pV\        P
                  \        P                  \        P                  39  d   \        RVP                   R24      hWn        W@n
        WPn        W`n        Wpn        Wn        Wn        Wn        Wn        Wn        R V n        R V n        W n        R # )Nz1Align must be 'LEFT', 'CENTER', or 'RIGHT', not 'r   )rE   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   imginfor_   )rA   rE   r   r   r   r   r   r   r   r   r   r   r   
align_convs   &&&&&&&&&&&&& r'   r@   ImageParagraph.__init__  s     	&*
e,J%''577EGG!<< G
HXHXGYY[\  $J
$!2$*	
 (,AE	$(	r*   c                   < V ^8  d   QhRR/# )r    r9   r   r+   )r%   r&   s   "r'   r(   r   '  s      , r*   c                    \        V P                  P                  P                  V P                  4      w  V n        V n        V n        V # r<   )r   rE   r   image_cacher   r   r   rV   s   &r'   
build_lineImageParagraph.build_line'  s9     *7KKOO''*
&	48TY r*   c          
      R   < V ^8  d   QhRS[ RS[ RS[ RS[S[S[,          ,          /# )r    col_left	col_width
max_heightr9   )r$   r   r   r   )r%   r&   s   "r'   r(   r   /  s=     G GG*/G=BG	/O3	4Gr*   c                H   V P                   f   \        R4      h\        V P                   \        4      p\	        ^ 4      ;rVV P
                  '       d   V P
                  pMF\        \        V P                   R,          4      V P                  P                  P                  ,          pV P                  '       d   V P                  pMc\        \        V P                   R,          4      V P                  P                  P                  ,          pW8  g   V P                  '       d   TpMTpV P
                  '       g   VV,          X,          pWc8  d   R # Tp	V P                  '       de   V P                  \        P                  8X  d   WV,
          ,          p	M5V P                  \        P                  8X  d   WV,
          ^,          ,          p	V'       d   V P                  P                  P!                  V P"                  \        RV P$                  4      \        \        V P                   4      V	R VVV P&                  V P(                  V P*                  V P,                  R7      p
V
# \.        '       d1   \        V P$                  \0        4      '       g   V P$                  f   Q hV P                  P                  P3                  V P"                  V P$                  \        \4        V P                   4      V	R VVV P&                  V P(                  V P*                  R V P,                  R7      p
V
# )Nz;ImageParagraph.build_line() must be called before render().r   wr   )r   svgr   xyr  r   r   r   r   r   )r   r   r   r  r  r  r   r   r   r   dimsr   )r   RuntimeErrorr   r   r$   r   r   rE   r   r   r   r   r   r   r   r   _vector_imager   r   r   r   r   r   r   r   _raster_imager   )rA   r   r  r  is_svgnative_hr   r  native_wr  return_infos   &&&&       r'   renderImageParagraph.render/  sJ    99M  DII7Qx;;;AE499S>2T[[__5F5FFH:::

A"5$))C.9DKKOO<M<MMH#t{{{ 
 >:::zzUWW$]"uww&!mq((--[$((3otyy9**!]]&*&<&< .   =!$((I66488;OOOKKOO))YYHH/4995YYjj"&"8"8 *  	  r*   )r   r   r   r   r   r   r   r   r_   r   r   rE   r   r   r   
NNNFFru   ru   NNN)	r,   r-   r.   r/   r@   r   r  r1   r2   r3   s   @r'   r   r      s&     $) $)L G Gr*   r   c                   :  a a ] tR tRt oRRRRRRRR	R
R	RRRRRR	/V3R lV 3R llltV3R lR ltV3R lR ltV3R lR ltR%V3R lR lltR%V3R lR llt	R&V3R lR llt
V3R lR ltR'V3R lR llt]V3R  lR! l4       t]V3R" lR# l4       tR$tVtV ;t# )(rH   iy  r   Nr}   LEFTr~   g      ?r   Fr   r   r   img_fill_widthc                   < V ^8  d   QhRRRS[ RS[S[,          RS[S[,          RS[RS[RS[R	S[S[,          R
S[S[,          RS[RS[ RR/# )r    r   r   r7   r   r}   r~   r   r   r   r   r  r8   r9   N)r   r   r   r   r$   rN   r   )r%   r&   s   "r'   r(   $ParagraphCollectorMixin.__annotate__z  s      7  7 7  7 sm	 7
 %K 7  7  7 " 7 8$ 7 c] 7  7  7 
 7r*   c               Z  < Wn         \        P                  ! V4      V n        V P                  \        P                  \        P
                  \        P                  \        P                  39  d$   \        R V P                  P                   R24      hW@n
        WPn        Ve   \        P                  ! V4      M\        P                  V n        W`n        . V n        RV n        \$        SV `L  ! V.V
O5/ VB  V'       d   V P)                  V4       V'       d   V P+                  WR7       R# R# )r   r   N)r   )r   r   r   r}   r   r   r   r   r   r   r~   r   r   CHARr   r   _paragraphs_active_paragraphr?   r@   r   image)rA   r   r   r}   r~   r   r   r   r   r  r7   r8   rB   s   &&$$$$$$$$*,r'   r@    ParagraphCollectorMixin.__init__z  s     ,,z2??577EGGUWWegg"FFSTXTcTcTiTiSjjlm  ' )1)=HOOH%8== 	 $7 =?04.t.v.JJtJJsJ6 r*   c                   < V ^8  d   QhRR/# )r    r9   rH   r+   )r%   r&   s   "r'   r(   r    s     	 	4 	r*   c                P   V P                   P                  V 4      '       d$   \        R V P                  P                   R24      hV P                   P
                  V n        V P                   P                  4        ^ V P                   n        V P                   P                  V 4       V # )zUnable to enter the same z context recursively.)	r   rQ   r   rB   r,   page_page_push_local_stackrK   rV   s   &r'   r   !ParagraphCollectorMixin.__enter__  s    88**400+DNN,C,C+DDYZ  XX]]
""$%%d+r*   c                p   < V ^8  d   QhRS[ S[S[,          ,          RS[ S[,          RS[ S[,          RR/# r   r   )r%   r&   s   "r'   r(   r    sG     	 	4./	 M*	 M*		
 
	r*   c                    V P                   P                  4        V P                  V P                   n        V P                   P	                  4        V P                  4        R # r<   )r   r>   r!  r   _pop_local_stackr  r   s   &&&&r'   r    ParagraphCollectorMixin.__exit__  s<     	""$

!!#r*   c                   < V ^8  d   QhRR/# rT   r+   )r%   r&   s   "r'   r(   r    s     , ,$ ,r*   c                    V P                   R 8X  d   \        R4      hV P                   fG   \        V V P                  V P                  R7      pV P
                  P                  V4       RV n         R# R# )EXPLICITzaConflicts with active paragraph. Either close the current paragraph or write your text inside it.N)rE   r}   r   AUTOr  r   r`   r}   r   r  r   )rA   ps   & r'   _check_paragraph(ParagraphCollectorMixin._check_paragraph  sn    !!Z/s  !!)??$($<$<A
 ##A&%+D" *r*   c                J   < V ^8  d   QhRS[ RS[S[ S[,          ,          RR/# r   r   )r%   r&   s   "r'   r(   r    s2     - -- sSy!- 
	-r*   c                    V P                  4        \        V P                  R,          \        4      '       d%   V P                  R,          P	                  V4       R# R#    Nr   )r.  r   r  r`   r   )rA   r   r   s   &&&r'   r   ParagraphCollectorMixin.write  sF    
 	d&&r*I66R &&t, 7r*   c                4   < V ^8  d   QhRS[ S[,          RR/# r   r   )r%   r&   s   "r'   r(   r    s     ' 'HUO 't 'r*   c                    V P                  4        \        V P                  R,          \        4      '       d%   V P                  R,          P	                  V4       R# R# r2  )r.  r   r  r`   r   )rA   r   s   &&r'   r   ParagraphCollectorMixin.ln  sD    d&&r*I66R ##A& 7r*   c                   < V ^8  d   QhRS[ S[,          RS[ S[,          RS[RS[ S[,          RS[ S[,          RS[ S[,          RS[ S[,          RS[ S[,          R	S[ S[,          R
S[ S[,          RS[/# )r    r}   r~   r   r   r   r   r   rj   r   r   r9   )r   r   r$   rN   r   r   r`   )r%   r&   s   "r'   r(   r    s     . .UO. e_. "	.
 UO.  . .  }. "%. 8$. $E?. 
.r*   c                b   V P                   R8X  d   \        R4      h\        T T;'       g    V P                  TT;'       g    V P                  T	T;'       g    ^ T;'       g    ^ T;'       g    ^ T
;'       g    ^ T;'       g    RVR7      pV P
                  P                  V4       RV n         V# )a  
Args:
    text_align (Align, optional): the horizontal alignment of the paragraph.
    line_height (float, optional): factor by which the line spacing will be different from the font height. (Default: by region)
    top_margin (float, optional):  how much spacing is added above the paragraph.
        No spacing will be added at the top of the paragraph if the current y position is at (or above) the
        top margin of the page. (Default: 0.0)
    bottom_margin (float, optional): those two values determine how much spacing is added below the paragraph.
        No spacing will be added at the bottom if it would result in overstepping the bottom margin of the page. (Default: 0.0)
    indent (float, optional): determines the indentation of the paragraph. (Default: 0.0)
    bullet_string (str, optional): determines the fragments and text lines of the bullet. (Default: "")
    bullet_r_margin (float, optional): determines the spacing between the bullet and the bulleted line
    skip_leading_spaces (float, optional): removes all space characters at the beginning of each line. (Default: False)
    wrapmode (WrapMode): determines the way text wrapping is handled. (Default: None)
    first_line_indent (float, optional): left spacing before first line of text in paragraph.
r*  Unable to nest paragraphs.r   )rE   r}   r~   r   r   r   r   r   r   r   rj   r,  )rA   r}   r~   r   r   r   r   r   rj   r   r   r-  s   &&&&&&&&&&& r'   ra   !ParagraphCollectorMixin.paragraph  s    : !!Z/ <==!44T__# 3 O Ot7O7O!Q',,1;;Q/441'--2+
 	"!+r*   c                   < V ^8  d   QhRR/# rT   r+   )r%   r&   s   "r'   r(   r    s     & &t &r*   c                N    V P                   '       g   \        R 4      hRV n         R# )zNo active paragraph to end.N)r  r   rV   s   &r'   r   %ParagraphCollectorMixin.end_paragraph  s"    %%% =>>!%r*   c                   < V ^8  d   QhRS[ RS[S[ S[,          ,          RS[S[,          RS[S[,          RS[RS[RS[RS[R	S[S[ S[,          ,          R
S[S[ ,          RS[S[ ,          RR/# )r    r   r   r   r   r   r   r   r   r   r   r   r9   N)r   r   r   r$   rN   r   )r%   r&   s   "r'   r(   r    s      #  # # e$ # 	 #
  #  #   #  #  # sSy! # } # 3- # 
 #r*   c                    V P                   R 8X  d   \        R4      hV P                   '       d   V P                  4        \        V VVVVVVVVV	V
VR7      pV P                  P                  V4       R# )r*  r:  )
r   r   r   r   r   r   r   r   r   r   N)r  r   r   r   r  r   )rA   r   r   r   r   r   r   r   r   r   r   r   r-  s   &&&&&&&&&&&& r'   r  ParagraphCollectorMixin.image  sz     !!Z/ <==!!! !/!'
 	"r*   c                   < V ^8  d   QhRR/# rT   r+   )r%   r&   s   "r'   r(   r  '  s    !!!r*   c                    R # r<   r+   rV   s   &r'   r  ParagraphCollectorMixin.render&  s    !r*   c                &   < V ^8  d   QhRS[ RS[ /# r    r   r9   r#   )r%   r&   s   "r'   r(   r  *  s    444%4r*   c                    R # r<   r+   )rA   r   s   &&r'   rv   !ParagraphCollectorMixin.get_width)  s    14r*   )	r  r!  r  r~   r   r   r   r}   r   r<   )
NNFru   ru   ru   r   NNru   r  )r,   r-   r.   r/   r@   r   r   r.  r   r   ra   r   r  r   r  rv   r1   r2   rZ   r[   s   @@r'   rH   rH   y  s      7 #	 7
 #) 7 ! 7  7 %* 7 (, 7 " 7  % 7  7D	 		 	, ,- -' '
. .`& & #  #D ! !4 44r*   rH   c                      a  ] tR tRt o RtV 3R lR ltV 3R lR ltV 3R lR ltV 3R	 lR
 ltV 3R lR lt	V 3R lR lt
RtV tR# )rG   i-  z3Abstract base class for all text region subclasses.c                B   < V ^8  d   QhRS[ RS[ RS[S[ S[ 3,          /# r    r  r   r9   r$   r   )r%   r&   s   "r'   r(   TextRegion.__annotate__0  s+     $ $5 $% $E%,<O $r*   c                    \        4       h)a*  
Return the horizontal extents of the current line.
Columnar regions simply return the boundaries of the column.
Regions with non-vertical boundaries need to check how the largest
font-height in the current line actually fits in there.
For that reason we include the current y and the line height.
NotImplementedError)rA   r  r   s   &&&r'   current_x_extentsTextRegion.current_x_extents0  s     "##r*   c                F   < V ^8  d   QhRS[ RS[S[S[,          ,          /# )r    ra   r9   )r   r   r   r   )r%   r&   s   "r'   r(   rM  :  s'      '	/O3	4r*   c                   VP                   '       d]   V P                  P                  V P                  P                  8  d.   V P                  ;P                  VP                   ,          un        V P	                  V P                  P                  ^ 4      w  r#V P                  P
                  V P                  P                  ,
          pW@P                  P                  ,
          pVP                  W#V,
          V4      pV'       dZ   VP                  pV'       dF   V P                  P                  V,           V8  d$   V P                  ;P                  V,          un        V# rt   )	r   r   r  t_marginrQ  r   b_marginr  r   )rA   ra   r   	col_rightbottomr  renderedmargins   &&      r'   _render_image_paragraph"TextRegion._render_image_paragraph:  s     DHHJJ1B1B$BHHJJ)...J"44TXXZZCdhh///hhjj(
##H(.BJO,,F488::.&8

f$
r*   c                R   < V ^8  d   QhRS[ S[S[,          ,          RS[RS[RS[/# )r    r   toprX  r9   r   r   r]   r$   )r%   r&   s   "r'   r(   rM  I  sC     S% S%+56S% S% 	S%
 
S%r*   c           
     <	   V'       g   ^ # W P                   n        ^ pRp^ pV EF]  p\        V\        4      '       d&   V P	                  V4      '       d   V^,          pK<   EM#VP
                  pRp	VP                  p
V
P                  pVP                   F  pVP                  '       g   K  Rp	 M	  V	'       d   VP                  '       dw   V'       go   V
P                  '       d]   V P                   P                  V P                   P                  8  d.   V P                   ;P                  V
P                  ,          un        V P                   P                  VP                  ,           V8  d   Tp EMT;'       g    ^ pVP                  pV P                  V P                   P                  ^ 4      w  rV P                   P                  V8  g   V P                   P                  V8  d   WP                   n        V P                   ;P                  V
P                   ,          un        V'       d   VP"                  '       g   VP%                  4       VP&                  ,           pV P                   ;P                  V,          un        VP(                  f   Q hV P                   P+                  VP(                  VP(                  P                  ^ \,        P.                  \0        P2                  RR7       RVn        V P                   ;P                  V,          un        V P                   ;P                  VP                   ,          un        V P                   P+                  VVP                  ^ \,        P.                  \0        P4                  RR7       V P                   ;P                  VP                   ,          un        V P                   ;P                  V
P                   ,          un        VP6                  '       dl   V
P8                  pV'       dX   V	'       dP   V P                   P                  V,           V8  d.   V P                   ;P                  V
P8                  ,          un        V^,          pVP:                  '       g   EK^   M	  V'       d   VRV1 T;'       g    ^ # )ru   NFT)r   bordernew_xnew_yfill)r   r  r   r   r[  r_   ra   r   rm   
charactersrb   r   rU  r   rQ  r  r   ro   ry   rn   ri   _render_styled_text_liner   r  r   TOPNEXTrc   r   trailing_form_feed)rA   r   r^  rX  prev_line_heightlast_line_heightrendered_lines
tl_wrapperri   text_renderedcur_paragraph
cur_bulletrx   r   rW  bullet_indent_shiftrZ  s   &&&&             r'   _render_column_linesTextRegion._render_column_linesI  s?    
"#,0$J*n55//
;;"a'N&OO	 % * 4 4*11
%//D(, 0
 ""---&%000

TXX%6%66HHJJ-":"::J88::	 0 0069'7$#3#8#8q #,#3#3 &*&<&<TXXZZ&K#88::(DHHJJ),C!)HHJ

m222
j&>&>&>"668:;N;NN ( HHJJ"55J%//;;;HH55",,$..55 "ii"hh" 6  04J,HHJJ"55J

i...
11&&)))) 2  

i...


m222
'''*88F-TXXZZ&5HF4R

m&A&AA
!#///I %J ?N?+$$1$r*   c                @   < V ^8  d   QhRS[ S[S[,          ,          /# rr   )r   r   r]   )r%   r&   s   "r'   r(   rM    s      tN[$@A r*   c                   . pV P                    Fr  p\        V\        4      '       d$   VP                  4       pVP	                  V4       K<  VP                  V P                  4      pV'       g   Ka  VP                  V4       Kt  	  V# r<   )r  r   r   r   r   r   r   r   )rA   r   ra   r_   	cur_liness   &    r'   collect_linesTextRegion.collect_lines  sp    9;
))I)^44 ++-!!$'%11$--@	 !!), * r*   c                   < V ^8  d   QhRR/# rT   r+   )r%   r&   s   "r'   r(   rM    s     $ $ $r*   c                    \        4       hr<   rO  rV   s   &r'   r  TextRegion.render  s    !##r*   c                &   < V ^8  d   QhRS[ RS[ /# rF  r#   )r%   r&   s   "r'   r(   rM    s       % r*   c                    V P                  V P                  P                  V4      w  r#V P                  P                  V8  d2   V P                  P                  V8  d   V P                  P                  pW2,
          pV# r<   )rQ  r   r  r  )rA   r   startendress   &&   r'   rv   TextRegion.get_width  sV    ++DHHJJ?
88::$((**s"2HHJJEk
r*   r+   N)r,   r-   r.   r/   rY   rQ  r[  rr  rw  r  rv   r1   r2   r3   s   @r'   rG   rG   -  sG     =$ $ S% S%j $ $ r*   rG   c                   l   a a ] tR tRt oRtRRRR/V3R lV 3R llltV3R lR	 ltV3R
 ltRtVt	V ;t
# )TextColumnarMixini  z*Enable a TextRegion to perform page breaksl_marginNrn   c                Z   < V ^8  d   QhRRRS[ RS[S[,          RS[S[,          RS[ RR/# )	r    r   r   r7   r  rn   r8   r9   N)r   r   r$   )r%   r&   s   "r'   r(   TextColumnarMixin.__annotate__  sO     * ** * 5/	*
 5/* * 
*r*   c                  < \         SV `  ! V/ VB  Vf   VP                  MTV n        V P                  pVf   VP                  MTV n        VP                  V P                  ,
          pV P                  Wg4       R # r<   )r?   r@   r  rn   r  _set_left_right)	rA   r   r  rn   r7   r8   r!   r"   rB   s	   &&$$*,  r'   r@   TextColumnarMixin.__init__  sd     	$)&)(0(8h}}(0(8h%T)r*   c                J   < V ^8  d   QhRS[ S[,          RS[ S[,          RR/# )r    r!   r"   r9   Nr   )r%   r&   s   "r'   r(   r    s+     , ,HUO ,HUO ,PT ,r*   c                (   Vf   V P                   P                  MTpVf2   V P                   P                  V P                   P                  ,
          MTpW!8:  d)   \	        V P
                  P                   RV RV R24      h\        W4      V n        R # )Nz(): Right limit (z) lower than left limit (z).)	r   r  r  rn   r   rB   r,   r   extents)rA   r!   r"   s   &&&r'   r  !TextColumnarMixin._set_left_right  s    $(Ltxx  d49Mdhh///u=>>**+ ,  %w&?vRI  t+r*   c                $   < V ^8  d   Qh/ R;R&   # )r    r   r   r+   )r%   r&   s   "r'   r(   r    s      
K r*   )r  r  rn   )r,   r-   r.   r/   rY   r@   r  r0   r1   r2   rZ   r[   s   @@r'   r  r    s7     4* %)	*
 %)* *, ,)  r*   r  c                      a a ] tR tRt oR^R^
RR/V3R lV 3R llltV3R lV 3R	 lltV3R
 lR ltV3R lR ltV3R lR ltV3R lR lt	Rt
VtV ;t# )TextColumnsi  ncolsgutterbalanceFc                @   < V ^8  d   QhRRRS[ RS[RS[RS[RS[ RR	/# )
r    r   r   r7   r  r  r  r8   r9   N)r   r   r$   rN   )r%   r&   s   "r'   r(   TextColumns.__annotate__  sZ     B BB B 	B
 B B B 
Br*   c               Z  < \         SV `  ! V.VO5/ VB  ^ V n        W n        W@n        V P
                  P                  V P
                  P                  ,
          pWr^,
          V,          ,
          V,          pV P
                  P                  p	\        WV,           4      .V n	        \        ^V4       F=  p
WV,           ,          p	V P                  P                  \        WV,           4      4       K?  	  \        V P                  P                  V P                  P                  4      V n        R# ru   N)r?   r@   _cur_column_ncolsr  r  r"   r!   r   _colsranger   maxr   rU  r  _first_page_top)rA   r   r  r  r  r7   r8   total_wr  c_left_rB   s   &&$$$*,    r'   r@   TextColumns.__init__  s     	.t.v.,,$$t||'8'88	V33u<	""fy&89:
q%A&((FJJgfy.@AB !  #488#4#4dhhjjAr*   c                   < V ^8  d   QhRR/# )r    r9   r  r+   )r%   r&   s   "r'   r(   r    s      = r*   c                4  < \         SV `  4        \        V P                  P                  V P                  P
                  4      V n        V P                  '       d>   ^ V n        V P                  V P                  ,          P                  V P                  n        V # rt   )r?   r   r  r   rU  r  r  r  r  r  r!   r  )rA   rB   s   &r'   r   TextColumns.__enter__  se    "488#4#4dhhjjA<<< DD$4$45::DHHJr*   c                   < V ^8  d   QhRR/# rT   r+   )r%   r&   s   "r'   r(   r    s     " "D "r*   c                    V P                   '       dP   \        V P                   R,          \        4      '       d)   V P                   R,          P                  \        4       R# V P                  \        4       R# )z?End the current column and continue at the top of the next one.Nr   )r  r   r`   r   r   rV   s   &r'   
new_columnTextColumns.new_column  sJ    
4+;+;B+? K KR &&y1JJy!r*   c                P   < V ^8  d   QhRS[ S[S[,          ,          RS[RS[RR/# )r    r   r^  rX  r9   Nr_  )r%   r&   s   "r'   r(   r    s=     2 2+562 2 	2
 
2r*   c                x   RpV P                   P                  pV P                  '       d   TpV'       g   R# \        R V 4       4      pWpP                  ,          pW2,
          p	W8  d   RpW(,           p\
        P                  ! \        V4      V P                  ,          4      R,           p
V^ ,          P                  P                  ;'       g    ^ pW,          pW8  d	   W,,           pW68  d   TpRp\        V P                  V P                  4       EF  pV'       g    R# WP                  8w  d   Wn        V P                  ^ ^ 4      w  rV P                   P                  V8  g   V P                   P                  V8  d   WP                   n        V'       dI   WP                  ^,
          8X  d2   V P                   P                  V P                   P                  ,
          pV P!                  WV4       V P                   P                  V8  g   K  V P                   P                  pEK  	  WPP                   n        R# )z?Rendering a set of lines in one or several columns on one page.FNc              3   `   "   T F$  qP                   P                  ;'       g    ^ x  K&  	  R# 5ir  )r_   r   ).0ls   & r'   	<genexpr>1TextColumns._render_page_lines.<locals>.<genexpr>  s!     DAVV]]//a/s    ..Tg      ?)r   r  r  sumr  mathceilr   r_   r   r  r  rQ  r  r   rV  rr  )rA   r   r^  rX  	balancingnext_ypage_bottom
tot_height
col_heightavail_heightlines_per_columnfirst_line_heightmult_heightcr   rW  s   &&&&            r'   _render_page_linesTextColumns._render_page_lines  s    	<<< !KDDDJ#kk1J!<L( 	)#'99S_t{{-J#Kc#Q $.qM$6$6$=$=$B$B!/B+ .F'(F %It''5A$$$#$ "&"8"8A">HxxzzH$

i(?%
Q;;?3dhh&7&77%%jv>xxzzF" 6 
r*   c                   < V ^8  d   QhRR/# rT   r+   )r%   r&   s   "r'   r(   r  1  s     I I Ir*   c                0   V P                   '       g   R # V P                  4       pV'       g   R # V P                  P                  V P                  P                  ,
          p\        V P                  P                  V P                  P                  4      pV P                  WV4       V'       di   V P                  P                  V P                  P                  4      pV'       g   R # ^ V n
        V P                  WP                  P                  V4       Kp  R # r<   )r  rw  r   r   rV  r  rU  r  r  _perform_page_break_if_need_ber  )rA   r   r  first_page_top
page_breaks   &    r'   r  TextColumns.render1  s    '')
hhjj488#4#44TXX..

;
KH@@

J  D##J

KH r*   c                B   < V ^8  d   QhRS[ RS[ RS[S[ S[ 3,          /# rK  rL  )r%   r&   s   "r'   r(   r  E  s+      5 % E%,<O r*   c                F    V P                   V P                  ,          w  r4W43# r<   )r  r  )rA   r  r   r!   r"   s   &&&  r'   rQ  TextColumns.current_x_extentsE  s     jj!1!12{r*   )r  r  r  r  r  )r,   r-   r.   r/   r@   r   r  r  r  rQ  r1   r2   rZ   r[   s   @@r'   r  r    sl     B 	B
 B B B. " "2 2hI I(  r*   r  )2rY   r  abcr   r   typesr   typingr   r   r   r   r	   r
   r   r   enumsr   r   r   r   errorsr   image_datastructuresr   r   image_parsingr   
line_breakr   r   utilr   fpdfr   r   r   r  r   r   r   r5   r]   rf   r`   r   rH   rG   r  r  r+   r*   r'   <module>r     s     # 	 	 	 / . ! B ( 1 ".j 
*c *,	* 	 &_ _Dv vrq5c q5hF( FR, ,>r*/ rr*   