
    F jy                         S r SrSrSrSSKrSSKrSSKrSSKrSSKrSSK	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\\\\4   4S jrS\S\4S jr " S S5      r " S S\5      rg)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.0    N)AnyOptionalSequence   )get_stack_level)WrapMode)FPDFException)FPDFcolreturnc                 $    U S-  U S-  S-  U S-  4$ )Ni       )r   s    ^/root/GenerationalWealth/GenerationalWealth/venv/lib/python3.13/site-packages/fpdf/template.py_rgbr      s     5LC3J,c	::    c                     [        U 5      u  pnUS:X  a  US:X  a  US:X  d  US:X  a	  US-  S S3$ US-  S SUS-  S SUS-  S S3$ )Nr      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            '          \ rS rSrSr SOS\S\\\\	\
4         SS4S jjrS\\\	\
4      SS4S jr\S	\	S\4S
 j5       r\S	\	S\\   4S j5       rSPS\R&                  \	   S\	SS4S jjr   SQS\R&                  \	   S\	S\	S\\	   SS4
S jjrS\	S\
SS4S jr\rS\	S\4S jrS\	S\
4S jrS\	S\	S\\	   4S jrSSSSSSSSSSSSSSSS S!.S"\
S#\S$\S%\S&\S\	S'\	S(\S)\S*\S+\S,\S-\	S.\S/\\   S0\\   S1\	S2\
SS4&S3 jjrSSSSSSSSS4.S"\
S#\S$\S%\S&\S(\S)\S.\S5\\\\\4      S2\
SS4S6 jjrSSSSSSSSSS7.	S"\
S#\S$\S%\S&\S(\S)\S.\S/\\   S5\\\\\4      S2\
SS4S8 jjr SSSSSSSSSS7.	S"\
S#\S$\S%\S&\S(\S)\S.\S/\\   S5\\\\\4      S2\
SS4S9 jjr!SSSSSS:.S"\
S#\S$\S%\S&\S\	S2\
SS4S; jjr"SSSSSS<S=SSS>.	S"\
S#\S$\S%\S&\S\	S'\	S(\S)\S.\S2\
SS4S? jjr#SSSSS@SSSSSSSA.S"\
S#\S$\S&\S\	S(\S)\S.\SB\\   SC\\   SD\\   SE\\   S2\
SS4SF jjr$SSSSSSSSSSSSSSG.S"\
S#\S$\S%\S&\S\	S'\	S(\S)\S*\S+\S,\SH\\\	-     S.\S2\
SS4 SI jjr%    SRSJ\SK\SL\S)\SS4
SM jjr&SNr'g)SFlexTemplate#   z
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>
Npdfelementsr   c           	      \   [        U[        5      (       d  [        S5      eXl        SU l        U(       a  U R                  U5        U R                  U R                  U R                  U R                  U R                  U R                  U R                  U R                  S.U l        0 U l        g)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(--<<	
 &(
r   c                 H   0 S[         [        S5      4_S[         [        S5      4_S[        [        4_S[        [        4_S[        [        4_S[        [        4_S[         [        S5      4_S	[        [        4_S
[        _S[        _S[        _S[        _S[        _S[         [        S5      4_S[         [        S5      4_S[        _S[
        [        S5      4_[        [        4[         [        S5      4[        [        S5      4S.EnXl        / U l        U GH  nSU;  a  SUS'   S Hh  nXC;  d  M
  US   S:X  aH  US:X  a  SU;   a
  US   US'   M)  US:X  a  SU;   a
  US   US'   M?  US:X  a  SU;   a  US   US   -   US'   M[  [        SU S35      e   SU;  a  US   S;   a  SUS'   O[        S5      eS	U;  a  US   S:X  a  SU;   a  US   US	'   SU;   ah  US   R                  5        H  nUS ;  d  M  [        S!U S"35      e   S#US   ;  a  SUS   S#'   S$US   ;  a  US   S#   US   S$'   S%US   ;  a  SUS   S%'   UR                  5        H  u  pEXC;   d  M  [        X4   U5      (       a  M!  [        U[        5      (       a  UR                  O/S&R                  U Vs/ s H  nS'UR                   S'3PM     sn5      n[        S(U S)U S*[        X4   5      R                   S+35      e   U R                  R                  US   R!                  5       5        GM     gs  snf ),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_patternr   )r;   r<   r=   r>   r@   r'   xyhzMandatory key 'z' missing in input datar&   r'   z(Mandatory key 'x2' missing in input datawrN   )dashgapphasezInvalid key 'z' in dash_patternrT   rU   rV   z or 'zValue of element item 'z
' must be z, not ''.)strr<   intfloatobjectbooldictr   keysKeyErroritemsr)   __name__joinr*   appendlower)r7   r   
key_configektrO   ttypes           r   r,   FlexTemplate.load_elementsI   s   
S$t*%
 S$t*%
 3,	

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

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    Lsc                 l    U SS S;   a  [        U S5      $ U S   S:X  a  [        U S5      $ [        U 5      $ )z#Allow hex and oct values for colorsN   )0x0X   r   0   rZ   )rl   s    r   _parse_colorcodeFlexTemplate._parse_colorcode   s>     Ra5L q":Q43;q!91vr   c                 6    [        U 5      nUS:  a  gUS:  a  gg )Nr   TFrt   )rl   is     r   _parse_multilineFlexTemplate._parse_multiline   s"    Fq5q5r   infileencodingc                 l   [        XS9 n[        R                  " U5      nU H  nUR                  S5      nU(       aW  [	        U[
        5      (       aB  UR                  5       R                  S5      (       a  [        USS S5      US'   O[        S5      eUR                  S5      nU(       d  M  [	        U[
        5      (       d  M  UR                  5       R                  S5      (       a  [        USS S5      US'   M  [        S	5      e   U R                  U5        SSS5        g! , (       d  f       g= f)
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|   rF   #r   Nrq   z;If foreground is a string, it must have the form '#rrggbb'.rG   z;If background is a string, it must have the form '#rrggbb'.)openjsonloadgetr)   rY   re   
startswithrZ   
ValueErrorr,   )r7   r{   r|   fdatadfgvalbgvals           r   
parse_jsonFlexTemplate.parse_json   s     &,99Q<Dl+Zs33{{}//44*-eABi*<,(Y  l+5Zs33{{}//44*-eABi*<,(Y  " t$' -,,s   B!D%/D%AD%%
D3	delimiterdecimal_sepc                   ^ S$S[         S[         S[        4U4S jjjnS[         S4S[         S4SUS4S	US4S
US4SUS4S[         S4SUS4S[        S4S[        S4S[        S4SU R                  S4SU R                  S4S[         S4S[         S4S[        S4SU R                  S4SUS4S[         S44n/ U l        Uc  [        R                  " 5       n[        XS9 n[        R                  " XrS9 H  nUR                  S/[        U5      [        U5      -
  -  5        0 n	[        X5       Hn  u  pU
R                  5       nU(       dB  US   (       a&  US   S
:X  a  US    S!;   a  M:  [        S"US    S#35      eUS   S:X  a  SU	S'   M\  M^  US    " U5      XS   '   Mp     U R
                  R!                  U	5        M     SSS5        U R
                   V
s/ s H  oS   R#                  5       PM     sn
U l        g! , (       d  f       NA= fs  sn
f )%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.
rl   defaultr   c                 h   > [        U R                  5       =(       d    UR                  TS5      5      $ )z-Convert to float with given decimal separator.)r[   stripreplace)rl   r   r   s     r   _varsep_float-FlexTemplate.parse_csv.<locals>._varsep_float   s(     !'').w77SIJJr   r;   Tr<   r=   r>   r?   r@   rA   FrB   rC   rD   rE   rF   rG   rH   rI   rJ   rK   rL   rM   Nr~   )r    rn   r   r   rR   zMandatory value 'z' missing in csv data)rr   )rY   r[   rZ   ru   ry   r   localegetpreferredencodingr   csvreaderextendlenzipr   r	   rd   re   r_   )r7   r{   r   r   r|   r   rf   r   rowkargsvalcfgvss      `         r   	parse_csvFlexTemplate.parse_csv   s<   (	KS 	K3 	K 	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q6"1v~#a&M2I $&3&7Ax?T$U'" !" !Vz101E*- 2
 ),Ar
!f! !5" $$U++ : -. 59MMBMS[&&(MB	/ -,. Cs   C G5H5
Hr;   valuec                     [        U[        5      (       d   S[        U5      R                   S35       eUR	                  5       U R
                  ;  a  [        SU 35      eX R                  UR	                  5       '   g )N!name must be of type 'str', not 'rX   z%Element not loaded, cannot set item: )r)   rY   r<   rb   re   r_   r	   r6   )r7   r;   r   s      r   __setitem__FlexTemplate.__setitem__  su    #
 
 	G.tDz/B/B.C2F	G 
 ::<tyy("Gv NOO#(

4::< r   c                     [        U[        5      (       d   S[        U5      R                   S35       eUR	                  5       U R
                  ;   $ )Nr   rX   )r)   rY   r<   rb   re   r_   )r7   r;   s     r   __contains__FlexTemplate.__contains__&  sS    #
 
 	G.tDz/B/B.C2F	G 
 zz|tyy((r   c                 <  ^ [        U[        5      (       d   S[        U5      R                   S35       eXR                  ;  a  [        U5      eUR                  5       mTU R                  ;   a  U R                  T   $ [        U4S jU R                   5       S 5      $ )Nr   rX   c              3   ^   >#    U  H"  oS    R                  5       T:X  d  M  US   v   M$     g7f)r;   rI   Nre   ).0rO   keys     r   	<genexpr>+FlexTemplate.__getitem__.<locals>.<genexpr>8  s'     J161Bc1IYQvYs   --)
r)   rY   r<   rb   r_   r`   re   r6   nextr   )r7   r;   r   s     @r   __getitem__FlexTemplate.__getitem__,  s    #
 
 	G.tDz/B/B.C2F	G 
 yy 4. jjl$**::c?"JJD
 	
r   rI   element_namec                 r  ^ [        U4S jU R                   5       5      nU R                  (       d)  [        5       U l        U R                  R	                  5         U R                  c   eSnUR                  S5      (       a  US-  nUR                  S5      (       a  US-  nUR                  S5      (       a  US-  nU R                  R                  US	   XCS
   5        U R                  R                  US   US   -
  US   US   -
  [        U5      UR                  SS5      SSUR                  SS5      S9$ )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   v   >#    U  H.  nUS    R                  5       TR                  5       :X  d  M*  Uv   M0     g7f)r;   Nr   )r   elementr   s     r   r   /FlexTemplate.split_multicell.<locals>.<genexpr>H  s8      
(v$$&,*<*<*>> G(s   )9	9r   rC   r$   rD   r#   rE   UrA   rB   r?   r=   r@   r>   rH   TLINESrM   WORD)rS   rQ   rI   rH   dry_runoutputrM   )	r   r   r+   r
   add_pager   set_font
multi_cellrY   )r7   rI   r   r   styles     `  r   split_multicellFlexTemplate.split_multicell;  s+     
==
 

 !!!%D'')!!---;;vSLE;;x  SLE;;{##SLE##GFOUFOL!!,,dmgdm+dmgdm+T++gr*[[V4 - 
 	
r   r   r   	helvetica
         ?Fr   )r=   r>   r?   r@   rI   rA   rB   scalerC   rD   rE   rH   rF   rG   rK   rM   _r=   r>   r?   r@   rA   rB   r   rC   rD   rE   rH   rF   rG   rK   rM   __c                   U(       d  g U R                   nUR                  [        U5      :w  a  UR                  " [	        U5      6   Uc  SnO3SnUR
                  [        U5      :w  a  UR                  " [	        U5      6   UR                  5       R                  5       nSnS HE  nUR                  SU S35      (       d  M  UR                  SU S35      (       d  M;  USS	 nUU-  nMG     U	(       a  US
-  nU
(       a  US-  nU(       a  US-  nUR                  UUXx-  5        UR                  X5        X1-
  XB-
  nnUc  UR                  UUUSUUS9  g U(       a*  UR                  UUUSUU[        R                   " U5      S9  g UR                  UUUU[        R                   " U5      SSS9S   nUR                  UUUSUUS9  g )NFTr   r$   r#   r   <></   r$   r#   r   r   )rS   rQ   rI   borderrH   fill)rS   rQ   rI   r   rH   r   rM   r   )rS   rQ   rI   rH   rM   r   r   )r   
text_colorr   set_text_colorr   
fill_colorset_fill_colorr   re   r   endswithr   set_xycellr   r   coerce)r7   r=   r>   r?   r@   rI   rA   rB   r   rC   rD   rE   rH   rF   rG   rK   rM   r   r   r   r   r   tagwidthheights                            r   r-   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   )r=   r>   r?   r@   rB   r   rF   rN   rN   c                   U R                   R                  c   eU R                   R                  R                  5       R                  5       [	        U5      :w  a"  U R                   R
                  " [        U5      6   U R                   R                  XV-  5        Ub  U R                   R                  n[        U[        5      (       aN  U R                   R                  UR                  SS5      UR                  SS5      UR                  SS5      5        O&U R                   R                  US   US   US   5        U R                   R                  XX45        Ub  U R                   R                  " S0 WD6  g g )NrT   r   rU   rV   r   rn   r   )r   
draw_color	serializere   r   set_draw_colorr   set_line_widthrN   r)   r^   set_dash_patternr   line)r7   r=   r>   r?   r@   rB   r   rF   rN   r   r   restore_dash_patterns               r   r.   FlexTemplate._line  s@    xx""...88((*002k*6MMHH##T*%56-##'88#8#8 ,--)) $$ !$$q !$$
 )) O\!_l1o 	bb%#HH%% & $r   )	r=   r>   r?   r@   rB   r   rF   rG   rN   c       	            U R                   nUR                  c   eUR                  R                  5       R                  5       [	        U5      :w  a  UR
                  " [        U5      6   Uc  SnO3SnUR                  [	        U5      :w  a  UR                  " [        U5      6   UR                  XV-  5        U	b  U R                   R                  n[        U	[        5      (       aD  UR                  U	R                  SS5      U	R                  SS5      U	R                  SS5      5        OUR                  U	S   U	S   U	S   5        UR                  XX1-
  XB-
  US	9  U	b  U R                   R                  " S
0 WD6  g g NDFDrT   r   rU   rV   r   rn   )r   r   )r   r   r   re   r   r   r   r   r   r   rN   r)   r^   r   r   rectr7   r=   r>   r?   r@   rB   r   rF   rG   rN   r   r   r   r   r   s                  r   r0   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       	            U R                   nUR                  c   eUR                  R                  5       R                  5       [	        U5      :w  a  UR
                  " [        U5      6   Uc  SnO3SnUR                  [	        U5      :w  a  UR                  " [        U5      6   UR                  XV-  5        U	b  U R                   R                  n[        U	[        5      (       aD  UR                  U	R                  SS5      U	R                  SS5      U	R                  SS5      5        OUR                  U	S   U	S   U	S   5        UR                  XX1-
  XB-
  US	9  U	b  U R                   R                  " S
0 WD6  g g r   )r   r   r   re   r   r   r   r   r   r   rN   r)   r^   r   r   ellipser   s                  r   r1   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   )r=   r>   r?   r@   rI   c          	      V    U(       a"  U R                   R                  XQX#U-
  XB-
  SS9  g g )Nr   )rS   rQ   link)r   image)r7   r=   r>   r?   r@   rI   r   r   s           r   r/   FlexTemplate._image5  s*     HHNN4R7bgBNG r   interleaved 2of5 ntr   )	r=   r>   r?   r@   rI   rA   rB   r   rF   c       	         J   U R                   nUR                  c   eUR                  R                  5       R                  5       [	        U	5      :w  a  UR
                  " [        U	5      6   UR                  5       R                  5       nUS:X  a  UR                  XQX'U-  XB-
  S9  g g )Nr   )rS   rQ   )	r   r   r   re   r   r   r   r   interleaved2of5)r7   r=   r>   r?   r@   rI   rA   rB   r   rF   r   r   r   s                r   r2   FlexTemplate._barcodeB  s     hh~~)))>>##%++-Z1HHZ 01zz|!!#(("uH )r   g      ?)r=   r>   r@   rI   rB   r   rF   rO   rP   rS   rQ   rO   rP   rS   rQ   c                t   Uc	  U	c  U
c  Ub"  [         R                  " S[        [        5       S9  U R                  nUR
                  c   eUR
                  R                  5       R                  5       [        U5      :w  a  UR                  " [        U5      6   X2-
  nUS::  a  SnUR                  XAX%U-  U5        g )NzVcode39 arguments x/y/w/h are deprecated since v2.4.4, please use x1/y1/y2/size instead
stacklevelr      )warningswarnDeprecationWarningr   r   r   r   re   r   r   r   code39)r7   r=   r>   r@   rI   rB   r   rF   rO   rP   rS   rQ   r   r   r   s                  r   r3   FlexTemplate._code39Y  s      =AMQ]amMM8 #*, hh~~)))>>##%++-Z1HHZ 01G6A

4Rq1r   )r=   r>   r?   r@   rI   rA   rB   r   rC   rD   rE   r   rF   r   c                   U(       d  g U R                   nUR                  [        U5      :w  a  UR                  " [	        U5      6   UR                  5       R                  5       nSnS HE  nUR                  SU S35      (       d  M  UR                  SU S35      (       d  M;  USS nUU-  nMG     U	(       a  US-  nU
(       a  US	-  nU(       a  US
-  nUR                  UUXx-  5        UR                  X5        UR                  SX\5        g )Nr   r   r   r   r   r   r   r$   r#   r   r  )r   r   r   r   r   r   re   r   r   r   r   write)r7   r=   r>   r?   r@   rI   rA   rB   r   rC   rD   rE   r   rF   r   r   r   r   r   s                      r   r4   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   offsetxoffsetyrL   c           	         [        U R                  S S9nU R                  R                  5          U GH  nUR	                  5       nU R
                  R                  US   R                  5       UR                  SS5      5      US'   US:w  aD  US   U-  US'   US   U-  US'   US   US	   US   -
  U-  -   US	'   US   US
   US   -
  U-  -   US
'   U(       a  US   U-   US'   US	   U-   US	'   U(       a  US   U-   US'   US
   U-   US
'   XGS'   US   R                  5       nU(       a  U R                  R                  X1U5         SU;   aO  US   (       aE  U R                  R                  US   US   US   5         U R                  U   " S0 UD6  SSS5        OU R                  U   " S0 UD6  SSS5        GM  SU;   aQ  US   (       aG  U R                  R                  US   US   US   5         U R                  U   " S0 UD6  SSS5        GM  U R                  U   " S0 UD6  GM     SSS5        0 U l        g! , (       d  f       N= f! , (       d  f       GM*  = f! , (       d  f       GM=  = f! , (       d  f       NM= f)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                     U S   $ )NrJ   r   )rO   s    r   <lambda>%FlexTemplate.render.<locals>.<lambda>  s    a
mr   )r   r;   rI   r   r   r=   r>   r?   r@   r   r<   rL   Nr   )sortedr   r   local_contextcopyr6   r   re   upperrotationr5   )	r7   r
  r  rL   r   sorted_elementsr   elehandler_names	            r   renderFlexTemplate.render  sa    !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#s?s8}!%!2!23x=#d)SQUY!W $l ; Bc B "X!W !MM,7>#> ED  33x=!XX..s8}c$iTS MM,7>#> TS l3:c:9 + &< 
 "X!W ED TS5 &%sU   DI37I<H<	I0AI31I %I3<
I
I
I	I3 
I0*	I33
J)r   r5   r_   r   r+   r6   )N)zutf-8),r   N)        r  r  r   )(rb   
__module____qualname____firstlineno____doc__r
   r   r   r^   rY   r   r8   r,   staticmethodrZ   ru   r]   ry   osPathLiker   r   r   setr   r   listr   r[   r-   tupler.   r0   r1   r/   r2   r3   r4   r  __static_attributes__r   r   r   r   r   #   s    IM((#+HT#s(^,D#E(	(8S0htCH~&> S04 S0j C C   C HTN  %S!1 %S %t %D "&ICC IC IC 	IC
 3-IC 
ICV) )C )D ) C) ) )
 
 
&
C &
s &
tCy &
V $($(%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V =A(( ( 	(
 ( ( ( ( ( uUE5%89:( ( 
(Z $(=A.. . 	.
 . . . . . SM. uUE5%89:. . 
.f $(=A.. . 	.
 . . . . . SM. uUE5%89:. . 
.f HH H 	H
 H H H H 
H  )II I 	I
 I I I I I I I I 
I4 !!!! 2 2  2 	 2
  2  2  2  2  2 E? 2 E? 2 E? 2 E? 2  2 
 2N $&&!&! &! 	&!
 &! &! &! &! &! &! &! &! &! sSy!&! &!  !&!" 
#&!T .. . 	.
 . 
. .r   r   c                      ^  \ rS rSrSr          SS\\R                  \      S\\	\
\\4         S\S\S\S	\S
\S\S\S\SS4U 4S jjjrSS jrSS\\   S\\   SS4U 4S jjjrSrU =r$ )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>
Nr{   r   formatorientationunittitleauthorsubjectcreatorkeywordsr   c                   > U(       a"  [         R                  " S[        [        5       S9  S H2  n[	        [        5       U   [        5      (       a  M%  [        SU S35      e   [        X4US9nUR                  U5        UR                  U5        UR                  U	5        UR                  U5        UR                  U
5        [        TU ]=  XS9  g)	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   )r)  r*  r+  r,  r-  r.  r/  r0  z
Argument "z" must be of type str.)r)  r*  r+  )r   r   N)r  r  r  r   r)   localsrY   r*   r
   	set_title
set_authorset_creatorset_subjectset_keywordssuperr8   )r7   r{   r   r)  r*  r+  r,  r-  r.  r/  r0  argr   	__class__s                r   r8   Template.__init__  s    : MMV"*,
	
C fhsmS11*SE1G HII	
 &Eev  "S4r   c                     U R                   R                  (       a  U R                  5         U R                   R                  5         g)z5Finish the current page, and proceed to the next one.N)r   pager  r   )r7   s    r   r   Template.add_page  s&    88==KKMr   outfiledestc                 $  > U(       a"  [         R                  " S[        [        5       S9  U R                  R                  SSSS9  U R                  R                  SSS	9  [        TU ]!  5         U(       a  U R                  R                  U5        g
g
)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$   rq   )r   rB   Fr   )marginN)
r  r  r  r   r   r   set_auto_page_breakr8  r  r   )r7   r?  r@  r:  s      r   r  Template.render   st     MMT"*,
 	+Sr:$$U1$5HHOOG$ r   r   )
NNA4portraitmmr   r   r   r   r   )r   N)NN)rb   r  r  r  r  r   r!  r"  rY   r   r^   r   r8   r   r  r&  __classcell__)r:  s   @r   r(  r(    s     .27;%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5 65p%hsm %(3- %SW % %r   r(  )r  
__author____copyright____license__r   r   r   r!  r  typingr   r   r   deprecationr   enumsr   errorsr	   fpdfr
   rZ   r%  r[   r   rY   r   r   r(  r   r   r   <module>rQ     s    5
5 
   	  * * (  ! ;c ;eE5%/0 ;;S ;S ;p
 p
f]%| ]%r   