+
    5iy                         R t RtRtRt^ RIt^ RIt^ RIt^ RIt^ RIt^ RI	H
t
HtHt ^RIHt ^RIHt ^RIHt ^R	IHt R
 R ltR R lt ! R R4      t ! R R]4      tR# )zj
PDF template helpers for fpdf2.

Usage documentation at: <https://py-pdf.github.io/fpdf2/Templates.html>
z%Mariano Reingart <reingart@gmail.com>z#Copyright (C) 2010 Mariano ReingartzLGPL 3.0N)AnyOptionalSequence)get_stack_level)WrapMode)FPDFException)FPDFc                \    V ^8  d   QhR\         R\        \        \        \        3,          /#    colreturn)inttuplefloat)formats   "S/Users/agent/.openclaw/workspace/venv/lib/python3.14/site-packages/fpdf/template.py__annotate__r      s&     ; ;c ;eE5%/0 ;    c                 D    V R ,          V R,          R,          V R,          3# )i       )r   s   &r   _rgbr      s     5LC3J,c	::r   c                0    V ^8  d   QhR\         R\        /# r
   )r   str)r   s   "r   r   r      s     ; ;S ;S ;r   c                     \        V 4      w  rpV^ 8X  d   V^ 8X  d   V^ 8X  g   VR8X  d   V^,          R R2# V^,          R RV^,          R RV^,          R R2# )    z.3fz g z rg)r   )r   rgbs   &   r   _rgb_as_strr"      sf    3iGA!	Q16a1fbc'#b!!#gc]!AGC=!c'#c::r   c                      a  ] tR t^#t o RtRGV 3R lR lltV 3R lR lt]V 3R lR l4       t]V 3R	 lR
 l4       t	RHV 3R lR llt
RIV 3R lR lltV 3R lR lt]tV 3R lR ltV 3R lR ltV 3R lR lt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+/V 3R, lR- lltR^ R^ R^ R^ R^ R R!R'^ R.R/V 3R/ lR0 lltR^ R^ R^ R^ R^ R R!R'^ R(RR.R/	V 3R1 lR2 lltR^ R^ R^ R^ R^ R R!R'^ R(RR.R/	V 3R3 lR4 lltR^ R^ R^ R^ RR/V 3R5 lR6 lltR^ R^ R^ R^ RRRR7R^R R!R'^ /	V 3R8 lR9 lltR^ R^ R^ RRRR:R R!R'^ R;RR<RR=RR>R/V 3R? lR@ lltR^ R^ R^ R^ RRRRR^
R R!R"R#R$R#R%R#RARR'^ /V 3RB lRC lltRJV 3RD lRE lltRFtV tR# )KFlexTemplatez
A flexible templating class.

Allows to apply one or several template definitions to any page of
a document in any combination.

Usage documentation at: <https://py-pdf.github.io/fpdf2/Templates.html>
Nc                `   < V ^8  d   QhRS[ RS[S[S[S[S[3,          ,          ,          RR/# )r   pdfelementsr   N)r   r   r   dictr   r   )r   __classdict__s   "r   r   FlexTemplate.__annotate__-   s7     ( ((#+HT#s(^,D#E(	(r   c                p   \        V\        4      '       g   \        R4      hWn        RV n        V'       d   V P                  V4       RV P                  RV P                  RV P                  RV P                  RV P                  RV P                  R	V P                  R
V P                  /V n        / V n        R# )a  
Args:
    pdf (fpdf.fpdf.FPDF): All content will be added to this `FPDF` instance.
    elements (list[dict]): A template definition in a list of dicts.
        If you omit this, then you need to call either load_elements()
        or parse_csv() before doing anything else.
z('pdf' must be an instance of fpdf.FPDF()NTLIBEBCC39W)
isinstancer   	TypeErrorr&   splitting_pdfload_elements_text_line_image_rect_ellipse_barcode_code39_writehandlerstexts)selfr&   r'   s   &&&r   __init__FlexTemplate.__init__-   s     #t$$FGG-1x($--4<<	
 &(
r   c                J   < V ^8  d   QhRS[ S[S[S[3,          ,          RR/# )r   r'   r   N)r   r(   r   r   )r   r)   s   "r   r   r*   I   s,     S0 S0htCH~&> S04 S0r   c                    / R\         \        R4      3bR\         \        R4      3bR\        \        3bR\        \        3bR\        \        3bR\        \        3bR\         \        R4      3bR	\        \        3bR
\        bR\        bR\        bR\        bR\        bR\         \        R4      3bR\         \        R4      3bR\        bR\
        \        R4      3bR\        \        3R\         \        R4      3R\        \        R4      3/CpWn        . V n        V EFk  pRV9   g   ^ VR&   R) F  pWC9  g   K  VR,          R8X  dc   VR8X  d   RV9   d   VR,          VR&   K5  VR8X  d   RV9   d   VR,          VR&   KQ  VR8X  d$   RV9   d   VR,          VR,          ,           VR&   K{  \        RV R24      h	  RV9  d    VR,          R*9   d   ^ VR&   M\        R4      hR	V9   g"   VR,          R8X  d   RV9   d   VR,          VR	&   RV9   d   VR,          P                  4        F  pVR+9  g   K  \        R!V R"24      h	  RVR,          9  d   ^ VR,          R&   RVR,          9  d   VR,          R,          VR,          R&   R VR,          9  d   ^ VR,          R &   VP                  4        F  w  rEWC9   g   K  \        W4,          V4      '       d   K'  \        V\        4      '       d   VP                  M.R#P                  V Uu. uF  pR$VP                   R$2NK  	  up4      p\        R%V R&V R'\        W4,          4      P                   R(24      h	  V P                  P                  VR,          P!                  4       4       EKn  	  R# u upi ),zk
Load a template definition.

Args:
    elements (list of dicts): A template definition in a list of dicts
nameNtypex1y1x2y2fontsizebolditalic	underline
foreground
backgroundaligntextpriority	multilinerotatewrapmodedash_patternr2   xyhzMandatory key 'z' missing in input dataz(Mandatory key 'x2' missing in input datawdashgapphasezInvalid key 'z' in dash_patternz or 'zValue of element item 'z
' must be z, not ''.)rG   rH   rI   rJ   rL   r1   r2   )r_   r`   ra   )r   rH   r   r   objectboolr(   r'   keysKeyErroritemsr4   __name__joinr5   appendlower)rB   r'   
key_configektr[   ttypes   &&      r   r7   FlexTemplate.load_elementsI   s   
S$t*%
 S$t*%
 3,	

 3,
 3,
 3,
 S$t*%
 S%L
 F
 f
 
 #
 #
 c4:&
  S$t*%!
" #
$ $T
+%
& sEld4j)T4:.+

0 3;!	A? !*7:yE) 9&'fAdG$9&'fAdG$9&'g#&6AdG$"_QC7N#OPP 8" 1}V9-AdG"#MNNQ;1V9#5!8 !#AfI">*//1A 88&qc9J'KLL 2 >!2201An%f-. 11/0/@/HAn%e,!N"3312An%g."((*6*QT1"5"5 &a.. 

#[[Q)GQAajj\*;Q)GH 
 $1!JugWTRSRVZM`M`Laacd  + IIQvY__./e Z *Hs   Nc                &   < V ^8  d   QhRS[ RS[/# r   sr   )r   r   )r   r)   s   "r   r   r*      s      C C r   c                    V R,          R9   d   \        V ^4      # V ^ ,          R8X  d   \        V ^4      # \        V 4      # )z#Allow hex and oct values for colors:Nr   N0)0x0Xr   )rv   s   &r   _parse_colorcodeFlexTemplate._parse_colorcode   s<     R5L q":Q43;q!91vr   c                6   < V ^8  d   QhRS[ RS[S[,          /# ru   )r   r   rf   )r   r)   s   "r   r   r*      s      C HTN r   c                @    \        V 4      pV^ 8  d   R# V^ 8  d   R# R# )r   TFNr{   )rv   is   & r   _parse_multilineFlexTemplate._parse_multiline   s"    Fq5q5r   c                N   < V ^8  d   QhRS[ P                  S[,          RS[RR/# )r   infileencodingr   N)osPathLiker   )r   r)   s   "r   r   r*      s+     % %S!1 %S %t %r   c                   \        WR7      ;_uu_ 4       p\        P                  ! V4      pV F  pVP                  R4      pV'       d^   \	        V\
        4      '       dH   VP                  4       P                  R4      '       d   \        VR,          ^4      VR&   M\        R4      hVP                  R4      pV'       g   K  \	        V\
        4      '       g   K  VP                  4       P                  R4      '       d   \        VR,          ^4      VR&   K  \        R4      h	  V P                  V4       RRR4       R#   + '       g   i     R# ; i)	aP  
Load the template definition from a JSON file.
The data must be structured as an array of objects, with names and values exactly
equivalent to what would get supplied to load_elements(),

Args:
    infile (str, path-like object): The filepath of the JSON file.
    encoding (str): The character encoding of the file. Default is UTF-8.
r   rR   #:   NNz;If foreground is a string, it must have the form '#rrggbb'.rS   z;If background is a string, it must have the form '#rrggbb'.N)openjsonloadgetr4   r   rm   
startswithr   
ValueErrorr7   )rB   r   r   fdatadfgvalbgvals   &&&     r   
parse_jsonFlexTemplate.parse_json   s     &,,99Q<Dl+Zs33{{}//44*-eBi*<,(Y  l+5Zs33{{}//44*-eBi*<,(Y  " t$' -,,,s$   A/D?8D?D?$D??6D??E	c          
      j   < V ^8  d   QhRS[ P                  S[,          RS[RS[RS[S[,          RR/# )r   r   	delimiterdecimal_sepr   r   N)r   r   r   r   )r   r)   s   "r   r   r*      sX     IC ICC IC IC 	IC
 3-IC 
ICr   c                p  a RR V3R lllpR\         R3R\         R3RVR3RVR3RVR3R	VR3R
\         R3RVR3R\        R3R\        R3R\        R3RV P                  R3RV P                  R3R\         R3R\         R3R\        R3RV P                  R3RVR3R\         R33p. V n        Vf   \
        P                  ! 4       p\        WR7      ;_uu_ 4       p\        P                  ! WrR7       F  pVP                  R.\        V4      \        V4      ,
          ,          4       / p	\        W4       F  w  rV
P                  4       pV'       g[   V^,          '       d5   V^ ,          R8X  d   V^,          R9   d   KJ  \        RV^ ,           R24      hV^ ,          R8X  d   ^ V	R&   Ku  Kw  V^,          ! V4      W^ ,          &   K  	  V P                  P                  V	4       K  	  RRR4       V P                   U
u. uF  qR,          P!                  4       NK  	  up
V n        R#   + '       g   i     LG; iu up
i ) a  
Load the template definition from a CSV file.

Args:
    infile (str, path-like object): The filepath of the CSV file.
    delimiter (str): The character that separates the fields in the CSV file:
        Usually a comma, semicolon, or tab.
    decimal_sep (str): The decimal separator used in the file.
        Usually either a point or a comma.
    encoding (str): The character encoding of the file.
        Default is the system default encoding.
c                <    V ^8  d   QhR\         R\         R\        /# )r   rv   defaultr   )r   r   )r   s   "r   r   ,FlexTemplate.parse_csv.<locals>.__annotate__   s&     	K 	KS 	K3 	K 	Kr   c                j   < \        V P                  4       ;'       g    TP                  SR4      4      # )z-Convert to float with given decimal separator.)r   stripreplace)rv   r   r   s   &&r   _varsep_float-FlexTemplate.parse_csv.<locals>._varsep_float   s+     !'')..w77SIJJr   rG   TrH   rI   rJ   rK   rL   rM   FrN   rO   rP   rQ   rR   rS   rT   rU   rV   rW   rX   rY   Nr   )r    zMandatory value 'z' missing in csv data)rx   rd   )r   r   r|   r   r'   localegetpreferredencodingr   csvreaderextendlenzipr   r   rl   rm   rg   )rB   r   r   r   r   r   rn   r   rowkargsvalcfgvss   &&&f&        r   	parse_csvFlexTemplate.parse_csv   s)   (	K 	K S$S$=$'=$'=$'=$'S% ]E*S% sE"#u%400%8400%8c5!S% e$$//7}e,e$)

, 224H&,,zz!9

B43z?SX#=>?(* #C 4HCBq66"1v~#a&M2I $&3&7Ax?T$U'" !" !Vz101E*- 2
 ),Ar
!f! !5" $$U++ : -. 59MMBMS[&&(MB	/ -,. Cs   BH BH 7H3 H0	c                *   < V ^8  d   QhRS[ RS[RR/# )r   rG   valuer   Nr   r   )r   r)   s   "r   r   r*     s"     ) ) )C )D )r   c                    \        V\        4      '       g   Q R \        V4      P                   R24       hVP	                  4       V P
                  9  d   \        RV 24      hW P                  VP	                  4       &   R# )!name must be of type 'str', not 'rc   z%Element not loaded, cannot set item: N)r4   r   rH   rj   rm   rg   r   rA   )rB   rG   r   s   &&&r   __setitem__FlexTemplate.__setitem__  su    #
 
 	G.tDz/B/B.C2F	G 
 ::<tyy("Gv NOO#(

4::< r   c                &   < V ^8  d   QhRS[ RS[/# r   rG   r   )r   rf   )r   r)   s   "r   r   r*   &  s     ) ) ) )r   c                    \        V\        4      '       g   Q R \        V4      P                   R24       hVP	                  4       V P
                  9   # )r   rc   )r4   r   rH   rj   rm   rg   )rB   rG   s   &&r   __contains__FlexTemplate.__contains__&  sS    #
 
 	G.tDz/B/B.C2F	G 
 zz|tyy((r   c                &   < V ^8  d   QhRS[ RS[/# r   r   )r   r)   s   "r   r   r*   ,  s     
 
 
 
r   c                J  a \        V\        4      '       g   Q R \        V4      P                   R24       hWP                  9  d   \        V4      hVP                  4       oSV P                  9   d   V P                  S,          # \        V3R lV P                   4       R4      # )r   rc   c              3   p   <"   T F+  qR ,          P                  4       S8X  g   K   VR,          x  K-  	  R# 5i)rG   rU   Nrm   ).0r[   keys   & r   	<genexpr>+FlexTemplate.__getitem__.<locals>.<genexpr>8  s)     J161Bc1IYQvYYs   66N)
r4   r   rH   rj   rg   rh   rm   rA   nextr'   )rB   rG   r   s   &&@r   __getitem__FlexTemplate.__getitem__,  s    #
 
 	G.tDz/B/B.C2F	G 
 yy 4. jjl$**::c?"JJD
 	
r   c                <   < V ^8  d   QhRS[ RS[ RS[S[ ,          /# )r   rU   element_namer   )r   list)r   r)   s   "r   r   r*   ;  s&     &
 &
C &
s &
tCy &
r   c                  a \        V3R lV P                   4       4      pV P                  '       g*   \        4       V n        V P                  P	                  4        V P                  f   Q hRpVP                  R4      '       d
   VR,          pVP                  R4      '       d
   VR,          pVP                  R4      '       d
   VR,          pV P                  P                  VR	,          WCR
,          4       V P                  P                  VR,          VR,          ,
          VR,          VR,          ,
          \        V4      VP                  RR4      RRVP                  RR4      R7      # )a  
Split a string between words, for the parts to fit into a given element
width. Additional splits will be made replacing any '\n' characters.

Args:
    text (str): The input text string.
    element_name (str): The name of the template element to fit the text inside.

Returns:
    A list of substrings, each of which will fit into the element width
    when rendered in the element font style and size.
c              3      <"   T F3  pVR ,          P                  4       SP                  4       8X  g   K/  Vx  K5  	  R# 5i)rG   Nr   )r   elementr   s   & r   r   /FlexTemplate.split_multicell.<locals>.<genexpr>H  s8      
(v$$&,*<*<*>> G(s   ,>
>r   rO   r/   rP   r.   rQ   UrM   rN   rK   rI   rL   rJ   rT   TLINESrY   WORD)r^   r]   rU   rT   dry_runoutputrY   )	r   r'   r6   r   add_pager   set_font
multi_cellr   )rB   rU   r   r   styles   &&f  r   split_multicellFlexTemplate.split_multicell;  s.     
==
 

 !!!!%D'')!!---;;vSLE;;x  SLE;;{##SLE##GFOUFOL!!,,dmgdm+dmgdm+T++gr*[[V4 - 
 	
r   rI   rJ   rK   rL   rU   r   rM   	helveticarN   scale      ?rO   FrP   rQ   rT   rR   rS   rW   rY   r   c          &         < V ^8  d   QhRS[ RS[RS[RS[RS[RS[RS[RS[R	S[R
S[RS[RS[RS[RS[RS[S[,          RS[S[,          RS[RS[ RR/# )r   _rI   rJ   rK   rL   rU   rM   rN   r   rO   rP   rQ   rT   rR   rS   rW   rY   __r   N)r   r   r   rf   r   r   )r   r)   s   "r   r   r*   c  s     FU FUFU FU 	FU
 FU FU FU FU FU FU FU FU FU FU FU  SM!FU" D>#FU$ %FU& 'FU( 
)FUr   c                  V'       g   R # V P                   pVP                  \        V4      8w  d   VP                  ! \	        V4      !   Vf   RpM5RpVP
                  \        V4      8w  d   VP                  ! \	        V4      !   VP                  4       P                  4       pRpR FK  pVP                  RV R24      '       g   K   VP                  R	V R24      '       g   K=  V^R pVV,          pKM  	  V	'       d
   VR,          pV
'       d
   VR,          pV'       d
   VR,          pVP                  VVWx,          4       VP                  W4       W1,
          WB,
          ppVf   VP                  VVV^ VVR
7       R # V'       d/   VP                  VVV^ VV\        P                   ! V4      R7       R # VP                  VVVV\        P                   ! V4      RRR7      ^ ,          pVP                  VVV^ VVR
7       R # )NFTr   r/   r.   r   <></)r^   r]   rU   borderrT   fill)r^   r]   rU   r   rT   r   rY   r   )r^   r]   rU   rT   rY   r   r   r/   r.   r   )r&   
text_colorr"   set_text_colorr   
fill_colorset_fill_colorr   rm   r   endswithr   set_xycellr   r   coerce)rB   rI   rJ   rK   rL   rU   rM   rN   r   rO   rP   rQ   rT   rR   rS   rW   rY   r   r   r&   r   r   tagwidthheights   &$$$$$$$$$$$$$$$$*,      r   r8   FlexTemplate._textc  s   * hh>>[44Z 01DD~~Z!88""D$45zz|!!# C3%qz**t}}r#a[/I/IAbz ! SLESLESLET5$,/

2vHHuT!5tHTNN!2   >>!2 "  D HHuT!5tHTr   rZ   c                   < V ^8  d   QhRS[ RS[RS[RS[RS[RS[RS[RS[R	S[S[S[S[S[3,          ,          R
S[ RR/# )r   r   rI   rJ   rK   rL   rN   r   rR   rZ   r   r   Nr   r   r   r   r   )r   r)   s   "r   r   r*     s     ( (( ( 	(
 ( ( ( ( ( uUE5%89:( ( 
(r   c                  V P                   P                  f   Q hV P                   P                  P                  4       P                  4       \	        V4      8w  d$   V P                   P
                  ! \        V4      !   V P                   P                  WV,          4       Ve   V P                   P                  p\        V\        4      '       dO   V P                   P                  VP                  R^ 4      VP                  R^ 4      VP                  R^ 4      4       M2V P                   P                  V^ ,          V^,          V^,          4       V P                   P                  WW44       Ve   V P                   P                  ! R/ XB  R # R # )Nr_   r`   ra   r   )r&   
draw_color	serializerm   r"   set_draw_colorr   set_line_widthrZ   r4   r(   set_dash_patternr   line)rB   rI   rJ   rK   rL   rN   r   rR   rZ   r   r   restore_dash_patterns   &$$$$$$$$*, r   r9   FlexTemplate._line  s@    xx""...88((*002k*6MMHH##T*%56-##'88#8#8 ,--)) $$ !$$q !$$
 )) O\!_l1o 	bb%#HH%% & $r   c                   < V ^8  d   QhRS[ RS[RS[RS[RS[RS[RS[RS[R	S[S[,          R
S[S[S[S[S[3,          ,          RS[ RR/# r   r   rI   rJ   rK   rL   rN   r   rR   rS   rZ   r   r   Nr   )r   r)   s   "r   r   r*          . .. . 	.
 . . . . . SM. uUE5%89:. . 
.r   c       	        @   V P                   pVP                  f   Q hVP                  P                  4       P                  4       \	        V4      8w  d   VP
                  ! \        V4      !   Vf   RpM5RpVP                  \	        V4      8w  d   VP                  ! \        V4      !   VP                  WV,          4       V	e   V P                   P                  p\        V	\        4      '       dE   VP                  V	P                  R^ 4      V	P                  R^ 4      V	P                  R^ 4      4       M(VP                  V	^ ,          V	^,          V	^,          4       VP                  WW1,
          WB,
          VR7       V	e   V P                   P                  ! R/ XB  R # R # NDFDr_   r`   ra   )r   r   )r&   r   r   rm   r"   r   r   r   r   r   rZ   r4   r(   r   r   rectrB   rI   rJ   rK   rL   rN   r   rR   rS   rZ   r   r   r&   r   r  s   &$$$$$$$$$*,   r   r;   FlexTemplate._rect  sc    hh~~)))>>##%++-Z1HHZ 01EE~~Z!88""D$454<(##'88#8#8 ,--$$ $$ !$$q !$$
 $$\!_l1o|TUW"'7#HH%% & $r   c                   < V ^8  d   QhRS[ RS[RS[RS[RS[RS[RS[RS[R	S[S[,          R
S[S[S[S[S[3,          ,          RS[ RR/# r  r   )r   r)   s   "r   r   r*     r  r   c       	        @   V P                   pVP                  f   Q hVP                  P                  4       P                  4       \	        V4      8w  d   VP
                  ! \        V4      !   Vf   RpM5RpVP                  \	        V4      8w  d   VP                  ! \        V4      !   VP                  WV,          4       V	e   V P                   P                  p\        V	\        4      '       dE   VP                  V	P                  R^ 4      V	P                  R^ 4      V	P                  R^ 4      4       M(VP                  V	^ ,          V	^,          V	^,          4       VP                  WW1,
          WB,
          VR7       V	e   V P                   P                  ! R/ XB  R # R # r  )r&   r   r   rm   r"   r   r   r   r   r   rZ   r4   r(   r   r   ellipser  s   &$$$$$$$$$*,   r   r<   FlexTemplate._ellipse  sc    hh~~)))>>##%++-Z1HHZ 01EE~~Z!88""D$454<(##'88#8#8 ,--$$ $$ !$$q !$$
 $$\!_l1o|TUWBBGRWE:#HH%% & $r   c                H   < V ^8  d   QhRS[ RS[RS[RS[RS[RS[RS[ RR	/# )
r   r   rI   rJ   rK   rL   rU   r   r   N)r   r   r   )r   r)   s   "r   r   r*   5  se     H HH H 	H
 H H H H 
Hr   c          	     r    V'       d/   V P                   P                  WQW#V,
          WB,
          R R7       R# R# )r   )r^   r]   linkN)r&   image)rB   rI   rJ   rK   rL   rU   r   r   s   &$$$$$*,r   r:   FlexTemplate._image5  s*     HHNN4R7bgBNG r   interleaved 2of5 ntc                `   < V ^8  d   QhRS[ RS[RS[RS[RS[RS[RS[RS[R	S[R
S[RS[ RR/# )r   r   rI   rJ   rK   rL   rU   rM   rN   r   rR   r   r   N)r   r   r   r   )r   r)   s   "r   r   r*   B  s     I II I 	I
 I I I I I I I I 
Ir   c       	        l   V P                   pVP                  f   Q hVP                  P                  4       P                  4       \	        V	4      8w  d   VP
                  ! \        V	4      !   VP                  4       P                  4       pVR8X  d$   VP                  WQW'V,          WB,
          R7       R # R # )Nr  )r^   r]   )	r&   r   r   rm   r"   r   r   r   interleaved2of5)rB   rI   rJ   rK   rL   rU   rM   rN   r   rR   r   r   r&   s   &$$$$$$$$$*, r   r=   FlexTemplate._barcodeB  s     hh~~)))>>##%++-Z1HHZ 01zz|!!#(("uH )r   g      ?r[   r\   r^   r]   c                   < V ^8  d   QhRS[ RS[RS[RS[RS[RS[RS[RS[R	S[S[,          R
S[S[,          RS[S[,          RS[S[,          RS[ RR/# )r   r   rI   rJ   rL   rU   rN   r   rR   r[   r\   r^   r]   r   r   N)r   r   r   r   r   )r   r)   s   "r   r   r*   Y  s      2  2 2  2 	 2
  2  2  2  2  2 E? 2 E? 2 E? 2 E? 2  2 
 2r   c                  Vf   V	f	   V
f   Ve&   \         P                  ! R\        \        4       R7       V P                  pVP
                  f   Q hVP
                  P                  4       P                  4       \        V4      8w  d   VP                  ! \        V4      !   W2,
          pV^ 8:  d   ^pVP                  WAW%V,          V4       R # )NzVcode39 arguments x/y/w/h are deprecated since v2.4.4, please use x1/y1/y2/size instead
stacklevel)warningswarnDeprecationWarningr   r&   r   r   rm   r"   r   r   code39)rB   rI   rJ   rL   rU   rN   r   rR   r[   r\   r^   r]   r   r   r&   s   &$$$$$$$$$$$*, r   r>   FlexTemplate._code39Y  s      =AMQ]amMM8 #*, hh~~)))>>##%++-Z1HHZ 01G6A

4Rq1r   r  c                    < V ^8  d   QhRS[ RS[RS[RS[RS[RS[RS[RS[R	S[R
S[RS[RS[RS[S[S[,          ,          RS[RS[ RR/# )r   r   rI   rJ   rK   rL   rU   rM   rN   r   rO   rP   rQ   r  rR   r   r   N)r   r   r   rf   r   r   )r   r)   s   "r   r   r*   }  s     &! &!&! &! 	&!
 &! &! &! &! &! &! &! &! &! sSy!&! &!  !&!" 
#&!r   c               X   V'       g   R # V P                   pVP                  \        V4      8w  d   VP                  ! \	        V4      !   VP                  4       P                  4       pRpR FK  pVP                  RV R24      '       g   K   VP                  RV R24      '       g   K=  V^R	 pVV,          pKM  	  V	'       d
   VR,          pV
'       d
   VR,          pV'       d
   VR,          pVP                  VVWx,          4       VP                  W4       VP                  ^W\4       R # )
Nr   r/   r.   r   r   r   r   r   r   )r&   r   r"   r   r   r   rm   r   r   r   r   write)rB   rI   rJ   rK   rL   rU   rM   rN   r   rO   rP   rQ   r  rR   r   r   r&   r   r   s   &$$$$$$$$$$$$$*,   r   r?   FlexTemplate._write}  s    & hh>>[44Z 01zz|!!# C3%qz**t}}r#a[/I/IAbz ! SLESLESLET5$,/

2		!T r   c          
      6   < V ^8  d   QhRS[ RS[ RS[ RS[ RR/# )r   offsetxoffsetyrX   r   r   N)r   )r   r)   s   "r   r   r*     s=     . .. . 	.
 . 
.r   c                   \        V P                  R R7      pV P                  P                  4       ;_uu_ 4        V EF  pVP	                  4       pV P
                  P                  VR,          P                  4       VP                  RR4      4      VR&   VR8w  d   VR,          V,          VR&   VR,          V,          VR&   VR,          VR	,          VR,          ,
          V,          ,           VR	&   VR,          VR
,          VR,          ,
          V,          ,           VR
&   V'       d'   VR,          V,           VR&   VR	,          V,           VR	&   V'       d'   VR,          V,           VR&   VR
,          V,           VR
&   WGR&   VR,          P                  4       pV'       d   V P                  P                  W1V4      ;_uu_ 4        RV9   dm   VR,          '       d^   V P                  P                  VR,          VR,          VR,          4      ;_uu_ 4        V P                  V,          ! R/ VB  RRR4       MV P                  V,          ! R/ VB  RRR4       EK  RV9   do   VR,          '       d`   V P                  P                  VR,          VR,          VR,          4      ;_uu_ 4        V P                  V,          ! R/ VB  RRR4       EK  V P                  V,          ! R/ VB  EK  	  RRR4       / V n        R#   + '       g   i     L; i  + '       g   i     EK  ; i  + '       g   i     EK  ; i  + '       g   i     LV; i)a(  
Add the contents of the template to the PDF document.

Args:
    offsetx, offsety (float): Place the template to move its origin to the given coordinates.
    rotate (float): Rotate the inserted template around its (offset) origin.
    scale (float): Scale the inserted template by this factor.
c                     V R ,          # )rV   r   )r[   s   &r   <lambda>%FlexTemplate.render.<locals>.<lambda>  s    a
mr   )r   rG   rU   r   r   rI   rJ   rK   rL   r   rH   rX   Nr   )sortedr'   r&   local_contextcopyrA   r   rm   upperrotationr@   )	rB   r)  r*  rX   r   sorted_elementsr   elehandler_names	   &&&&&    r   renderFlexTemplate.render  sw    !4KLXX##%%*lln"jjnnS[->->-@#''&RTBUVFC< #D	E 1CI #D	E 1CI #D	c$i'$-.G5-P QCI #D	c$i'$-.G5-P QCI #D	G 3CI #D	G 3CI #D	G 3CI #D	G 3CI$G"6{002**6GDD#s?s8}}!%!2!23x=#d)SQUY!W!W $l ; Bc B "X!W !MM,7>#> ED  33x==!XX..s8}c$iTSS MM,7>#> TS l3:c:9 + &< 
 "X!W EDD TSS5 &%sm   C-L=)-L=A-L=L:LL /"L L=2:L=,L()L= LLL%
L=(L:3
L==M	)r'   r@   rg   r&   r6   rA   )N)zutf-8),r   N)        r:  r:  r   )rj   
__module____qualname____firstlineno____doc__rC   r7   staticmethodr|   r   r   r   r   setr   r   r   r8   r9   r;   r<   r:   r=   r>   r?   r7  __static_attributes____classdictcell__)r)   s   @r   r$   r$   #   sP    ( (8S0 S0j    % %>IC ICV) ) C) )
 
&
 &
PFU FU 	FU
 FU FU FU  FU FU FU FU FU  FU FU FU  %)!FU" %)#FU$ %FU FUP( ( 	(
 ( ( ( ( ( >B( (T. . 	.
 . . . . . %). >B. .`. . 	.
 . . . . . %). >B. .`H H 	H
 H H H HI I 	I
 I I I *I I I I I. 2  2 	 2
  2  2  2  2  2 " 2 " 2 " 2 " 2  2H&! &! 	&!
 &! &! &!  &! &! &! &! &!  &! %'&! &! &!P. . .r   r$   c                   t   a a ] tR tRt oRtR
V3R lV 3R llltV3R lR ltRV3R lV 3R llltR	tVt	V ;t
# )Templatei  z
A simple templating class.

Allows to apply a single template definition to all pages of a document.

Usage documentation at: <https://py-pdf.github.io/fpdf2/Templates.html>
c                   < V ^8  d   QhRS[ S[P                  S[,          ,          RS[ S[S[S[S[3,          ,          ,          RS[RS[RS[RS[RS[RS[R	S[R
S[RR/# )r   r   r'   r   orientationunittitleauthorsubjectcreatorkeywordsr   N)r   r   r   r   r   r(   r   )r   r)   s   "r   r   Template.__annotate__  s     65 65S)*65 8DcN3465 	65
 65 65 65 65 65 65 65 
65r   c                  < V'       d&   \         P                  ! R\        \        4       R7       R F7  p\	        \        4       V,          \        4      '       d   K*  \        RV R24      h	  \        W4VR7      pVP                  V4       VP                  V4       VP                  V	4       VP                  V4       VP                  V
4       \        SV `=  WR7       R# )	a$  
Args:
    infile (str): [**DEPRECATED since 2.2.0**] unused, will be removed in a later version
    elements (list[dict]): A template definition in a list of dicts.
        If you omit this, then you need to call either load_elements()
        or parse_csv() before doing anything else.
    format (str): The page format of the document (eg. "A4" or "letter").
    orientation (str): The orientation of the document.
        Possible values are "portrait"/"P" or "landscape"/"L"
    unit (str): The units used in the template definition.
        One of "mm", "cm", "in", "pt", or a number for points per unit.
    title (str): The title of the document.
    author (str): The author of the document.
    subject (str): The subject matter of the document.
    creator (str): The creator of the document.
zD"infile" is deprecated since v2.2.0, unused and will soon be removedr  z
Argument "z" must be of type str.)r   rF  rG  )r&   r'   N)r   rF  rG  rH  rI  rJ  rK  rL  )r  r   r!  r   r4   localsr   r5   r   	set_title
set_authorset_creatorset_subjectset_keywordssuperrC   )rB   r   r'   r   rF  rG  rH  rI  rJ  rK  rL  argr&   	__class__s   &&&&&&&&&&&  r   rC   Template.__init__  s    : MMV"*,
	
C fhsmS11*SE1G HII	
 &Eev  "S4r   c                   < V ^8  d   QhRR/# )r   r   Nr   )r   r)   s   "r   r   rM    s      $ r   c                    V P                   P                  '       d   V P                  4        V P                   P                  4        R# )z5Finish the current page, and proceed to the next one.N)r&   pager7  r   )rB   s   &r   r   Template.add_page  s(    88===KKMr   c                J   < V ^8  d   QhRS[ S[,          RS[ S[,          RR/# )r   outfiledestr   N)r   r   )r   r)   s   "r   r   rM     s+     % %hsm %(3- %SW %r   c                >  < V'       d&   \         P                  ! R\        \        4       R7       V P                  P                  RR^R7       V P                  P                  R^ R7       \        SV `!  4        V'       d   V P                  P                  V4       R# R# )	a*  
Finish the document and process all pending data.

Args:
    outfile (str): If given, the PDF file will be written to this file name.
        Alternatively, the `.pdf.output()` method can be manually called.
    dest (str): [**DEPRECATED since 2.2.0**] unused, will be removed in a later version.
zB"dest" is deprecated since v2.2.0, unused and will soon be removedr  r   r/   )r   rN   F)marginN)
r  r   r!  r   r&   r   set_auto_page_breakrU  r7  r   )rB   r^  r_  rW  s   &&&r   r7  Template.render   st     MMT"*,
 	+Sr:$$U1$5HHOOG$ r   r   )
NNA4portraitmmr   r   r   r   r   )NN)rj   r;  r<  r=  r>  rC   r   r7  rA  rB  __classcell__)rW  r)   s   @@r   rD  rD    s.     65 65p % % %r   rD  )r>  
__author____copyright____license__r   r   r   r   r  typingr   r   r   deprecationr   enumsr   errorsr   fpdfr   r   r"   r$   rD  r   r   r   <module>rp     sa    5
5 
   	  * * (  ! ;;p
 p
f]%| ]%r   