
    }f                       d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl	m
Z
 d dlmZ d dlmZmZ d dlmZ d dlmZ d dlmZ d dlmZ d d	lmZ d d
lmZmZmZmZmZ 	 d dlmZ d dl m!Z! n# e"$ r d\  Z!ZY nw xY w	 d dl#m$Z$ n(# e"$ r   ej%        d            G d d          Z$Y nw xY wddl&m'Z' ddl(m)Z)m*Z*m+Z+m,Z, ddl-m.Z.m/Z/ ddl0m1Z1m2Z2m3Z3 ddl4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z< ddl=m>Z> ddl?m@Z@mAZAmBZBmCZCmDZDmEZEmFZFmGZGmHZHmIZImJZJmKZKmLZLmMZMmNZNmOZOmPZPmQZQmRZRmSZSmTZT ddlUmVZVmWZWmXZX ddlYmZZZm[Z[m\Z\m]Z] ddl^m_Z_ ddl`maZa ddlbmcZcmdZdmeZemfZf ddlgmhZhmiZimjZjmkZk dd llmmZm dd!lnmoZompZpmqZq dd"lrmsZs dd#ltmuZumvZvmwZwmxZx dd$lymzZz dd%l{m|Z| dd&l}m~Z~ dd'lmZmZ dd(lmZmZmZ dd)lmZmZ dd*lmZmZ dd+lmZmZ d,Zd-d.d/d0d1d2Z	  ej        e          Z ee                                          j        Zed3z  ZdeJj        eJj        eJj        d4Z G d5 d6e\          Z G d7 d8e          Zd@d9Zd: Z G d; d<e_e          Ze3ej        e         _        d=d>iZg d?ZdS )A    N)defaultdict)contextmanager)datetimetimezonewraps)isclose)Number)splitext)Path)CallableIterator
NamedTupleOptionalUnion)signer)pkcs12NN)ImagezFPillow could not be imported - fpdf2 will not be able to add any imagec                       e Zd ZdS )r   N)__name__
__module____qualname__     B/var/www/rtfcompare/venv/lib/python3.11/site-packages/fpdf/fpdf.pyr   r   #   s        r   r      )	URIAction)AnnotationDictPDFAnnotationPDFEmbeddedFileDEFAULT_ANNOT_FLAGS)BidiParagraphauto_detect_base_direction)support_deprecated_txt_argget_stack_level WarnOnDeprecatedModuleAttributes)convert_to_device_color	DeviceRGBGraphicsStateDictRegistryGraphicsStyleDrawingContextPaintedPathPoint	Transform)StandardSecurityHandler)AccessPermissionAlignAngleAnnotationFlagAnnotationNameCharVPosCornerEncryptionMethodFileAttachmentAnnotationNameMethodReturnValue
PageLayoutPageModePathPaintRuleRenderStyleTextDirectionTextEmphasisTextMarkupTypeTextModeWrapModeXPosYPos)FPDFExceptionFPDFPageFormatExceptionFPDFUnicodeEncodingException)CoreFont
CORE_FONTSFontFaceTTFFont)GraphicsStateMixin)	HTML2FPDF)
ImageCache	ImageInfoRasterImageInfoVectorImageInfo)SUPPORTED_IMAGE_FILTERSget_img_info
load_imagepreload_image)LinearizedOutputProducer)FragmentMultiLineBreakTextLine)OutlineSection)OutputProducerPDFPageZOOM_CONFIGSstream_content_for_raster_image)FPDFRecorder)	Signature)StructureTreeBuilder)Percent	SVGObject)DestinationXYZPDFArrayPDFDate)Tabledraw_box_borders)TextRegionMixinTextColumns)get_scale_factorPaddingz2.7.9)QO@g33333@)
ףp=@rn   )gףp=
Oz@ro   )d  i  )rp   i  )a3a4a5letterlegalfont)defaultsingle
continuoustwoc                        e Zd Z	 	 	 	 	 	 	 	 ddee         dee         dee         deeef         dedee         d	ee         d
ee         f fdZ	 fdZ
 xZS )
TitleStyleNFfont_family
font_stylefont_size_ptcolor	underlinet_marginl_marginb_marginc	                     t                                          ||r|pddz   n|||           || _        || _        || _        d S )N U)super__init__r   r   r   )
selfr}   r~   r   r   r   r   r   r   	__class__s
            r   r   zTitleStyle.__init__   s\     	*3CjB#%%		
 	
 	
 !  r   c                     t                                                      d d         d| j         d| j         d| j         dz   S )Nz, t_margin=z, l_margin=z, b_margin=))r   __repr__r   r   r   )r   r   s    r   r   zTitleStyle.__repr__   sP    GGss#`DM``dm``PTP]```a	
r   )NNNNFNNN)r   r   r   r   strintr   tupleboolr   r   __classcell__r   s   @r   r|   r|      s         &*$(&*#'"&"&"&! !c]! SM	!
 sm! S%Z ! ! 3-! 3-! 3-! ! ! ! ! !,
 
 
 
 
 
 
 
 
r   r|   c                   <    e Zd ZU eed<   eed<   eed<   dZeed<   dS )ToCPlaceholderrender_function
start_pageyr   pagesN)r   r   r   r   __annotations__r   r   r   r   r   r   r      s;         OOO
FFFE3NNNNNr   r   c                 N   t          | t                    r;|                                 } | t          v rt          |          S t	          | d          |t	          | d          	 | d         |z  | d         |z  fS # t
          $ r}|  d| }t	          d|           |d}~ww xY w)	aO  Return page width and height size in points.

    Throws FPDFPageFormatException

    `format` can be either a 2-tuple or one of 'a3', 'a4', 'a5', 'letter', or
    'legal'.

    If format is a tuple, then the return value is the tuple's values
    given in the units specified on this document in the constructor,
    multiplied by the corresponding scale factor `k`, taken from instance
    variable `self.k`.

    If format is a string, the (width, height) tuple returned is in points.
    For a width and height of 8.5 * 11, 72 dpi is assumed, so the value
    returned is (8.5 * 72, 11 * 72), or (612, 792). Additional formats can be
    added by adding fields to the `PAGE_FORMATS` dictionary with a
    case insensitive key (the name of the new format) and 2-tuple value of
    (width, height) in dots per inch with a 72 dpi resolution.
    T)unknownN)oner   r   z, zArguments must be numbers: )
isinstancer   lowerPAGE_FORMATSrG   	Exception)formatkeargss       r   get_page_formatr      s    ( &# <\!!''%fd;;;;y%f$7777Say1}fQi!m++ S S SA%&JD&J&JKKQRRSs   %A; ;
B$BB$c                 <     t                      fd            }|S )z$Decorator to protect drawing methodsc                     | j         s9|                    d          s$|                    d          st          d           | g|R i |S )Ndry_run
split_only/No page open, you need to call add_page() first)pagegetrF   )r   r   kwargsfns      r   wrapperzcheck_page.<locals>.wrapper   se    y 	S&**Y"7"7 	S6::l;S;S 	S QRRRr$(((((((r   r   )r   r   s   ` r   
check_pager      s5     2YY) ) ) ) Y)
 Nr   c                       e Zd ZdZdZdZdZ ej        dej	                  Z
dZdZeZ	 	 	 	 dʈ fd	Zdej         ej                    dfdZd Zd Zed             Zed             Zej        d             Zed             Zed             Zed             Zd ZddZd Z d Z!d Z"ddZ#ed             Z$d  Z%dd"Z&	 	 	 	 	 dd#e'd$e(d%e)e*e+f         d&e*d'e*f
d(Z,ed)             Z-e-j        d*             Z-d+ Z.d, Z/d- Z0d. Z1d/ Z2d0 Z3d1 Z4d2 Z5dd3Z6d4 Z7d5 Z8d6 Z9dd8Z:	 dd:Z;	 dd;Z<d< Z=d= Z>d> Z?dd?Z@dd@ZAddAZBddBZCdC ZDdD ZEeFeGddE                        ZHdF ZIeFddeJjK        dfdG            ZLddHZMddIZNdJ ZOeGdK             ZPeGddL            ZQeGddM            ZReGddO            ZSeGddP            ZTdQ ZUeGddR            ZVdS ZWeGddT            ZXeGddU            ZYeGddV            ZZeG	 	 	 	 	 	 ddW            Z[	 	 	 	 ddXZ\ddYZ]ddZZ^d[ Z_d\ Z`d] Zadd^Zbdd`ZcddaZdeGddb            Ze	 	 	 	 ddcZfeGdNdNdegfdd            ZheGdNdNdegfde            ZieGddddegfdf            ZjeGdg             ZkeF	 ddj            ZleFdk             ZmeG	 	 	 	 ddl            ZneG	 ddm            ZoeGepddn                        ZqeGddo            ZreGeFddp                        ZseGeFddq                        ZteGeFdr                         ZueGeF	 	 	 	 	 	 	 	 dds                        Zvedt             ZweGepddd9ddexjy        dd9ddezj{        e|j}        fdu                        Z~ddezj{        e|j}        dd9ddfdvedwedxe)e*ef         dyezdze|d{e'd|e*d}e'd~efdZd Zd Zd ZddZde*de'dee         fdZd Zd Zd Zd ZeFd             ZeGepdd9dexj        ddd9ddddezj{        e|j        ej        dej        ddfdefd                        ZeGepdd9d9dej        fdwede*d|e*de'def
d                        ZeGddddNddddNdddej        dfdee*         dee*         de'dedede'de)exe*f         dededede'dede'fd            ZeG	 	 	 	 	 	 	 	 	 	 dd            Z	 	 	 	 	 	 	 	 	 ddefdZ	 	 	 	 	 	 	 	 ddedefdZd ZddZeFd             Zd ZeGdd            Zd Zd Zd Zd Zd Zd Zddddddej        ej        ffdZeGddddddej        ej        ffd            Zd Zd Zd Zd ZddZd ZeGepdd                        ZeGepdd                        ZeGeFd                         ZeGeFd                         ZeGeFd                         ZeFd             ZeFd             ZeGdd            Z	 	 	 	 	 	 ddZeGddÄ            ZeFdefdń            ZeFdefdǄ            ZeGeFdȄ                         Zd9d9defdɄZƈ xZS )FPDFzPDF Generation classz**__z--z^\[([^][]+)\]\(([^()]+)\)(.*)$NTportraitmmA4
DEPRECATEDc                 v   |dk    r(t          j        dt          t                                 t	                                                       d| _        i | _        i | _        i | _	        g | _
        t                      | _        d| _        d| _        d| _        |                                  d| _        d| _        d| _        d| _        d| _        d| _        d| _        t1                      | _        d| _        g | _        d| _        i | _        d	| _        	 d
ddd| _        tA          |          | _!        d| _"        d| _#        d| _$        d| _%        d| _&        d| _'        d| _(        | j)        | _*        | j+        | _,        | j-        | _.        d| _/        ta          ddd          | _1        d| j!        z  | _2        tf          j4        | _5        tm          || j!                  \  | _7        | _8        | 9                    || j7        | j8                   | j:        | _;        d| j!        z  }d\  | _<        | _=        | _>        | _?        | @                    ||           | j>        | j?        c| _<        | _=        |dz  | _A        | B                    dd|z             | C                    d           d| _D        d| _E        d| _F        d| _G        t          jI        t          jK                  | _L        d| _M        g | _N        d| _O        d| _P        t                      | _R        d| _S        t          t                    | _V        d| _W        dS )ak  
        Args:
            orientation (str): possible values are "portrait" (can be abbreviated "P")
                or "landscape" (can be abbreviated "L"). Default to "portrait".
            unit (str, int, float): possible values are "pt", "mm", "cm", "in", or a number.
                A point equals 1/72 of an inch, that is to say about 0.35 mm (an inch being 2.54 cm).
                This is a very common unit in typography; font sizes are expressed in this unit.
                If given a number, then it will be treated as the number of points per unit.  (eg. 72 = 1 in)
                Default to "mm".
            format (str): possible values are "a3", "a4", "a5", "letter", "legal" or a tuple
                (width, height) expressed in the given unit. Default to "a4".
            font_cache_dir (Path or str): [**DEPRECATED since v2.5.1**] unused
        r   zV"font_cache_dir" parameter is deprecated since v2.5.1, unused and will soon be removed
stacklevelr   FNT   latin-1	helveticacouriertimes)arial
couriernewtimesnewromanr      d   dashgapphaseg/$?gbX<@)r   r   r   r   g      $@	fullwidthz1.3)XwarningswarnDeprecationWarningr&   r   r   r   r   fontslinksembedded_filesrO   image_cache	in_footer_in_unbreakable_lasthalias_nb_pages_anglexmp_metadatapage_durationpage_transitionallow_images_transparencyoversized_imagesoversized_images_ratiorb   struct_builder_toc_placeholder_outline	_sign_keysection_title_stylescore_fonts_encodingfont_aliasesrl   r   r}   r~   r   font_stretchingchar_spacingr   current_fontDEFAULT_DRAW_COLOR
draw_colorDEFAULT_FILL_COLOR
fill_colorDEFAULT_TEXT_COLOR
text_colorpage_backgrounddictdash_pattern
line_widthrB   FILL	text_moder   dw_ptdh_pt_set_orientationcur_orientationdef_orientationxr   r   r   set_marginsc_marginset_auto_page_breakset_display_mode
_page_modeviewer_preferencescompresspdf_versionr   nowr   utccreation_date_security_handler_fallback_font_ids_fallback_font_exact_match_current_draw_contextr*    _drawing_graphics_state_registry_record_text_quad_pointsr   list_text_quad_pointsbuffer)r   orientationunitr   font_cache_dirmarginr   s         r   r   zFPDF.__init__   s%   ( \))M6 #*,,    		


 %<<$ #)-& $&'#244 $$&!#, + !#$
 
 "$'' " 	 111# aQa888$&.! "1!@!@
DJk4:tzBBB#3 &7A4t}(((  q6z222k***"& %\(,77!%"$*/'%)"0I0K0K-(-% "-T!2!2 r   Fc                 :    t          | |||||          | _        dS )a   "
        Activate encryption of the document content.

        Args:
            owner_password (str): mandatory. The owner password allows to perform any change on the document,
                including removing all encryption and access permissions.
            user_password (str): optional. If a user password is set, the content of the document will be encrypted
                and a password prompt displayed when a user opens the document.
                The document will only be displayed after either the user or owner password is entered.
            encryption_method (fpdf.enums.EncryptionMethod, str): algorithm to be used to encrypt the document.
                Defaults to RC4.
            permissions (fpdf.enums.AccessPermission): specify access permissions granted
                when the document is opened with user access. Defaults to ALL.
            encrypt_metadata (bool): whether to also encrypt document metadata (author, creation date, etc.).
                Defaults to False.
        )owner_passworduser_password
permissionencryption_methodencrypt_metadataN)r0   r  )r   r  r  r  permissionsr  s         r   set_encryptionzFPDF.set_encryptionk  s3    0 "9)'"/-"
 "
 "
r   c                     t          |           }|                    |            | j        | g|R i |}|                    |           dS )a  
        Parse HTML and convert it to PDF.
        cf. https://py-pdf.github.io/fpdf2/HTML.html

        Args:
            text (str): HTML content to render
            image_map (function): an optional one-argument function that map <img> "src"
                to new image URLs
            li_tag_indent (int): [**DEPRECATED since v2.7.8**] numeric indentation of <li> elements - Set tag_indents instead
            dd_tag_indent (int): [**DEPRECATED since v2.7.8**] numeric indentation of <dd> elements - Set tag_indents instead
            table_line_separators (bool): enable horizontal line separators in <table>
            ul_bullet_char (str): bullet character preceding <li> items in <ul> lists.
            li_prefix_color (tuple | str | drawing.Device* instance): color for bullets or numbers preceding <li> tags.
                This applies to both <ul> & <ol> lists.
            heading_sizes (dict): [**DEPRECATED since v2.7.8**] font size per heading level names ("h1", "h2"...) - Set tag_styles instead
            pre_code_font (str): [**DEPRECATED since v2.7.8**] font to use for <pre> & <code> blocks - Set tag_styles instead
            warn_on_tags_not_matching (bool): control warnings production for unmatched HTML tags
            tag_indents (dict): mapping of HTML tag names to numeric values representing their horizontal left identation
            tag_styles (dict): mapping of HTML tag names to colors
        N)varsupdateHTML2FPDF_CLASSfeed)r   textr   r   kwargs2html2pdfs         r   
write_htmlzFPDF.write_html  s[    * t**v'4'?t???w??dr   c                 :    t          | j        |          | _        d S N)maxr  )r   versions     r   _set_min_pdf_versionzFPDF._set_min_pdf_version  s    t/99r   c                 0    | j         o| j         j        dk    S )NTTF)r   typer   s    r   is_ttf_fontzFPDF.is_ttf_font  s     DT%6%;u%DDr   c                     | j         S r%  )r   r,  s    r   	page_modezFPDF.page_mode  s
    r   c                     t          j        |          | _        | j        t           j        k    r|                     d           d S | j        t           j        k    r|                     d           d S d S )N1.61.5)r<   coercer   USE_ATTACHMENTSr(  USE_OC)r   r/  s     r   r/  zFPDF.page_mode  sn    "/)44?h666%%e,,,,,_//%%e,,,,, 0/r   c                 0    | j         | j        z
  | j        z
  S )zT
        Effective page width: the page width minus its horizontal margins.
        )wr   r_marginr,  s    r   epwzFPDF.epw      
 v%55r   c                 0    | j         | j        z
  | j        z
  S )zT
        Effective page height: the page height minus its vertical margins.
        )hr   r   r,  s    r   ephzFPDF.eph  r:  r   c                 *    t          | j                  S )z:
        Returns the total pages of the document.
        )lenr   r,  s    r   pages_countzFPDF.pages_count  s    
 4:r   c                 h    |                      ||           |                     | j        |           dS )z
        Sets the document right, left, top & bottom margins to the same value.

        Args:
            margin (float): margin in the unit specified to FPDF constructor
        N)r   r   auto_page_breakr   r  s     r   
set_marginzFPDF.set_margin  s9     	(((  !5v>>>>>r   r   c                     |                      |           | j        |k     s| j        | j        k    r|| _        || _        |dk    r|}|| _        dS )a  
        Sets the document left, top & optionaly right margins to the same value.
        By default, they equal 1 cm.
        Also sets the current FPDF.y on the page to this minimum vertical position.

        Args:
            left (float): left margin in the unit specified to FPDF constructor
            top (float): top margin in the unit specified to FPDF constructor
            right (float): optional right margin in the unit specified to FPDF constructor
        r   N)set_left_marginr   r   r8  )r   lefttoprights       r   r   zFPDF.set_margins  sX     	T"""6C<<46T]22DFB;;Er   c                 X    | j         |k     s| j         | j        k    r|| _         || _        dS )z
        Sets the document left margin.
        Also sets the current FPDF.x on the page to this minimum horizontal position.

        Args:
            margin (float): margin in the unit specified to FPDF constructor
        N)r   r   rC  s     r   rF  zFPDF.set_left_margin  s/     6F??df55DFr   c                     || _         dS )z
        Sets the document top margin.

        Args:
            margin (float): margin in the unit specified to FPDF constructor
        N)r   rC  s     r   set_top_marginzFPDF.set_top_margin       r   c                     || _         dS )z
        Sets the document right margin.

        Args:
            margin (float): margin in the unit specified to FPDF constructor
        N)r8  rC  s     r   set_right_marginzFPDF.set_right_margin  rM  r   r   c                 J    || _         || _        | j        | j        z
  | _        dS )ab  
        Set auto page break mode and triggering bottom margin.
        By default, the mode is on and the bottom margin is 2 cm.

        Args:
            auto (bool): enable or disable this mode
            margin (float): optional bottom margin (distance from the bottom of the page)
                in the unit specified to FPDF constructor
        N)rB  r   r<  page_break_trigger)r   autor  s      r   r   zFPDF.set_auto_page_break
  s*      $"&&4="8r   c                 P    | j         dk    r| j        | j        fn| j        | j        fS )zGReturn a pair (width, height) in the unit specified to FPDF constructorP)r   r   r   r,  s    r   default_page_dimensionszFPDF.default_page_dimensions  s4    
 #s** Z$$*dj)	
r   c                 
   |                                 }|dv rd| _        || _        || _        n,|dv rd| _        || _        || _        nt	          d|           | j        | j        z  | _        | j        | j        z  | _        d S )N)pr   rT  )l	landscapeLzIncorrect orientation: )r   r   w_pth_ptrF   r   r7  r<  )r   r  page_width_ptpage_height_pts       r   r   zFPDF._set_orientation!  s    !''))+++#&D %DI&DII...#&D &DI%DII G+ G GHHHTV#TV#r   ry   c                     |t           v st          |t                    s|| _        n|dk    rt	          d|           t
                              ||          | _        dS )a  
        Defines the way the document is to be displayed by the viewer.

        It allows to set the zoom level: pages can be displayed entirely on screen,
        occupy the full width of the window, use the real size,
        be scaled by a specific zooming factor or use the viewer default (configured in its Preferences menu).

        The page layout can also be specified: single page at a time, continuous display, two columns or viewer default.

        Args:
            zoom: either "fullpage", "fullwidth", "real", "default",
                or a number indicating the zooming factor to use, interpreted as a percentage.
                The zoom level set by default is "default".
            layout (fpdf.enums.PageLayout, str): allowed layout aliases are "single", "continuous", "two" or "default",
                meaning to use the viewer default mode.
                The layout set by default is "continuous".
        rw   zIncorrect zoom display mode: N)r^   r   r   	zoom_moderF   LAYOUT_ALIASESr   page_layout)r   zoomlayouts      r   r   zFPDF.set_display_mode0  sg    $ <z$'<'<!DNNY F F FGGG)--ff==r   use_shaping_enginefeatures	directionscriptlanguagec                    |r(	 ddl }n+# t          $ r}t          d          |d}~ww xY wd| _        dS |r$t	          |t
                    st          d          |si }d}|rTt	          |t                    r|nt          j        |          }|t          j        t          j	        fvrt          d          d||||ddd| _        dS )a<  
        Enable or disable text shaping engine when rendering text.
        If features, direction, script or language are not specified the shaping engine will try
        to guess the values based on the input text.

        Args:
            use_shaping_engine: enable or disable the use of the shaping engine to process the text
            features: a dictionary containing 4 digit OpenType features and whether each feature
                should be enabled or disabled
                example: features={"kern": False, "liga": False}
            direction: the direction the text should be rendered, either "ltr" (left to right)
                or "rtl" (right to left).
            script: a valid OpenType script tag like "arab" or "latn"
            language: a valid OpenType language tag like "eng" or "fra"
        r   NziThe uharfbuzz package could not be imported, but is required for text shaping. Try: pip install uharfbuzzz=Features must be a dictionary. See text shaping documentationzPFPDF2 only accept ltr (left to right) or rtl (right to left) directions for now.T)re  rf  rg  rh  ri  fragment_directionparagraph_direction)
	uharfbuzzImportErrorrF   text_shapingr   r   r?   r3  LTRRTL)	r   re  rf  rg  rh  ri  rm  exctext_directions	            r   set_text_shapingzFPDF.set_text_shapingJ  s8   .  		        # 
 !%DF  	Jx66 	O    	H  		 i775		"))44 
 m&79J%KKK#f  
 #' ' "&#'
 
s   	 
(#(c                     | j         S r%  )_page_layoutr,  s    r   rb  zFPDF.page_layout  s      r   c                     |rt          j        |          nd | _        | j        t           j        t           j        fv r|                     d           d S d S )Nr2  )r;   r3  rv  TWO_PAGE_LEFTTWO_PAGE_RIGHTr(  )r   rb  s     r   rb  zFPDF.page_layout  s[    >ISJ-k:::t!9:;T UUU%%e,,,,, VUr   c                     || _         dS )a  
        Activates or deactivates page compression.

        When activated, the internal representation of each page is compressed
        using the zlib/deflate method (FlateDecode), which leads to a compression ratio
        of about 2 for the resulting document.

        Page compression is enabled by default.

        Args:
            compress (bool): indicates if compression should be enabled
        N)r  )r   r  s     r   set_compressionzFPDF.set_compression  s     !r   c                     || _         dS )zf
        Defines the title of the document.

        Args:
            title (str): the title
        Ntitle)r   r~  s     r   	set_titlezFPDF.set_title  s     


r   c                 F    || _         |r|                     d           dS dS )a  
        A language identifier specifying the natural language for all text in the document
        except where overridden by language specifications for structure elements or marked content.
        A language identifier can either be the empty text string, to indicate that the language is unknown,
        or a Language-Tag as defined in RFC 3066, "Tags for the Identification of Languages".

        Args:
            lang (str): the document main language
        1.4N)langr(  )r   r  s     r   set_langzFPDF.set_lang  s7     	 	-%%e,,,,,	- 	-r   c                     || _         dS )zz
        Defines the subject of the document.

        Args:
            subject (str): the document main subject
        N)subject)r   r  s     r   set_subjectzFPDF.set_subject  s     r   c                     || _         dS )zt
        Defines the author of the document.

        Args:
            author(str): the name of the author
        N)author)r   r  s     r   
set_authorzFPDF.set_author  s     r   c                     || _         dS )z
        Associate keywords with the document

        Args:
            keywords (str): a space-separated list of words
        N)keywords)r   r  s     r   set_keywordszFPDF.set_keywords  s     !r   c                     || _         dS )z
        Defines the creator of the document.
        This is typically the name of the application that generates the PDF.

        Args:
            creator (str): name of the PDF creator
        N)creator)r   r  s     r   set_creatorzFPDF.set_creator  s     r   c                     || _         dS )zProducer of documentN)producer)r   r  s     r   set_producerzFPDF.set_producer  s     r   c                     | j         rt          d          t          |t                    st	          dt          |                     |j        s|                                }|| _        dS )z:Sets Creation of Date time, or current time if None given.zB.set_creation_date() must always be called before .sign*() methodsz#date should be a datetime but is a N)	r   rF   r   r   	TypeErrorr+  tzinfo
astimezoner  )r   dates     r   set_creation_datezFPDF.set_creation_date  sz    > 	T   $)) 	PN$t**NNOOO{ 	%??$$D!r   c                 |    d|d d         v rt          d          || _        |r|                     d           d S d S )Nz	<?xpacket2   z@fpdf2 already performs XMP metadata wrapping in a <?xpacket> tagr  )
ValueErrorr   r(  )r   r   s     r   set_xmp_metadatazFPDF.set_xmp_metadata  sa    ,ss+++R   ) 	-%%e,,,,,	- 	-r   c                     t          j        dt          t                                 |dk    rt	          d| d          || _        dS )a  
        Defines a document option.

        Args:
            opt (str): name of the option to set
            value (str) option value

        .. deprecated:: 2.4.0
            Simply set the `FPDF.core_fonts_encoding` property as a replacement.
        zset_doc_option() is deprecated since v2.4.0 and will be removed in a future release. Simply set the `.core_fonts_encoding` property as a replacement.r   r   zUnknown document option ""N)r   r   r   r&   rF   r   )r   optvalues      r   set_doc_optionzFPDF.set_doc_option  sg     	S &((	
 	
 	
 	
 ''' BC B B BCCC#(   r   c                     |t           vr-t          d| dd                    t                                || j        _        |dk    r|                     d           dS dS )a  
        Args:
            image_filter (str): name of a the image filter to use
                when embedding images in the document, or "AUTO",
                meaning to use the best image filter given the images provided.
                Allowed values: `FlateDecode` (lossless zlib/deflate compression),
                `DCTDecode` (lossy compression with JPEG)
                and `JPXDecode` (lossy compression with JPEG2000).
        'z4' is not a supported image filter - Allowed values: r   	JPXDecoder2  N)rS   r  joinr   image_filterr(  )r   r  s     r   set_image_filterzFPDF.set_image_filter  s     666IL I I&(gg.E&F&FI I   )5%;&&%%e,,,,, '&r   {nb}c                     || _         dS )a  
        Defines an alias for the total number of pages.
        It will be substituted as the document is closed.

        This is useful to insert the number of pages of the document
        at a time when this number is not known by the program.

        This substitution can be disabled for performances reasons, by calling `alias_nb_pages(None)`.

        Args:
            alias (str): the alias. Defaults to "{nb}".

        Notes
        -----

        When using this feature with the `FPDF.cell` / `FPDF.multi_cell` methods,
        or the `.underline` attribute of `FPDF` class,
        the width of the text rendered will take into account the alias length,
        not the length of the "actual number of pages" string,
        which can causes slight positioning differences.
        N)str_alias_nb_pages)r   aliass     r   r   zFPDF.alias_nb_pages0  s    , #(r   r   c           	         | j         rt          d          | j        }| j        r
| j         dn| j        }| j        }| j        }	| j        }
| j        }| j	        }| j
        }| j        }| j        }| j        dk    r"d| _        |                                  d| _        |                     ||||p| j        |p| j        |                                             | j        rt+          | j        t,                    rC | j        | j          |                     dd| j        | j        d            | j        |j          n(|                     | j        dd| j        | j                   |                     d	           |	| _        |                     |	| j        z  d
d           |r|                     |||           |
| _        |
| j         k    r9|                     |
!                                "                                           || _        || j#        k    r9|                     |!                                $                                           || _	        | %                                 | j        |	k    r(|	| _        |                     |	| j        z  d
d           |r|                     |||           | j        |
k    r@|
| _        |                     |
!                                "                                           | j        |k    r@|| _        |                     |!                                $                                           || _	        |dk    r| &                    |           |dk    r| '                    |           |tQ          ddd          k    r+| )                    |d         |d         |d                    dS dS )u  
        Adds a new page to the document.
        If a page is already present, the `FPDF.footer()` method is called first.
        Then the page  is added, the current position is set to the top-left corner,
        with respect to the left and top margins, and the `FPDF.header()` method is called.

        Args:
            orientation (str): "portrait" (can be abbreviated "P")
                or "landscape" (can be abbreviated "L"). Default to "portrait".
            format (str): "a3", "a4", "a5", "letter", "legal" or a tuple
                (width, height). Default to "a4".
            same (bool): indicates to use the same page format as the previous page.
                Default to False.
            duration (float): optional page’s display duration, i.e. the maximum length of time,
                in seconds, that the page is displayed in presentation mode,
                before the viewer application automatically advances to the next page.
                Can be configured globally through the `.page_duration` FPDF property.
                As of june 2021, onored by Adobe Acrobat reader, but ignored by Sumatra PDF reader.
            transition (Transition child class): optional visual transition to use when moving
                from another page to the given page during a presentation.
                Can be configured globally through the `.page_transition` FPDF property.
                As of june 2021, onored by Adobe Acrobat reader, but ignored by Sumatra PDF reader.
        zCA page cannot be added on a closed document, after calling output()r   r   TF)new_pageFstylez2 J.2f wr   r   r   r   r   N)*r  rF   r}   r   r~   r   r   r   r   r   r   r   r   r   r   footer
_beginpager   r   _has_next_pager   r   r   set_fill_colorrectr7  r<  	colors255image_outr   set_fontr   	serializeupperr   r   headerset_stretchingset_char_spacingr   _write_dash_pattern)r   r  r   sameduration
transitionfamilyr  sizelwdcfctc
stretchingr   r   s                   r   add_pagezFPDF.add_pageH  s   4 ; 	U   !)-L4?%%%%T_ ____)
((9q==!DNKKMMM"DN 	**.$.,,... 	 	
 	
 	
  	G$.66 G##T%9::		!Qc	:::##R\222

4/AtvtvFFF		%		R$&[(((()))  	/MM&%... (((IIbllnn**,,---(((IIbllnn**,,--- 	?b   DOIIdf,,,,--- 	/MM&%...?b   DOIIbllnn**,,---?b   DOIIbllnn**,,---
+++1!!,///4QAQ77777$$V$l5&9<;P     87r   c                 p   | xj         dz  c_         |rKt          t                      ||| j                   }|| j        | j         <   |r|                     d           n| j        | j                  }| j        | _        | j        | _        d| _	        d| _
        d| _        |r|s|rt          d| d| d	|           nZ|rt          || j                  n| j        | j        f\  }}	|                     |p| j        ||	           | j        | j        z
  | _        |                    | j        | j                   d S )
Nr   )contentsr  r  indexr2  r   r   r   zInconsistent parameters: same=z but orientation=z format=)r   r]   	bytearrayr   r(  r   r   r   r   r}   r   r   r  r   r   r   r   r   r   r<  r   rQ  set_dimensionsr[  r\  )
r   r  r   r  r  r  r  r   r]  r^  s
             r   r  zFPDF._beginpage  sy    			Q		 	)"!%i	  D %)DJty! 1))%000:di(D" 	= f  iTiiKiiagii   4:W///
DJ?W *M> !!3t3]N   '+ft}&<D#DIty11111r   c                     dS )aW  
        Header to be implemented in your own inherited class

        This is automatically called by `FPDF.add_page()`
        and should not be called directly by the user application.
        The default implementation performs nothing: you have to override this method
        in a subclass to implement your own rendering logic.
        Nr   r,  s    r   r  zFPDF.header        r   c                     dS )al  
        Footer to be implemented in your own inherited class.

        This is automatically called by `FPDF.add_page()` and `FPDF.output()`
        and should not be called directly by the user application.
        The default implementation performs nothing: you have to override this method
        in a subclass to implement your own rendering logic.
        Nr   r,  s    r   r  zFPDF.footer  r  r   c                     | j         S )zGet the current page numberr   r,  s    r   page_nozFPDF.page_no  s
    yr   c                     t          |||          }|| j        k    rR|| _        | j        dk    rB|                     | j                                                                                   dS dS dS )ay  
        Defines the color used for all stroking operations (lines, rectangles and cell borders).
        It can be expressed in RGB components or grey scale.
        The method can be called before the first page is created and the value is retained from page to page.

        Args:
            r (int, tuple, fpdf.drawing.DeviceGray, fpdf.drawing.DeviceRGB): if `g` and `b` are given, this indicates the red component.
                Else, this indicates the grey level. The value must be between 0 and 255.
            g (int): green component (between 0 and 255)
            b (int): blue component (between 0 and 255)
        r   N)r(   r   r   r  r  r  )r   rgbr   s        r   set_draw_colorzFPDF.set_draw_color  s     -Q155
(((DOy1}}		$/3355;;==>>>>> )(}r   c                     t          |||          }|| j        k    rR|| _        | j        dk    rB|                     | j                                                                                   dS dS dS )a|  
        Defines the color used for all filling operations (filled rectangles and cell backgrounds).
        It can be expressed in RGB components or grey scale.
        The method can be called before the first page is created and the value is retained from page to page.

        Args:
            r (int, tuple, fpdf.drawing.DeviceGray, fpdf.drawing.DeviceRGB): if `g` and `b` are given, this indicates the red component.
                Else, this indicates the grey level. The value must be between 0 and 255.
            g (int): green component (between 0 and 255)
            b (int): blue component (between 0 and 255)
        r   N)r(   r   r   r  r  r   )r   r  r  r  r   s        r   r  zFPDF.set_fill_color  r  r   c                 2    t          |||          | _        dS )aA  
        Defines the color used for text.
        It can be expressed in RGB components or grey scale.
        The method can be called before the first page is created and the value is retained from page to page.

        Args:
            r (int, tuple, fpdf.drawing.DeviceGray, fpdf.drawing.DeviceRGB): if `g` and `b` are given, this indicates the red component.
                Else, this indicates the grey level. The value must be between 0 and 255.
            g (int): green component (between 0 and 255)
            b (int): blue component (between 0 and 255)
        N)r(   r   )r   r  r  r  s       r   set_text_colorzFPDF.set_text_color  s     2!Q::r   c                     |r|n|                      |          }d}|                     ||          D ]}||                                z  }|S )a&  
        Returns the length of a string in user unit. A font must be selected.
        The value is calculated with stretching and spacing.

        Note that the width of a cell has some extra padding added to this width,
        on the left & right sides, equal to the .c_margin property.

        Args:
            s (str): the string whose length is to be computed.
            normalized (bool): whether normalization needs to be performed on the input string.
            markdown (bool): indicates if basic markdown support is enabled
        r   )normalize_text_parse_chars	get_width)r   s
normalizedmarkdownr7  frags         r   get_string_widthzFPDF.get_string_width&  s_     7AA!4!4Q!7!7%%a22 	" 	"D!!!AAr   c                     || j         k    r5|| _         | j        dk    r%|                     || j        z  dd           dS dS dS )aF  
        Defines the line width of all stroking operations (lines, rectangles and cell borders).
        By default, the value equals 0.2 mm.
        The method can be called before the first page is created and the value is retained from page to page.

        Args:
            width (float): the width in user unit
        r   r  r  N)r   r   r  r   )r   widths     r   set_line_widthzFPDF.set_line_width:  sZ     DO###DOy1}}		UTV^333344444 $#}r   c                    t          |t          t          j        t          t
          t          t          d          f          r,t          |t
                    r|j        | _	        dS || _	        dS t          dt          |                     )aB  
        Sets a background color or image to be drawn every time `FPDF.add_page()` is called, or removes a previously set background.
        The method can be called before the first page is created and the value is retained from page to page.

        Args:
            background: either a string representing a file path or URL to an image,
                an io.BytesIO containg an image as bytes, an instance of `PIL.Image.Image`, drawing.DeviceRGB
                or a RGB tuple representing a color to fill the background with or `None` to remove the background
        Nzkbackground must be of type str, io.BytesIO, PIL.Image.Image, drawing.DeviceRGB, tuple or None
        got: )r   r   ioBytesIOr   r)   r   r+  r  r   r  )r   
backgrounds     r   set_page_backgroundzFPDF.set_page_backgroundH  s     bj%E4::N
 
 	 *i00 2'1';$$$'1$$$#:# #  r   c              #     K   | j         t          d          t                      }|| _         	 |V  d| _         n# d| _         w xY w|                                 }| j        t          | j        | j                  | j        | j	        |f}|r |j
        g ||R  }n
 |j        | }|                     |           |                     d           dS )a  
        Create a context for drawing paths on the current page.

        If this context manager is called again inside of an active context, it will
        raise an exception, as base drawing contexts cannot be nested.

        Args:
            debug_stream (TextIO): print a pretty tree of all items to be rendered
                to the provided stream. To store the output in a string, use
                `io.StringIO`.
        Nz9cannot create a drawing context while one is already openr  )r	  rF   r,   _current_graphic_styler
  r.   r   r   r   r<  render_debugrenderr  r(  )r   debug_streamcontextstarting_stylerender_argsrendereds         r   drawing_contextzFPDF.drawing_context`  s      %1K   !""%,"	.MMM)-D&&D&----44661$&$&!!FF
  	4+w+G[G,GGGHH%w~{3H		(!!%(((((s	   ; 	Ac                 L   t                      }| j        |_        | j        |_        | j        | j        k    r| j        |_        | j        | j	        k    r| j        |_        | j
        }|d         |d         f}|d         dk    s|d         dk    rd }||_        |d         |_        |S )Nr   r   r   r   r   )r+   r   allow_transparencyr   stroke_widthr   r   stroke_colorr   r   r   stroke_dash_patternstroke_dash_phase)r   gs	dash_infor   s       r   r  zFPDF._current_graphic_style  s    __ $ >
 /?d555"oBO?d555 OBM%	!&)9U+;<Oq  l1o&:&:L!-(1	r   c              #      K   |                      |          5 }t          ||          }||j        _        |V  |                    |           ddd           dS # 1 swxY w Y   dS )aY  
        Create a path for appending lines and curves to.

        Args:
            x (float): Abscissa of the path starting point
            y (float): Ordinate of the path starting point
            paint_rule (PathPaintRule): Optional choice of how the path should
                be painted. The default (AUTO) automatically selects stroke/fill based
                on the path style settings.
            debug_stream (TextIO): print a pretty tree of all items to be rendered
                to the provided stream. To store the output in a string, use
                `io.StringIO`.

        r  )r   r   N)r  r-   r  
paint_ruleadd_item)r   r   r   r  r  ctxtpaths          r   new_pathzFPDF.new_path  s        !!|!<< 	 a(((D$.DJ!JJJMM$		  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	 s   7AA!$A!c                     |                      |          5 }|                    |           ddd           dS # 1 swxY w Y   dS )aI  
        Add a pre-constructed path to the document.

        Args:
            path (drawing.PaintedPath): the path to be drawn.
            debug_stream (TextIO): print a pretty tree of all items to be rendered
                to the provided stream. To store the output in a string, use
                `io.StringIO`.
        r  N)r  r  )r   r	  r  r  s       r   	draw_pathzFPDF.draw_path  s     !!|!<< 	 MM$	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	 s   :>>c                    t          |t          t          f          r|dk    st          d          t          |t          t          f          r|dk    st          d          t          |t          t          f          r|dk    st          d          t	          |||          }|| j        k    r || _        |                     |||           dS dS )a  
        Set the current dash pattern for lines and curves.

        Args:
            dash (float): The length of the dashes in current units.

            gap (float): The length of the gaps between dashes in current units.
                If omitted, the dash length will be used.

            phase (float): Where in the sequence to start drawing.

        Omitting 'dash' (= 0) resets the pattern to a solid line.
        r   z.Dash length must be zero or a positive number.z-gap length must be zero or a positive number.z(Phase must be zero or a positive number.r   N)r   r   floatr  r   r   r  )r   r   r   r   patterns        r   set_dash_patternzFPDF.set_dash_pattern  s     4#u.. 	O4199MNNN3e-- 	N#((LMMM53,// 	IEQJJGHHHDc777d''' 'D$$T366666 ('r   c                     |rF|r(d|| j         z  dd|| j         z  dd|| j         z  dd}nd|| j         z  dd|| j         z  dd}nd}|                     |           d S )N[z.3f z] z dz[] 0 d)r   r  )r   r   r   r   dstrs        r   r  zFPDF._write_dash_pattern  s     	 FX4$&=XXXsTV|XXX5$&=XXXXE4$&=EEEtvEEEED		$r   c           
          |                      || j        z  dd| j        |z
  | j        z  dd|| j        z  dd| j        |z
  | j        z  dd           dS )a  
        Draw a line between two points.

        Args:
            x1 (float): Abscissa of first point
            y1 (float): Ordinate of first point
            x2 (float): Abscissa of second point
            y2 (float): Ordinate of second point
        r  r   m  l SNr  r   r<  )r   x1y1x2y2s        r   linez	FPDF.line  s     			DF{R 0 0$&2+!7R 0 0TVR 0 0tv%/0 0 0	
 	
 	
 	
 	
r   c                    |r(t          j        dt          t                                 |r|t          j        }n;t	          j        |          }|r%|t          j        k    rt          d| d|           d}|D ]G}| 	                    |d         | j
        z  dd	| j        |d
         z
  | j
        z  dd	|            d}H|r| 	                    d           | 	                    d	|j                    dS )a  
        Draws lines between two or more points.

        Args:
            point_list (list of tuples): List of Abscissa and Ordinate of
                                        segments that should be drawn
            fill (bool): [**DEPRECATED since v2.5.4**] Use `style="F"` or `style="DF"` instead
            polygon (bool): If true, close path before stroking, to fill the inside of the polyline
            style (fpdf.enums.RenderStyle, str): Optional style of rendering. Possible values are:

            * `D` or None: draw border. This is the default value.
            * `F`: fill
            * `DF` or `FD`: draw and fill
        zP"fill" parameter is deprecated since v2.5.4, use style="F" or style="DF" insteadr   Nz"Conflicting values provided: fill=z	 & style=mr   r  r  r   rX  z h)r   r   r   r&   r>   DFr3  Dr  r  r   r<  operator)r   
point_listfillpolygonr  r"  points          r   polylinezFPDF.polyline  sC      	M: #*,,     	EMNEE&u--E .. OOOOO    	 	EII8df$XXXDFU1X,=+GXXXhXX   HH 	IIdOOO		&en&&'''''r   c                 8    |                      ||d|           dS )a  
        Outputs a polygon defined by three or more points.

        Args:
            point_list (list of tuples): List of coordinates defining the polygon to draw
            fill (bool): [**DEPRECATED since v2.5.4**] Use `style="F"` or `style="DF"` instead
            style (fpdf.enums.RenderStyle, str): Optional style of rendering. Possible values are:

            * `D` or None: draw border. This is the default value.
            * `F`: fill
            * `DF` or `FD`: draw and fill
        T)r$  r%  r  N)r'  )r   r#  r$  r  s       r   r%  zFPDF.polygon(  s$     	jtTGGGGGr   r   c                     t          j        dt          t                                 |                     ||           |                     ||||           |                                  dS )a  
        Draw a dashed line between two points.

        Args:
            x1 (float): Abscissa of first point
            y1 (float): Ordinate of first point
            x2 (float): Abscissa of second point
            y2 (float): Ordinate of second point
            dash_length (float): Length of the dash
            space_length (float): Length of the space between 2 dashes

        .. deprecated:: 2.4.6
            Use `FPDF.set_dash_pattern()` and the normal drawing operations instead.
        zdashed_line() is deprecated since v2.4.6, and will be removed in a future release. Use set_dash_pattern() and the normal drawing operations instead.r   N)r   r   r   r&   r  r  )r   r  r  r  r  dash_lengthspace_lengths          r   dashed_linezFPDF.dashed_line8  sy      	T &((	
 	
 	
 	
 	k<888		"b"b!!!r   c                    t          j        |          }|dur|                     |||||||           dS |                     || j        z  dd| j        |z
  | j        z  dd|| j        z  dd| | j        z  dd|j         	           dS )a{  
        Outputs a rectangle.
        It can be drawn (border only), filled (with no border) or both.

        Args:
            x (float): Abscissa of upper-left bounding box.
            y (float): Ordinate of upper-left bounding box.
            w (float): Width.
            h (float): Height.
            style (fpdf.enums.RenderStyle, str): Optional style of rendering. Possible values are:

            * `D` or empty string: draw border. This is the default value.
            * `F`: fill
            * `DF` or `FD`: draw and fill

            round_corners (tuple of str, tuple of fpdf.enums.Corner, bool): Optional draw a rectangle with round corners.
            Possible values are:

            *`TOP_LEFT`: a rectangle with round top left corner
            *`TOP_RIGHT`: a rectangle with round top right corner
            *`BOTTOM_LEFT`: a rectangle with round bottom left corner
            *`BOTTOM_RIGHT`: a rectangle with round bottom right corner
            *`True`: a rectangle with all round corners
            *`False`: a rectangle with no round corners

            corner_radius: Optional radius of the corners
        Fr  r   re N)r>   r3  _draw_rounded_rectr  r   r<  r"  )r   r   r   r7  r<  r  round_cornerscorner_radiuss           r   r  z	FPDF.rectU  s    < "5))%%##Aq!Q}mTTTTTIItv:Q 9 9TVaZ46$9Q 9 9DF
Q 9 92;89 9(-9 9    r   c                    |}||k     r|}|dk    r|dz  }||dz  k    r||z  }||fx}	}
||z   |fx}}||z   ||z   fx}}|||z   fx}}|||z   |||z   g}||||z   ||z   g}|du rBt           j        j        t           j        j        t           j        j        t           j        j        f}t          d |D                       }t           j        |v r8|                     |d         |d         d|z  dd|           ||z   |f}	|||z   f}
t           j        |v rD|                     |d	         d|z  z
  |d	         d|z  dd|           ||z   |z
  |f}||z   ||z   f}t           j        |v rP|                     |d
         d|z  z
  |d
         d|z  z
  d|z  dd|           ||z   ||z   |z
  f}||z   |z
  ||z   f}t           j        |v rD|                     |d         |d         d|z  z
  d|z  dd|           ||z   ||z   f}|||z   |z
  f}|j        r | 	                    |	|||||||
|	g	d           |j
        r|                     |	d         |	d	         |d         |d	                    |                     |d         |d	         |d         |d	                    |                     |d         |d	         |d         |d	                    |                     |d         |d	         |
d         |
d	                    d S d S )Nr      r   Tc              3   >   K   | ]}t          j        |          V  d S r%  )r7   r3  ).0rcs     r   	<genexpr>z*FPDF._draw_rounded_rect.<locals>.<genexpr>  s,      HHBfmB//HHHHHHr      i  r  r      Z   r  )r7   	TOP_RIGHTr  TOP_LEFTBOTTOM_RIGHTBOTTOM_LEFTr   arcis_fillr'  is_drawr  )r   r   r   r7  r<  r  r0  r  minpoint_1point_8point_2point_3point_4point_5point_6point_7coor_xcoor_ys                      r   r/  zFPDF._draw_rounded_rect|  s   q55C66aAa<<HAF"'UAJ&'UAEN*'AJ&'QUAq1u%QAq1u%D   &%#)"(	M HH-HHHHH},,HHVAYq	1q5#s%HHHH1uajG!a%jG?m++HHVAYQ&q	1q5#qHNNN1uqy!nG1ua!enG..HHVAYQ&q	AE(91q5!RuHUUU1ua!eai(G1uqy!a%(G-//HHVAYq	AE 11q5"cHOOO1ua!enG!a%!)nG= 	MM
      = 	FIIgaj'!*gaj'!*EEEIIgaj'!*gaj'!*EEEIIgaj'!*gaj'!*EEEIIgaj'!*gaj'!*EEEEE		F 	Fr   c                 j    t          j        |          }|                     |||||j                   dS )a   
        Outputs an ellipse.
        It can be drawn (border only), filled (with no border) or both.

        Args:
            x (float): Abscissa of upper-left bounding box.
            y (float): Ordinate of upper-left bounding box.
            w (float): Width
            h (float): Height
            style (fpdf.enums.RenderStyle, str): Optional style of rendering. Possible values are:

            * `D` or empty string: draw border. This is the default value.
            * `F`: fill
            * `DF` or `FD`: draw and fill
        N)r>   r3  _draw_ellipser"  )r   r   r   r7  r<  r  s         r   ellipsezFPDF.ellipse  s8    " "5))1aAu~66666r   c                    ||dz  z   }||dz  z   }|dz  }|dz  }	dt          j        d          dz
  z  |z  }
dt          j        d          dz
  z  |	z  }|                     ||z   | j        z  dd| j        |z
  | j        z  dd||z   | j        z  dd| j        |z
  |z   | j        z  dd||
z   | j        z  dd| j        |z
  |	z   | j        z  dd|| j        z  dd| j        |z
  |	z   | j        z  dd           |                     ||
z
  | j        z  dd| j        |z
  |	z   | j        z  dd||z
  | j        z  dd| j        |z
  |z   | j        z  dd||z
  | j        z  dd| j        |z
  | j        z  dd           |                     ||z
  | j        z  dd| j        |z
  |z
  | j        z  dd||
z
  | j        z  dd| j        |z
  |	z
  | j        z  dd|| j        z  dd| j        |z
  |	z
  | j        z  dd           |                     ||
z   | j        z  dd| j        |z
  |	z
  | j        z  dd||z   | j        z  dd| j        |z
  |z
  | j        z  dd||z   | j        z  dd| j        |z
  | j        z  dd|            d S )	Nr   gUUUUUU?r   r  r  r   cz c )mathsqrtr  r   r<  )r   r   r   r7  r<  r"  cxcyrxrylxlys               r   rN  zFPDF._draw_ellipse  s#   QYQYUUdillQ&'",dillQ&'",		Gtv%K I ITVb[DF,BK I IGtv%NI I-1Vb[2-=,GNI IGtv%NI I-1Vb[2-=,GNI I ;HI I '+frkB&6$&%@HI I I	
 	
 	
 			Gtv%N K KTVb[2-=,GN K KGtv%NK K-1Vb[2-=,GNK KGtv%JK K-1Vb[DF,BJK K K	
 	
 	
 			Gtv%N I ITVb[2-=,GN I IGtv%NI I-1Vb[2-=,GNI I;HI I&*frkB&6$&%@HI I I	
 	
 	
 			Gtv%N V VTVb[2-=,GN V VGtv%NV V-1Vb[2-=,GNV VGtv%UV V-1Vb[DF,BUV VKSV V	
 	
 	
 	
 	
r   c                 8    |                      |||||           dS )a  
        Outputs a circle.
        It can be drawn (border only), filled (with no border) or both.

        Args:
            x (float): Abscissa of upper-left bounding box.
            y (float): Ordinate of upper-left bounding box.
            r (float): Radius of the circle.
            style (str): Style of rendering. Possible values are:

            * `D` or None: draw border. This is the default value.
            * `F`: fill
            * `DF` or `FD`: draw and fill
        N)rO  )r   r   r   r  r  s        r   circlezFPDF.circle  s$      	Q1a'''''r   c           
         |dz  }||z   }||z
  }	g }
t          d|dz             D ]}||t          j        t          j        d|z  |z            t          j        |          z             z  z   |	|t          j        t          j        d|z  |z            t          j        |          z             z  z   f}|
                    |           |                     |
|           dS )a  
        Outputs a regular polygon with n sides
        It can be rotated
        Style can also be applied (fill, border...)

        Args:
            x (float): Abscissa of upper-left bounding box.
            y (float): Ordinate of upper-left bounding box.
            numSides (int): Number of sides for polygon.
            polyWidth (float): Width of the polygon.
            rotateDegrees (float): Optional degree amount to rotate polygon.
            style (fpdf.enums.RenderStyle, str): Optional style of rendering. Possible values are:

            * `D` or None: draw border. This is the default value.
            * `F`: fill
            * `DF` or `FD`: draw and fill
        r   r   h  r  N)rangerR  cosradianssinappendr%  )r   r   r   numSides	polyWidthrotateDegreesr  radiuscenterXcenterYpointsir&  s                r   regular_polygonzFPDF.regular_polygon  s   & Qf*f*q(Q,'' 	! 	!AftxcHn122T\-5P5PP( (  $(cHn122T\-5P5PP# #  E
 MM%     	V5)))))r   c                    t          j        |          }g }	t          d|dz  dz             D ]}}
||
dz  dk    r|n|t          j        |          z  z   }||
dz  dk    r|n|t          j        |          z  z   }|	                    ||f           |t          j        d|z            z  }~|                     |	d|           dS )a  
        Outputs a regular star with n corners.
        It can be rotated.
        It can be drawn (border only), filled (with no border) or both.

        Args:
            x (float): Abscissa of star's centre.
            y (float): Ordinate of star's centre.
            r_in (float): radius of internal circle.
            r_out (float): radius of external circle.
            corners (int): number of star's corners.
            rotate_degrees (float): Optional degree amount to rotate star clockwise.

            style (fpdf.enums.RenderStyle, str): Optional style of rendering. Possible values are:
            * `D`: draw border. This is the default value.
            * `F`: fill.
            * `DF` or `FD`: draw and fill.
        r   r   r   r8  T)r%  r  N)rR  r`  r^  ra  r_  rb  r'  )r   r   r   r_inr_outcornersrotate_degreesr  thr#  rj  corner_xcorner_ys                r   starz	FPDF.star2  s    ( \.))
q7Q;!+,, 	. 	.AQUaZZEETTXb\\IIHQUaZZEETTXb\\IIHx2333$,sW}---BBj$e<<<<<r   c                    !"#$ t          j        |          }dz  dz  |z   !|z   "d ##fd} #|          }t          j        |           t          j        |          $ !"$fd} $fd} ||          } ||          }|s||k    r|dt          j        z  z  }n|r||k    r|dt          j        z  z  } ||          }|	rw|                     !| j        z  dd| j        "z
  | j        z  dd	           |                     |d
         | j        z  dd| j        |d         z
  | j        z  dd           nA|                     |d
         | j        z  dd| j        |d         z
  | j        z  dd	           d}t          |t          j
        t          ||z
            dt          j        z  |z  z                      }||z
  |z  }t          j        |          t          j        ddt          j        |dz            dz  z  z             dz
  z  dz  }|} ||          } ||          }t          |          D ]%}|}|}||z  } ||          } ||          }|d
         ||d
         z  z   |d         ||d         z  z   g}|d
         ||d
         z  z
  |d         ||d         z  z
  g}d}||dz
  k    r|
s
d|j         }|                     |d
         | j        z  dd| j        |d         z
  | j        z  dd|d
         | j        z  dd| j        |d         z
  | j        z  dd|d
         | j        z  dd| j        |d         z
  | j        z  dd|z              '|
r_|	r|                     d|j                    dS |                     !| j        z  dd| j        "z
  | j        z  dd|j                    dS dS )a  
        Outputs an arc.
        It can be drawn (border only), filled (with no border) or both.

        Args:
            a (float): Semi-major axis diameter.
            b (float): Semi-minor axis diameter, if None, equals to a (default: None).
            start_angle (float): Start angle of the arc (in degrees).
            end_angle (float): End angle of the arc (in degrees).
            inclination (float): Inclination of the arc in respect of the x-axis (default: 0).
            clockwise (bool): Way of drawing the arc (True: clockwise, False: counterclockwise) (default: False).
            start_from_center (bool): Start drawing from the center of the circle (default: False).
            end_at_center (bool): End drawing at the center of the circle (default: False).
            style (fpdf.enums.RenderStyle, str): Optional style of rendering. Allowed values are:

            * `D` or None: draw border. This is the default value.
            * `F`: fill
            * `DF` or `FD`: draw and fill
        Nr   c                 &    | t           j        z  dz  S )Nr8  )rR  pi)degs    r   
deg_to_radzFPDF.arc.<locals>.deg_to_rad  s    =3&&r   c                      | dz            } t          j        t          j        |           z  t          j        |           z            }|dk     r|dt           j        z  z  }|S )Nr]  r   r   )rR  atan2ra  r_  rw  )angleetaar  ry  s     r   angle_to_paramz FPDF.arc.<locals>.angle_to_param  s_    Jus{++E*TXe__q0$(5//A2EFFCQwwq47{"Jr   c                     t          j        |           z  }t          j        |           z  }|z  z   |z  z
  |z  z   |z  z   gS r%  )rR  r_  ra  )	r}  	a_cos_eta	b_sin_etar~  r  	cos_thetarT  rU  	sin_thetas	      r   evaluatezFPDF.arc.<locals>.evaluate  sa    DHSMM)IDHSMM)I Y**Y-BBY**Y-BB r   c                     t          j        |           z  }t          j        |           z  }| z  |z  z
  | z  |z  z   gS r%  )rR  ra  r_  )r}  	a_sin_eta	b_cos_etar~  r  r  r  s      r   derivative_evaluatez%FPDF.arc.<locals>.derivative_evaluate  s[    DHSMM)IDHSMM)I 
Y&Y)>>
Y&Y)>> r   r  r  z mr   r   z l   r9  r   rQ  zh z l )r>   r3  rR  r_  ra  rw  r  r   r<  rB  ceilabsrS  tanr^  r"  )%r   r   r   r~  start_angle	end_angler  inclination	clockwisestart_from_centerend_at_centerr  r  thetar  r  	start_etaend_etastart_point
max_curvesnd_etaalphaeta2p2p2_primerj  p1p1_primecontrol_point_1control_point_2endr  rT  rU  ry  r  s%      `  `                         @@@@@r   r?  zFPDF.arcQ  sf   D "5))9A	Q	QUU	' 	' 	'	 	 	 	 	 	 	 
;''HUOO	HUOO		 	 	 	 	 	 	 	 	 		 	 	 	 	 	 	 	 #N;//	 .++ 	%W	11q47{"GG 	%7i//TW$Ihy))  	IIdfIIIDFRK46+AIIIIJJJIIq>DF*[[[$&;q>2ITV1S[[[[    IIq>DF*[[[$&;q>2ITV1S[[[[  
 
	#g	&9":":a$'kJ>V"WXX
 
 9$)49QTXeai5H5HA5M1M-M#N#NQR#RSVWWXd^^&&t,,q 	 	ABHEMD$B**400H!!uux{'::BqEEHUVKDW<WXO!!uux{'::BqEEHUVKDW<WXOCAEzz-z*%.**II&q)DF2f N N$&?STCU:UY]Y_9_f N N&q)DF2fN N:>&?STCU:UY]Y_9_fN N!utv~MN N-1Vbe^tv,EMN N NPST     	  		/u~//00000		DF{XXX$&2+)?XXXXX    		 	r   c
                 D    |                      ||||||||dd|	           dS )a  
        Outputs a solid arc. A solid arc combines an arc and a triangle to form a pie slice
        It can be drawn (border only), filled (with no border) or both.

        Args:
            x (float): Abscissa of upper-left bounding box.
            y (float): Ordinate of upper-left bounding box.
            a (float): Semi-major axis.
            b (float): Semi-minor axis, if None, equals to a (default: None).
            start_angle (float): Start angle of the arc (in degrees).
            end_angle (float): End angle of the arc (in degrees).
            inclination (float): Inclination of the arc in respect of the x-axis (default: 0).
            clockwise (bool): Way of drawing the arc (True: clockwise, False: counterclockwise) (default: False).
            style (str): Style of rendering. Possible values are:

            * `D` or None: draw border. This is the default value.
            * `F`: fill
            * `DF` or `FD`: draw and fill
        TN)r?  )
r   r   r   r~  r  r  r  r  r  r  s
             r   	solid_arczFPDF.solid_arc  sE    > 		
 	
 	
 	
 	
r   c                 t   |st          d          t          t          |                    d                                         }|dvrt          d| d          |dk    r(t	          j        dt          t                                 d	                    t          |
                                                    }t          d
 |D                       rt          d|           dt          fD ]=}|st          |          |z                                  rt          |          |z  } n>t          d|           ||j        }|                                 | }|| j        v s	|t$          v r(t	          j        d| dt                                 dS t'          | |||          | j        |<   dS )a  
        Imports a TrueType or OpenType font and makes it available
        for later calls to the `FPDF.set_font()` method.

        You will find more information on the "Unicode" documentation page.

        Args:
            family (str): optional name of the font family. Used as a reference for `FPDF.set_font()`.
                If not provided, use the base name of the `fname` font path, without extension.
            style (str): font style. "B" for bold, "I" for italic.
            fname (str): font file name. You can specify a relative or full path.
                If the file is not found, it will be searched in `FPDF_FONT_DIR`.
            uni (bool): [**DEPRECATED since 2.5.1**] unused
        z"fname" parameter is requiredr   )z.otfz.otcz.ttfz.ttcz!Unsupported font file extension: z. add_font() used to accept .pkl file as input, but for security reasons this feature is deprecated since v2.5.1 and has been removed in v2.5.3.r   zK"uni" parameter is deprecated since v2.5.1, unused and will soon be removedr   r   c              3      K   | ]}|d vV  	dS BINr   r5  rt   s     r   r7  z FPDF.add_font.<locals>.<genexpr>6  s'      66fvT!666666r   z9Unknown style provided (only B & I letters are allowed): .zTTF Font file not found: Nz!Core font or font already added 'z': doing nothing)r  r   r   r   r   r   r   r&   r  sortedr  anyFPDF_FONT_DIRr   existsFileNotFoundErrorstemr   rJ   rL   )	r   r  r  fnameuniextparentfont_file_pathfontkeys	            r   add_fontzFPDF.add_font  s     	><===s5zz""1%++--666[C [ [ [   ,M6 #*,,    u{{}}--..6666666 	SESS   M* 	I 	IF Vu$,,.. !%f!5 $$G$G$GHHH>#(F\\^^,U,,dj  Gz$9$9MMGMMM*,,    F%dNGUKK
7r   c                    |s| j         }|                                }d                    t          |                                                    }t          d |D                       rt          d|           d|v rd| _        |                    dd          }nd| _        || j	        v rT||z   | j
        vrHt          j        d| d| j	        |          d	t          t                      
           | j	        |         }n.|dv r*|r(t          j        d| dt                      
           d}|s| j        }| j         |k    r"| j        |k    rt#          | j        |          rdS ||z   }|| j
        vr5|t$          vrt'          d| d          t)          | ||          | j
        |<   || _         || _        || _        | j
        |         | _        | j        dk    r.|                     d| j        j         d| j        dd           dS dS )a  
        Sets the font used to print character strings.
        It is mandatory to call this method at least once before printing text.

        Default encoding is not specified, but all text writing methods accept only
        unicode for external fonts and one byte encoding for standard.

        Standard fonts use `Latin-1` encoding by default, but Windows
        encoding `cp1252` (Western Europe) can be used with
        `self.core_fonts_encoding = encoding`.

        The font specified is retained from page to page.
        The method can be called before the first page is created.

        Args:
            family (str): name of a font added with `FPDF.add_font`,
                or name of one of the 14 standard "PostScript" fonts:
                Courier (fixed-width), Helvetica (sans serif), Times (serif),
                Symbol (symbolic) or ZapfDingbats (symbolic)
                If an empty string is provided, the current family is retained.
            style (str): empty string (by default) or a combination
                of one or several letters among B (bold), I (italic) and U (underline).
                Bold and italic styles do not apply to Symbol and ZapfDingbats fonts.
            size (float): in points. The default value is the current size.
        r   c              3      K   | ]}|d vV  	dS )BIUNr   r  s     r   r7  z FPDF.set_font.<locals>.<genexpr>r  s'      77vvU"777777r   z9Unknown style provided (only B/I/U letters are allowed): r   TFzSubstituting font z by core font z< - This is deprecated since v2.7.8, and will soon be removedr   )symbolzapfdingbatszBuilt-in font z6 only has a single 'style' and can't be bold or italicNzUndefined font: z3 - Use built-in fonts or FPDF.add_font() beforehandr   BT /Fr  r   Tf ET)r}   r   r  r  r  r  r  r   replacer   r   r   r   r   r&   r   r~   r	   rJ   rF   rI   r   r   r  rj  )r   r  r  r  r  s        r   r  zFPDF.set_fontS  s   4  	&%Fu{{}}--..7777777 	SESS   %<<!DNMM#r**EE"DNT&&&6E>+K+KMOV O O4;LV;T O O O"*,,	    &v.FF111e1M. . . .*,,   
 E 	%$D &&5(()400 ) F 5.$*$$j((#Hw H H H  
 #+4%"@"@DJw "  Jw/9q==IIQd/1QQD4EQQQQRRRRR =r   c                     t          | j        |          rdS || _        | j        dk    rD| j        st	          d          |                     d| j        j         d| j        dd           dS dS )zp
        Configure the font size in points

        Args:
            size (float): font size in points
        Nr   z3Cannot set font size: a font must be selected firstr  r  r  r  )r	   r   r   r   rF   r  rj  )r   r  s     r   set_font_sizezFPDF.set_font_size  s     4$d++ 	F 9q==$ #I   IIQd/1QQD4EQQQQRRRRR =r   c                 |    | j         |k    rdS || _         | j        dk    r|                     d|dd           dS dS )a\  
        Sets horizontal character spacing.
        A positive value increases the space between characters, a negative value
        reduces it (which may result in glyph overlap).
        By default, no spacing is set (which is equivalent to a value of 0).

        Args:
            spacing (float): horizontal spacing in document units
        Nr   BT r  z Tc ET)r   r   r  )r   spacings     r   r  zFPDF.set_char_spacing  sX     ''F#9q==II/G////00000 =r   c                 |    | j         |k    rdS || _         | j        dk    r|                     d|dd           dS dS )z
        Sets horizontal font stretching.
        By default, no stretching is set (which is equivalent to a value of 100).

        Args:
            stretching (float): horizontal stretching (scaling) in percents.
        Nr   r  r  z Tz ET)r   r   r  )r   r  s     r   r  zFPDF.set_stretching  sX     :--F)9q==II2J222233333 =r   c                 :   g }|D ]z}d}| j         D ]Y}|                    dd                              dd          |                                k    r|                    |           d}Z|st	          d| d          {t          |          | _        || _        dS )	a;  
        Allows you to specify a list of fonts to be used if any character is not available on the font currently set.
        Detailed documentation: https://py-pdf.github.io/fpdf2/Unicode.html#fallback-fonts

        Args:
            fallback_fonts: sequence of fallback font IDs
            exact_match (bool): when a glyph cannot be rendered uing the current font,
                fpdf2 will look for a fallback font matching the current character emphasis (bold/italics).
                If it does not find such matching font, and `exact_match` is True, no fallback font will be used.
                If it does not find such matching font, and `exact_match` is False, a fallback font will still be used.
                To get even more control over this logic, you can also override `FPDF.get_fallback_font()`
        FBr   ITzUndefined fallback font: z! - Use FPDF.add_font() beforehandN)r   r  r   rb  rF   r   r  r  )r   fallback_fontsexact_matchfallback_font_idsfallback_fontfoundr  s          r   set_fallback_fontszFPDF.set_fallback_fonts  s     + 
	 
	ME: ! !??3++33C<<@S@S@U@UUU%,,W555 E #````   #((9":":*5'''r   nullc                     t          |dk    r| j        n|| j        || j        z  z
  || j        z  |          }t	          | j                  dz   }|| j        |<   |S )aO  
        Creates a new internal link and returns its identifier.
        An internal link is a clickable area which directs to another place within the document.

        The identifier can then be passed to the `FPDF.cell()`, `FPDF.write()`, `FPDF.image()`
        or `FPDF.link()` methods.

        Args:
            y (float): optional ordinate of target position.
                The default value is 0 (top of page).
            x (float): optional abscissa of target position.
                The default value is 0 (top of page).
            page (int): optional number of target page.
                -1 indicates the current page, which is the default value.
            zoom (float): optional new zoom level after following the link.
                Currently ignored by Sumatra PDF Reader, but observed by Adobe Acrobat reader.
        r   )rH  rG  rc  r   )re   r   r\  r   r?  r   )r   r   r   r   rc  link
link_indexs          r   add_linkzFPDF.add_link  sk    $ DII	AJ&TV	
 
 
 __q(
!%
:r   c                     | j         |         }|dk    r| j        n||_        | j        || j        z  z
  |_        || j        z  |_        ||_        dS )a  
        Defines the page and position a link points to.

        Args:
            link (int): a link identifier returned by `FPDF.add_link()`.
            y (float): optional ordinate of target position.
                The default value is 0 (top of page).
            x (float): optional abscissa of target position.
                The default value is 0 (top of page).
            page (int): optional number of target page.
                -1 indicates the current page, which is the default value.
            zoom (float): optional new zoom level after following the link.
                Currently ignored by Sumatra PDF Reader, but observed by Adobe Acrobat reader.
        r   N)r   r   page_numberr\  r   rH  rG  rc  )r   r  r   r   r   rc  s         r   set_linkzFPDF.set_link  sR    $ z$(,

4999q46z)J				r   c           
         d\  }}	|rxt          |t                    rt          |          }nS|| j        v s#J d| dt	          | j                   d            | j        |         }	|	j        st          d| d          t          d|| j        z  | j	        || j        z  z
  || j        z  || j        z  ||	|          }
| j
        | j                 j                            |
           ||                     d
|           |
S )a  
        Puts a link annotation on a rectangular area of the page.
        Text or image links are generally put via `FPDF.cell`,
        `FPDF.write` or `FPDF.image`,
        but this method can be useful for instance to define a clickable area inside an image.

        Args:
            x (float): horizontal position (from the left) to the left side of the link rectangle
            y (float): vertical position (from the top) to the bottom side of the link rectangle
            w (float): width of the link rectangle
            h (float): height of the link rectangle
            link: either an URL or an integer returned by `FPDF.add_link`, defining an internal link to a page
            alt_text (str): optional textual description of the link, for accessibility purposes
            border_width (int): thickness of an optional black border surrounding the link.
                Not all PDF readers honor this: Acrobat renders it but not Sumatra.
        r   zLink with an invalid index: z (doc #links=r   zCannot insert link z with no page number assignedLink)r   r   r  heightactiondestborder_widthNz/Link)struct_typealt_text)r   r   r   r   r?  r  r  r   r   r\  r   r   annotsrb  _add_marked_content)r   r   r   r7  r<  r  r  r  r  r  
link_annots              r   r  z	FPDF.link)  s<   $ " 	$$$ 
"4 DJ&&&W$WWS__WWW '&&z$'' $QdQQQ   $$&ji!df*$df*tv:%	
 	
 	

 	
49$++J777 $$8$LLLr   c                    |r|rt          d          |rt          d          t          |          }|                    d          5 }|                                }ddd           n# 1 swxY w Y   |j        }|                                }|+t          j        |j                  	                                }n"|st          d          |st          d          t          d | j        D                       }||v rt          | d          t          d|||d	|}	| j                            |	           |                     d
           |	S )aT  
        Embed a file into the PDF document

        Args:
            file_path (str or Path): filesystem path to the existing file to embed
            bytes (bytes): optional, as an alternative to file_path, bytes content of the file to embed
            basename (str): optional, required if bytes is provided, file base name
            creation_date (datetime): date and time when the file was created
            modification_date (datetime): date and time when the file was last modified
            desc (str): optional description of the file
            compress (bool): enabled zlib compression of the file - False by default
            checksum (bool): insert a MD5 checksum of the file content - False by default

        Returns: a PDFEmbeddedFile instance, with a .basename string attribute representing the internal file name
        z+'bytes' cannot be provided with 'file_path'z.'basename' cannot be provided with 'file_path'rbNz2'bytes' is required if 'file_path' is not providedz5'basename' is required if 'file_path' is not providedc              3   >   K   | ]}|                                 V  d S r%  )basename)r5  files     r   r7  z"FPDF.embed_file.<locals>.<genexpr>  s;       )
 )
 $DMMOO)
 )
 )
 )
 )
 )
r   z' has already been embedded in this file)r  r  modification_dater  r   )r  r   openreadnamestatr   fromtimestampst_mtimer  setr   r!   rb  r(  )
r   	file_pathbytesr  r  r   
input_filestatsalready_embedded_basenamesembedded_files
             r   
embed_filezFPDF.embed_fileZ  s   .  	 P !NOOO S !QRRRYI%% *"))* * * * * * * * * * * * * * * ~HNN$$E ($,$:5>$J$J$U$U$W$W! W !UVVV  K   &) )
 )
(,(;)
 )
 )
 &
 &
" 111QQQRRR' 
/
 
 	
 
 	""=111!!%(((s   	A**A.1A.c                     | j         |fi |}	|	                    d           t          d|| j        z  | j        || j        z  z
  || j        z  || j        z  |	                                |rt          j        |          ndt          d |D                                 }
| j	        | j
                 j                            |
           |
S )a5  
        Puts a file attachment annotation on a rectangular area of the page.

        Args:
            file_path (str or Path): filesystem path to the existing file to embed
            x (float): horizontal position (from the left) to the left side of the link rectangle
            y (float): vertical position (from the top) to the bottom side of the link rectangle
            w (float): optional width of the link rectangle
            h (float): optional height of the link rectangle
            name (fpdf.enums.FileAttachmentAnnotationName, str): optional icon that shall be used in displaying the annotation
            flags (Tuple[fpdf.enums.AnnotationFlag], Tuple[str]): optional list of flags defining annotation properties
            bytes (bytes): optional, as an alternative to file_path, bytes content of the file to embed
            basename (str): optional, required if bytes is provided, file base name
            creation_date (datetime): date and time when the file was created
            modification_date (datetime): date and time when the file was last modified
            desc (str): optional description of the file
            compress (bool): enabled zlib compression of the file - False by default
            checksum (bool): insert a MD5 checksum of the file content - False by default
        FFileAttachmentNc              3   >   K   | ]}t          j        |          V  d S r%  r4   r3  r5  flags     r   r7  z2FPDF.file_attachment_annotation.<locals>.<genexpr>  -      FF-d33FFFFFFr   )	file_specr  flags)r  set_globally_enclosedr   r   r\  r  r9   r3  r   r   r   r  rb  )r   r  r   r   r7  r<  r  r  r   r  
annotations              r   file_attachment_annotationzFPDF.file_attachment_annotation  s    . (	<<V<<++E222#JIDF
"JJ#--//>BL-4T:::FFFFFFF	
 	
 	

 	
49$++J777r   c                 2   t          d|| j        z  | j        || j        z  z
  || j        z  || j        z  ||rt          j        |          ndt          d |D                                 }| j        | j                 j        	                    |           |S )a  
        Puts a text annotation on a rectangular area of the page.

        Args:
            x (float): horizontal position (from the left) to the left side of the link rectangle
            y (float): vertical position (from the top) to the bottom side of the link rectangle
            text (str): text to display
            w (float): optional width of the link rectangle
            h (float): optional height of the link rectangle
            name (fpdf.enums.AnnotationName, str): optional icon that shall be used in displaying the annotation
            flags (Tuple[fpdf.enums.AnnotationFlag], Tuple[str]): optional list of flags defining annotation properties
        TextNc              3   >   K   | ]}t          j        |          V  d S r%  r  r  s     r   r7  z'FPDF.text_annotation.<locals>.<genexpr>  r  r   )r  r  r  )
r   r   r\  r5   r3  r   r   r   r  rb  )	r   r   r   r   r7  r<  r  r  r  s	            r   text_annotationzFPDF.text_annotation  s      $JIDF
"JJ04>&t,,,$FFFFFFF	
 	
 	

 	
49$++J777r   c                    | j         st          d          || j        }|| j        }|| j        }||                     |dd          }t          d|| j        z  | j        || j        z  z
  || j        z  || j        z  |t          d |D                       d| j
                                         d	| j        j         d
| j        dd          }| j        | j                 j                            |           |S )ao  
        Puts a free text annotation on a rectangular area of the page.

        Args:
            text (str): text to display
            x (float): optional horizontal position (from the left) to the left side of the link rectangle.
                Default value: None, meaning the current abscissa is used
            y (float): vertical position (from the top) to the bottom side of the link rectangle.
                Default value: None, meaning the current ordinate is used
            w (float): optional width of the link rectangle. Default value: None, meaning the length of text in user unit
            h (float): optional height of the link rectangle. Default value: None, meaning an height equal
                to the current font size
            flags (Tuple[fpdf.enums.AnnotationFlag], Tuple[str]): optional list of flags defining annotation properties
        3No font set, you need to call set_font() beforehandNTFr  r  FreeTextc              3   >   K   | ]}t          j        |          V  d S r%  r  r  s     r   r7  z,FPDF.free_text_annotation.<locals>.<genexpr> 	  r  r   (z /Fr  r  z Tf))r  r  default_appearance)r}   rF   r   r   	font_sizer  r   r   r\  r   r   r  r   rj  r   r   r   r  rb  )r   r   r   r   r7  r<  r  r  s           r   free_text_annotationzFPDF.free_text_annotation  s"   0  	W UVVV9A9A9A9%%dte%LLA#JIDF
"JJFFFFFFFt4?#<#<#>#>tt4CTCVttY]Yjtttt	
 	
 	

 	
49$++J777r   c                     t          d|| j        z  | j        || j        z  z
  || j        z  || j        z  |          }| j        | j                 j                            |           |S )a  
        Puts an Action annotation on a rectangular area of the page.

        Args:
            action (fpdf.actions.Action): the action to add
            x (float): horizontal position (from the left) to the left side of the link rectangle
            y (float): vertical position (from the top) to the bottom side of the link rectangle
            w (float): width of the link rectangle
            h (float): height of the link rectangle
        Action)r  )r   r   r\  r   r   r  rb  )r   r  r   r   r7  r<  r  s          r   
add_actionzFPDF.add_action	  sq     $JIDF
"JJ
 
 

 	
49$++J777r   	Highlightr   r   r   c           
   #     K   | j         rt          d          d| _         dV  | j                                        D ]!\  }}|                     |||||||           "t          t                    | _        d| _         dS )u/  
        Context manager that adds a single highlight annotation based on the text lines inserted
        inside its indented block.

        Args:
            text (str): text of the annotation
            title (str): the text label that shall be displayed in the title bar of the annotation’s
                pop-up window when open and active. This entry shall identify the user who added the annotation.
            type (fpdf.enums.TextMarkupType, str): "Highlight", "Underline", "Squiggly" or "StrikeOut".
            color (tuple): a tuple of numbers in the range 0.0 to 1.0, representing a colour used for
                the title bar of the annotation’s pop-up window. Defaults to yellow.
            modification_time (datetime): date and time when the annotation was most recently modified
        zhighlight() cannot be nestedTN)quad_pointsr~  r   modification_timer   F)r  rF   r  itemsadd_text_markup_annotationr   r  )r   r   r~  r+  r   r  r   r  s           r   	highlightzFPDF.highlight	  s      " ( 	@ >???(,%!%!7!=!=!?!? 		 		D+++'"3 ,     "-T!2!2(-%%%r   c              /      K   t          j        dt          t                                  | j        |i |5  d V  d d d            d S # 1 swxY w Y   d S )Nz:add_highlight() has been renamed to highlight() in v2.5.5.r   )r   r   r   r&   r  )r   r   r   s      r   add_highlightzFPDF.add_highlight?	  s      H&((	
 	
 	
 	

 T^T,V,, 	 	EEE	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   A

AAc                    |                      d           t          j        |          j        }|| j        }|| j        }t          |ddd                   }t          |ddd                   }	t          |ddd                   }
t          |ddd                   }t          |||	||
|z
  ||	z
  ||||
  
        }| j	        |         j
                            |           |S )u  
        Adds a text markup annotation on some quadrilateral areas of the page.

        Args:
            type (fpdf.enums.TextMarkupType, str): "Highlight", "Underline", "Squiggly" or "StrikeOut"
            text (str): text of the annotation
            quad_points (tuple): array of 8 × n numbers specifying the coordinates of n quadrilaterals
                in default user space that comprise the region in which the link should be activated.
                The coordinates for each quadrilateral are given in the order: x1 y1 x2 y2 x3 y3 x4 y4
                specifying the four vertices of the quadrilateral in counterclockwise order
            title (str): the text label that shall be displayed in the title bar of the annotation’s
                pop-up window when open and active. This entry shall identify the user who added the annotation.
            color (tuple): a tuple of numbers in the range 0.0 to 1.0, representing a colour used for
                the title bar of the annotation’s pop-up window. Defaults to yellow.
            modification_time (datetime): date and time when the annotation was most recently modified
            page (int): index of the page where this annotation is added
        r1  Nr   r   r   )	r  r   r   r  r  r   r  r~  r  )r(  rA   r3  r  r  r   rB  r&  r   r   r  rb  )r   r+  r   r  r~  r   r  r   x_miny_minx_maxy_maxr  s                r   r  zFPDF.add_text_markup_annotationI	  s   8 	!!%((($T**0$ $ 2<9DK1%&&K1%&&K1%&&K1%&&#%-5=/#
 
 

 	
4&&z222r   c                     t           fd|D             d          }t          |ddd                   }t          |ddd                   }t          |ddd                   }	t          |ddd                   }
t          d||
|	|z
  |
|z
  |||||
  
        } j         j                 j                            |           |S )	u  
        Adds add an ink annotation on the page.

        Args:
            coords (tuple): an iterable of coordinates (pairs of numbers) defining a path
            contents (str): textual description
            title (str): the text label that shall be displayed in the title bar of the annotation’s
                pop-up window when open and active. This entry shall identify the user who added the annotation.
            color (tuple): a tuple of numbers in the range 0.0 to 1.0, representing a colour used for
                the title bar of the annotation’s pop-up window. Defaults to yellow.
            border_width (int): thickness of the path stroke.
        c              3   V   K   | ]#\  }}|j         z  j        |z
  j         z  fV  $d S r%  )r   r<  )r5  r   r   r   s      r   r7  z&FPDF.ink_annotation.<locals>.<genexpr>	  s?      QQATVdfqjDF%:;QQQQQQr   r   r   Nr   r   Ink)	r   r   r  r  ink_listr   r  r  r~  )sumrB  r&  r   r   r   r  rb  )r   coordsr  r~  r   r  r%  r  r  r   r!  r  s   `           r   ink_annotationzFPDF.ink_annotation~	  s      QQQQ&QQQSUVVHQTTN##HQTTN##HQTTN##HQTTN###%-5=%
 
 

 	
49$++J777r   c                    | j         st          d          |                     |          }d|| j        z  dd| j        |z
  | j        z  ddg}| j        t          j        k    r'|                    d| j         d| j	        dd           |                    | j
                            |           d           | j        r|d	k    s| j        r}|                     |d
d          }| j        r0|d	k    r*|                    |                     |||                     | j        r'| j        }|d|z  z  }|                     ||||           g }| j        | j        k    r?|                    | j                                                                                    |rdg|z   |z   dgz   }|                     d                    |                     dS )a  
        Prints a character string. The origin is on the left of the first character,
        on the baseline. This method allows placing a string precisely on the page,
        but it is usually easier to use the `FPDF.cell()`, `FPDF.multi_cell() or `FPDF.write()` methods.

        Args:
            x (float): abscissa of the origin
            y (float): ordinate of the origin
            text (str): string to print
            txt (str): [**DEPRECATED since v2.7.6**] string to print
        r  r  r  r   Td Tr r  z ETr   TFr	  g?qQN)r}   rF   r  r   r<  r   rB   r   rb  r   r   encode_textr   r  r  _do_underliner  _add_quad_pointsr   r   r  r   r  r  )r   r   r   r   slr7  r<  attr_ls           r   r   z	FPDF.text	  s     	W UVVV""4((CAJCCCdfqjDF%:CCCCD>X]**IIE$.EEdoEEEEFFF
		T&22488===>>>N 	2trzzd.Kz%%dte%LLA~ 7$"**		$,,Q155666, 2NS1W%%aAq111?do--MMT_6688>>@@BCCC 	-"$u,B		#((2,,r   c                    t          j        dt          t                                 || j        }|| j        }| j        dk    r|                     d           || _        |dk    r|t          j	        dz  z  }t          j
        |          }t          j        |          }|| j        z  }| j        |z
  | j        z  }d|dd	|dd	| dd	|dd	|d
d	|d
d| d
d	| d
d}|                     |           dS dS )zR
        .. deprecated:: 2.1.0
            Use `FPDF.rotation()` instead.
        zrotate() can produces malformed PDFs and is deprecated since v2.1.0. It will be removed in a future release. Use the rotation() context manager instead.r   Nr   r-  r8  q .5Fr  .2F cm 1 0 0 1  cm)r   r   r   r&   r   r   r   r  rR  rw  r_  ra  r   r<  r   r|  r   r   cr  rT  rU  s           r   rotatezFPDF.rotate	  sh    	> &((	
 	
 	
 	
 9A9A;!IIcNNNA::TWs]"EAATVB&1*&B2QK 2 2QK 2 2aRK 2 2aK 2 2bK 2 2rK 2 2312 2&(S12 2 2  IIaLLLLL :r   c              #     K   || j         }|| j        }|t          j        dz  z  }t          j        |          t          j        |          }}|| j        z  | j        |z
  | j        z  }}|                                 5  | 	                    |dd|dd| dd|dd|dd|dd| dd| dd           dV  ddd           dS # 1 swxY w Y   dS )a  
        Method to perform a rotation around a given center.
        It must be used as a context-manager using `with`:

            with rotation(angle=90, x=x, y=y):
                pdf.something()

        The rotation affects all elements which are printed inside the indented
        context (with the exception of clickable areas).

        Args:
            angle (float): angle in degrees
            x (float): abscissa of the center of the rotation
            y (float): ordinate of the center of the rotation

        Notes
        -----

        Only the rendering is altered. The `FPDF.get_x()` and `FPDF.get_y()` methods are
        not affected, nor the automatic page break mechanism.
        The rotation also establishes a local graphics state, so that any
        graphics state settings changed within will not affect the operations
        invoked after it has finished.
        Nr8  r5  r  r6  r7  r8  )
r   r   rR  rw  r_  ra  r   r<  local_contextr  r9  s           r   rotationzFPDF.rotation	  s     6 9A9A3x1TVdfqjDF2B!! 	 	III 2 21I 2 2A2I 2 2AI 2 2BI 2 2RI 2 2312 2&(S12 2 2   EEE	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   ?=C		CCc              #   ,  K   d}|| j         }|| j        }t          t          t	          j        |t          j        dz  z            |          |           }t          t          t	          j        |t          j        dz  z            |          |           }|| j        z  | j        |z
  | j        z  }}| 	                                5  | 
                    d|dd|dd|dd|dd	|dd
|dd           dV  ddd           dS # 1 swxY w Y   dS )a  
        Method to perform a skew transformation originating from a given center.
        It must be used as a context-manager using `with`:

            with skew(ax=15, ay=15, x=x, y=y):
                pdf.something()

        The skew transformation affects all elements which are printed inside the indented
        context (with the exception of clickable areas).

        Args:
            ax (float): angle of skew in the horizontal direction in degrees
            ay (float): angle of skew in the vertical direction in degrees
            x (float): abscissa of the center of the skew transformation
            y (float): ordinate of the center of the skew transformation
        l        Nr8  z1 .5fr  z 1 r   cm 1 0 0 1 - -r8  )r   r   r&  rB  rR  r  rw  r   r<  r=  r  )r   axayr   r   lim_valrT  rU  s           r   skewz	FPDF.skew
  s     & 9A9ATXbDGcM233W==xHHTXbDGcM233W==xHHTVdfqjDF2B!! 	 	II2R> 2 2b> 2 2> 2 2"> 2 212 2&(12 2 2   EEE	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   	3D		DDc              #     K   |\  }}	 t          j        |          j        }n# t          $ r |}Y nw xY wt	          j        t	          j        |dz                      }t	          j        t	          j        |dz                      }|| j        z  | j	        |z
  | j        z  }	}| 
                                5  |                     |dd|dd|dd|dz  dd|dd|	dd|dd|	dd           d	V  d	d	d	           d	S # 1 swxY w Y   d	S )
a+  
        Method to perform a reflection transformation over a given mirror line.
        It must be used as a context-manager using `with`:

            with mirror(origin=(15,15), angle="SOUTH"):
                pdf.something()

        The mirror transformation affects all elements which are rendered inside the indented
        context (with the exception of clickable areas).

        Args:
            origin (float, Sequence(float, float)): a point on the mirror line
            angle: (fpdf.enums.Angle): the direction of the mirror line
        r   r@  r  r   r  rA  rB  r8  N)r3   r3  r  r  rR  r_  r`  ra  r   r<  r=  r  )
r   originr|  r   r   r  r~  r  rT  rU  s
             r   mirrorzFPDF.mirror4
  s     " 1	L''-EE 	 	 	EEE	 HT\%!),,--HT\%!),,--TVdfqjDF2B!! 	 	IIK 2 21K 2 21K 2 21R4K 2 2bK 2 2rK 2 212 2&(12 2 2   EEE	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   # 227=DDDc	              +     K   | j         rt          d          |                                  d}
|	                                D ]\  }}|dv rt	          d| d          |t
          j        v r=|
t                      }
t          |
||           |dk    r|                     d           g|dv rt          | ||           }t	          d|           |
r4| j	        
                    |
          }|                     d	| d
           n|                     d           |||,|                     |p| j        |p| j        |p| j                   ||                     |           ||                     |           ||                     |           ||                     |           | | j        di | dV  |                     d           |                                  dS )a  
        Creates a local graphics state, which won't affect the surrounding code.
        This method must be used as a context manager using `with`:

            with pdf.local_context():
                set_some_state()
                draw_some_stuff()

        The affected settings are those controlled by GraphicsStateMixin and drawing.GraphicsStyle:
            allow_transparency
            auto_close
            blend_mode
            dash_pattern
            draw_color
            fill_color
            fill_opacity
            font_family
            font_size
            font_style
            font_stretching
            intersection_rule
            line_width
            paint_rule
            stroke_cap_style
            stroke_join_style
            stroke_miter_limit
            stroke_opacity
            text_color
            text_mode
            underline
            char_vpos

        Args:
            **kwargs: key-values settings to set at the beggining of this context.
        z@cannot create a local context inside an unbreakable() code blockN)r  r  r   r  zUnsupported setting: zH - This can be controlled through dash_pattern / draw_color / line_width
blend_moder  )r   r   r   	char_vposzq /z gsr,  r-  r   )r   rF   _push_local_stackr  r  r+   MERGE_PROPERTIESsetattrr(  r
  register_styler  r  r}   r~   r   r  r  r  r  r  _pop_local_stack)r   r}   r~   r  r   r   r   r   r   r   r  keyr  gs_names                 r   r=  zFPDF.local_contextV
  sh     b  	R   	    ,,.. 	@ 	@JC    !yCyyy   m444:&BC''',&&--e444RRRc5)))) !>!>!>??? 	;JJ2NNGII(G((())))IIcNNN"j&<	@UMM/t/-do.T.  
 !
+++!
+++!
+++!
+++#!D!11L111		#r   c                     | j         S )an  
        Whenever a page break condition is met, this method is called,
        and the break is issued or not depending on the returned value.

        The default implementation returns a value according to the mode selected by `FPDF.set_auto_page_break()`.
        This method is called automatically and should not be called directly by the application.
        )rB  r,  s    r   accept_page_breakzFPDF.accept_page_break
  s     ##r   c                 ^   | j         st          d          t          |t                    st          |t                    rt	          d          t          |t
                    r(|dvr$t          j        dt                                 d}t          j
        |          }t          j
        |          }t          j
        |          }|t          j        k    rt	          d          |dk    r|d	k    rt          j        }t          j        }nQ|dk    rt          j        }t          j        }n2|d
k    rt          j        }t          j        }nt	          d| d          t          j        d| d|j         d|j         dt(          t                                 |                     |          }| j        r|                     ||
          n|                     ||
          }|                     t5          |d	d	|t          j        k    rt          j        n|||d          |||||||	          S )a	  
        Prints a cell (rectangular area) with optional borders, background color and
        character string. The upper-left corner of the cell corresponds to the current
        position. The text can be aligned or centered. After the call, the current
        position moves to the selected `new_x`/`new_y` position. It is possible to put a link
        on the text. A cell has an horizontal padding, on the left & right sides, defined by
        the.c_margin property.

        If automatic page breaking is enabled and the cell goes beyond the limit, a
        page break is performed before outputting.

        Args:
            w (float): Cell width. Default value: None, meaning to fit text width.
                If 0, the cell extends up to the right margin.
            h (float): Cell height. Default value: None, meaning an height equal
                to the current font size.
            text (str): String to print. Default value: empty string.
            border: Indicates if borders must be drawn around the cell.
                The value can be either a number (`0`: no border ; `1`: frame)
                or a string containing some or all of the following characters
                (in any order):
                `L`: left ; `T`: top ; `R`: right ; `B`: bottom. Default value: 0.
            new_x (fpdf.enums.XPos, str): New current position in x after the call. Default: RIGHT
            new_y (fpdf.enums.YPos, str): New current position in y after the call. Default: TOP
            ln (int): **DEPRECATED since 2.5.1**: Use `new_x` and `new_y` instead.
            align (fpdf.enums.Align, str): Set text alignment inside the cell.
                Possible values are: `L` or empty string: left align (default value) ;
                `C`: center; `X`: center around current x position; `R`: right align
            fill (bool): Indicates if the cell background must be painted (`True`)
                or transparent (`False`). Default value: False.
            link (str): optional link to add on the cell, internal
                (identifier returned by `FPDF.add_link`) or external URL.
            center (bool): center the cell horizontally on the page.
            markdown (bool): enable minimal markdown-like markup to render part
                of text as bold / italics / underlined. Default to False.
            txt (str): [**DEPRECATED since v2.7.6**] String to print. Default value: empty string.

        Returns: a boolean indicating if page break was triggered
        r  jParameter 'w' and 'h' must be numbers, not strings. You can omit them by passing string content with text=r   r   HInteger values for "border" parameter other than 1 are currently ignoredr   r   zGcell() only produces one text line, justified alignment is not possibler   r   r   "Invalid value for parameter "ln" (z"), must be an int between 0 and 2.=The parameter "ln" is deprecated since v2.5.2. Instead of ln= use new_x=XPos., new_y=YPos.r  F
text_widthnumber_of_spacesalignr  	max_widthtrailing_nl)new_xnew_yr$  r  center)r}   rF   r   r   r  r   r   r   r&   rD   r3  rE   r2   JRIGHTTOPLMARGINNEXTLEFTr  r   r  ro  _preload_bidirectional_text_preload_font_styles_render_styled_text_linerZ   rZ  )r   r7  r<  r   borderlnra  r$  r  rf  r  rd  re  styled_txt_fragss                 r   cellz	FPDF.cell
  s   p  	W UVVVa 	As!3!3 	J   fc"" 	vV';';MZ*,,    FE""E""U##EGY   Qww
q	q		 7 7 7 7   Ma&(a a:?*a aSXS]a a a #*,,    ""4((  ;D,,T8<<<**4:: 	
 ,, !"!&%'!1!1eggu!   ! - 
 
 	
r   	text_liner<  rp  rd  re  r$  r  rf  paddingc
                    t          |t                    r)|dvr%t          j        dt	                                 d}n9t          |t
                    r$t          |                              d          rd}|	t          dddd          }	dx}
}|	j	        dk    r| j
        }
|	j        dk    r| j
        }|j        }|s9t          |j                  D ]$\  }}|                    |dk              }||z  }%|j        }||j        st#          d	          ||
z   |z   }n|dk    r| j        | j        z
  | j        z
  }|r| j        | j        |z
  d
z  z   | _        n(|j        t0          j        k    r| xj        |d
z  z  c_        d}|                                }|D ]}|j        |k    r|j        }||}|                     |          }g }| j        }| j        |	j	        z
  |z  }| j        |z   |	j        z   |z  }| j        | j        z
  |	j         z   |z  }| j        | j        |z   z
  |	j!        z
  |z  }|r8|dk    rdnd}|"                    |dd|dd||z
  dd||z
  dd| 	           n1|dk    r+|"                    |dd|dd||z
  dd||z
  dd           t          |t
                    rd|v r%|"                    |dd|dd|dd|dd           d|v r%|"                    |dd|dd|dd|dd           d|v r%|"                    |dd|dd|dd|dd           d|v r%|"                    |dd|dd|dd|dd           | j#        r"| $                    | j        | j        ||           | j        }dg }}dx}}d} tJ          j&        }!| j'        }"| j(        }#| j)        }$| j*        }%| j+        }&d}'| j,        }(|rO|j        t0          j-        k    r	||
z
  |z
  })n*|j        t0          j.        t0          j        fv r	||z
  d
z  })n|
})||)z  }d}*|j        t0          j/        k    r|j0        r||
z
  |z
  |z
  |j0        z  }*|"                    d| j        |)z   |z  dd| j        | j        z
  d|z  z
  d|z  z
  |z  dd           t          |          D ]\  }}|j1        d         |(k    rH|j1        d         }(|"                    |(2                                3                                           d}'|*r|j*        dk    r|*dz  |j*        z  }n|*}|%|j*        k    r%|j*        }%|"                    |j*        dd           |&|j+        k    r%|j+        }&|"                    |j+        dd            |"|j4        k    s|#|j(        k    s|!|j5        k    rW|!|j5        k    r|j5        }!|#|j(        k    r|j(        }#|j4        }"|"                    d!|j4        j6         d|j(        dd"           |j7        }+|+| k    r|"                    |+dd#           |+} |j)        tp          j9        k    s|j)        |$k    r-|j)        }$|"                    |j)         d$|j:        dd%           |;                    |||*| j        |)z   |z   | j        d|z  d|z  z   z   | j                  },|,r|"                    |,           |                    |dk              |*|j<        =                    d          z  z   }-|j>        r.|"                    | j        |)z   |z   |-|j4        |j        f           |j?        rE| ?                    | j        |)z   |z   | j        d|z  z   d|j        z  z
  |-|j        |j?        &           |j@        s|}||-z  }|"                    d'           |D ]C\  }.}/}0}1|"                    | A                    |.| j        d|z  z   d|1z  z   |/|0                     D|r<| ?                    | j        |)z   | j        d|z  z   d|j        z  z
  ||j        |           |r|dk    sO| dk    sI|!tJ          j&        k    s9|"| j'        k    s.|#| j(        k    s#|$| j)        k    s|'s|%| j*        k    s|&| j+        k    rd(dB                    |           d)}2ndB                    |          }2| C                    |2           |p| j        | _D        |t          jF        k    r| xj        |z  c_        n|t          jG        k    r|| _        n|t          jH        k    r||z   | _        n|t          jI        k    r|r||z   |z
  | _        ng|| _        n_|t          jJ        k    r||d*z  z   | _        nA|t          jK        k    r| j        | _        n$|t          jL        k    r| j        | j        z
  | _        |t          jN        k    r| xj        |z  c_        |t          jO        k    r| jP        | _        |t          jQ        k    r| j        | jR        z
  | _        |S )+aM  
        Prints a cell (rectangular area) with optional borders, background color and
        character string. The upper-left corner of the cell corresponds to the current
        position. The text can be aligned, centered or justified. After the call, the
        current position moves to the requested new position. It is possible to put a
        link on the text.

        If automatic page breaking is enabled and the cell goes beyond the limit, a
        page break is performed before outputting.

        Args:
            text_line (TextLine instance): Contains the (possibly empty) tuple of
                fragments to render.
            h (float): Cell height. Default value: None, meaning an height equal
                to the current font size.
            border: Indicates if borders must be drawn around the cell.
                The value can be either a number (`0`: no border ; `1`: frame)
                or a string containing some or all of the following characters
                (in any order):
                `L`: left ; `T`: top ; `R`: right ; `B`: bottom. Default value: 0.
            new_x (fpdf.enums.XPos): New current position in x after the call.
            new_y (fpdf.enums.YPos): New current position in y after the call.
            fill (bool): Indicates if the cell background must be painted (`True`)
                or transparent (`False`). Default value: False.
            link (str): optional link to add on the cell, internal
                (identifier returned by `FPDF.add_link`) or external URL.
            center (bool): center the cell horizontally on the page.
            padding (Padding or None): optional padding to apply to the cell content.
                If padding for left and right is non-zero then c_margin is ignored.

        Returns: a boolean indicating if page break was triggered
        rX  rY  r   r   LTRBNr   )
initial_cszA'text_line' must have fragments if 'text_line.text_width' is Noner   r  fr  r  r.  z re SrZ  r  r  TRg        Fr  g      ?g333333?r*  r   Tr   z Tzz Tcz/Fz Tfz Tsr+  r  )r   r   r7  r<  r  ETr4  z Qg       @)Sr   r   r   r   r&   r   r  
issupersetrm   rG  r   rI  r_  	enumerate	fragmentsr  rb  r  r7  r8  r   r   r9  ra  r2   Xget_ordered_fragmentsr  _perform_page_break_if_need_ber   r<  r   rH  bottomrb  r  r0  r6   LINEr   r   r   r   r   r   r{  Crg  r`  graphics_stater  r   rv   rL  rj  liftrB   r   r   render_pdf_text
characterscountr   r  r-  r/  r  r  r   rD   rh  STARTENDWCONTCENTERrj  RMARGINrE   rk  TMARGINr   BMARGINr   )3r   rt  r<  rp  rd  re  r$  r  rf  ru  
l_c_margin
r_c_marginstyled_txt_widthrj  r  unscaled_widthr7  max_font_sizer  page_break_triggeredr1  r   rG  rI  rH  r  ops_starts_width
underlines
current_wsfrag_wscurrent_liftcurrent_char_vposr   current_font_size_ptcurrent_text_modecurrent_font_stretchingcurrent_char_spacingfill_color_changedlast_used_colordxword_spacingr  r_text
frag_widthstart_xul_wul_fontul_font_sizer  s3                                                      r   ro  zFPDF._render_styled_text_lineD  s>   X fc"" 	vV';';MZ*,,    FF$$ 	V)?)?)G)G 	F?aAq))G"##
Z<1J=AJ$/ 	3$Y%899 3 34!%16!B!B N2  9&  W   !:-
:AA!VV&/A 	]dhla%77DFF_''FFa!eOFF3355	 	/ 	/D~-- $9A#BB1EEF %*!gm+q0v,1&DFQJ''.8A= 	V!BIIWWWCWWWeDjWWWvczWWWSUWWXXXXq[[IITTTCTTTeDjTTTvczTTTTUUU fc"" 	Uf}}		TOOOOOODOOOvOOOOPPPf}}		TMMMMMMEMMMMMMMNNNf}}		UQQQQQQUQQQQQQQRRRf}}		TSSSSSSuSSS6SSSSTTT( 	8!!$&$&!Q777&""
W$M(#0 N"&"6#0"/ n	%'))^&66UWeg$666**a/rMGL%'))i.H)
NZ/2BB. / IIRtv{a'. R RFTVOcAg-m0CCqHQR R R   %Y// I& I&4&|4GG&*&9,&GOIIo7799??AABBB)-& +D$8C$?$?*S043GGGG*G*d.BBB.2.B+II!5>>>>???'4+<<<+/+<(II!2;;;;<<< DI--+t/@@@(DN::(DN::,0N)+t/@@@/3/@,#'9LIIK49;KK1BKKKKLLLy<''II....///#'LNhm33~):::(,%IILLT_LLLLMMM-- FRK')FcAgm(;;<F   &IIf%%%!^^ Av ,   4?#8#8#=#==>
 > %% FRK'1& I N	   9 II&2+/&C!G,dn0DE$.!Y     ' )!(J:%IIdOOO8B  4w		&&#'*cL.@A	      		FRKFcAg&#*>?$N    	
 c!!3&&$554#444'4+<<<$66% 7*d.BBB'4+<<<)")))HHRLLIIaLLL )4> DJFFaKFFFdj  DFFdhw&DFFdj   ! 7*Z7 dk!!w},DFFdl""]DFFdl""Vdm+DF DIFFaKFFDL  ]DFDL  Vdm+DF##r   c                 8   | j         | j                                     || j        z  | j        |z
  | j        z  ||z   | j        z  | j        |z
  | j        z  || j        z  | j        |z
  |z
  | j        z  ||z   | j        z  | j        |z
  |z
  | j        z  g           d S r%  )r  r   extendr   r<  r   r   r   r7  r<  s        r   r0  zFPDF._add_quad_pointsp  s    ty)00DF
!tv%Q$& !tv%DF
!a46)Q$& !a46)		
 	
 	
 	
 	
r   c                 n   | j         s|                     ||          S | j         d         r| j         d         nt          |          }t          ||          }|                                }|j        | j         d<   g }|D ](\  }}|| j         d<   ||                     ||          z  })t          |          S )zh "
        Break the text into bidirectional segments and preload font styles for each fragment
        rg  )r   base_directionrl  rk  )ro  rn  r$   r#   get_bidi_fragmentsr  r   )	r   r   r  rl  	paragraphdirectional_segmentsr  	bidi_textbidi_directions	            r   rm  z FPDF._preload_bidirectional_text~  s       	=,,T8<<<  -2Dk**+D11 	 "t<OPPP	(;;==3<3K/0	)= 	H 	H%I~6DD23229hGGGIIYr   c                    |st                      S | j        }| j        r|dz  }t          |                     ||                    }|r| j        }d| _        t          d |D                       r|                     d           t          d |D                       r|                     d           t          d |D                       r|                     d	           t          d
 |D                       r|                     d           |D ]!}| j        |j        |j        z            |_	        "|                     |           || _        |S )aS  
        When Markdown styling is enabled, we require secondary fonts
        to ender text in bold & italics.
        This function ensure that those fonts are available.
        It needs to perform Markdown parsing,
        so we return the resulting `styled_txt_frags` tuple
        to avoid repeating this processing later on.
        r   r   c              3   ,   K   | ]}|j         d k    V  dS )r  Nr~   r5  r  s     r   r7  z,FPDF._preload_font_styles.<locals>.<genexpr>  )      GGd4?c)GGGGGGr   r  r  c              3   ,   K   | ]}|j         d k    V  dS )r  Nr  r  s     r   r7  z,FPDF._preload_font_styles.<locals>.<genexpr>  r  r   r  c              3   ,   K   | ]}|j         d k    V  dS r  r  r  s     r   r7  z,FPDF._preload_font_styles.<locals>.<genexpr>  s)      HHt4?d*HHHHHHr   r  c              3   ,   K   | ]}|j         d k    V  dS )r   Nr  r  s     r   r7  z,FPDF._preload_font_styles.<locals>.<genexpr>  s)      FFT4?b(FFFFFFr   r   )
r   r~   r   r  r   r  r  r   r}   rv   )r   r   r  prev_font_stylerr  r   r  s          r   rn  zFPDF._preload_font_styles  s     	77N/> 	#s"O !2!24!B!BCC 	9D DIGG6FGGGGG )C(((GG6FGGGGG )C(((HH7GHHHHH *D)))FF5EFFFFF (B'''( K K Jt'7$/'IJ		MMM000DIr   c                      t          j        |           fd j        D             }|sdS t           fd|D             d          }|r|S  j        rdS |d         S )z
        Returns which fallback font has the requested glyph.
        This method can be overriden to provide more control than the `select_mode` parameter
        of `FPDF.set_fallback_fonts()` provides.
        c                 V    g | ]%}t                    j        |         j        v #|&S r   )ordr   cmap)r5  font_idcharr   s     r   
<listcomp>z*FPDF.get_fallback_font.<locals>.<listcomp>  s>     
 
 
4yyDJw/444 444r   Nc              3   H   K   | ]}j         |         j        k    |V  d S r%  )r   emphasis)r5  rv   r  r   s     r   r7  z)FPDF.get_fallback_font.<locals>.<genexpr>  s7      WWdD1A1Jh1V1VT1V1V1V1VWWr   r   )r@   r3  r  nextr  )r   r  r  fonts_with_charfont_with_matching_emphasisr  s   ``   @r   get_fallback_fontzFPDF.get_fallback_font  s      &u--
 
 
 
 
2
 
 

  	4&*WWWWWoWWW'
 '
# ' 	/..* 	4q!!r   r   r  returnc              #   <   K   |s: j         r j        s,t          |                                  j                  V  dS g d j        v d j        v t           j                  f\  d fd} j         r j        j	        }ng }|rw|dd          j
         j         j        fv }|d         }|r[|rrd         |k    rzt          |          dk     s|d         |k    r[r |            V  |dd          j
        k    r |dd          j        k    r |dd          j        k    r |dd         } j                            |          }|r|                                \  }}	}r |            V                                   }
 j        |
d	<    j        r
 j        |
d
<   	 t'          |	          }                     |          }	n# t*          $ r Y nw xY wt          t-          |          |
 j        |	          V   j         r|d         dk    rt/          |d                   |vrrdndrdndz   }                     |d         |          }|rd|k    r'                    |d                    |dd         }	r |            V  |                    |d                    |dd         }@rr |            V  d                    |d                    |dd         }|wr |            V  dS dS )zSplit text into fragmentsNr  r  c                  :                                    } rdndrdndz   | d<   | d<   rVd                    d D                       | d<   d                    d D                       | d<   j                 | d	<   d t          | j                  }g |S )
Nr  r   r  r~   r   c              3   B   K   | ]}|                                 |V  d S r%  )islowerr5  r:  s     r   r7  z2FPDF._parse_chars.<locals>.frag.<locals>.<genexpr>  sC       0 0		00 0 0 0 0 0r   r}   c              3   B   K   | ]}|                                 |V  d S r%  )isupperr  s     r   r7  z2FPDF._parse_chars.<locals>.frag.<locals>.<genexpr>  sC       / /		// / / / / /r   r   )_get_current_graphics_stater  r   rX   r   )gstatefragmentcurrent_fallback_fontin_bold
in_italicsin_underliner   txt_frags     r   r  zFPDF._parse_chars.<locals>.frag  s    5577F+2$:CC!)r$F<  #/F;$ -(* 0 040 0 0 ) )}% (*ww / /4/ / / ( (|$ *.4I)J~&(,% H
 HOr   r   r   r   r9  r   r   r  )r  
r   r   )r-  r  rX   r  r   r~   r   r   r   r  MARKDOWN_BOLD_MARKERMARKDOWN_ITALICS_MARKERMARKDOWN_UNDERLINE_MARKERr?  MARKDOWN_LINK_REGEXmatchgroupsMARKDOWN_LINK_UNDERLINEMARKDOWN_LINK_COLORr   r  r  r  r  r  rb  )r   r   r  r  font_glyphs	is_markerhalf_markeris_link	link_text	link_destr  r   r  r  r  r  r  r  r  s   `             @@@@@r   r  zFPDF._parse_chars  s:      	!1 	9P 	4!A!A!C!CTVLLLLLF4?"4?"  	7
3':| !%	 	 	 	 	 	 	 	 	 	0  	+0KKK @	RaR),.% I
 q'K $%)1")D)DTQ$q'[*@*@ %"dffBQBx4#<<<&-+BQBx4#???)3^
BQBx4#AAA+7'78D288>> 181A1A.Iy$ %"dff!==??F*.*FF;'/ H/3/G|,"9~~$(MMtM$<$<		%   "Y&	       DGtOOCQLLK<W<W '/R:4MCC2N $ 6 6tAw F F  
$(=== Q000#ABBx  %"dff,9)OODG,,,8D$ - !$&&LLL(,%OODG$$$8DA  @	B  	$&&LLLLL	 	s   :%G   
G-,G-c                 f    | j         | j        k    o!| j         |z   | j        k    o| j         o| j        S )a8  
        Let you know if adding an element will trigger a page break,
        based on its height and the current ordinate (`y` position).

        Args:
            height (float): height of the section that would be added, e.g. a cell

        Returns: a boolean indicating if a page break would occur
        )r   r   rQ  r   rU  )r   r  s     r   will_page_breakzFPDF.will_page_breakA  sE     FT]" '$"99'N"' &	
r   c                     |                      |          rCt                              d| j        | j        || j                   |                                  dS dS )Nz;Page break on page %d at y=%d for element of height %d > %dTF)r  LOGGERdebugr   r   rQ  _perform_page_breakr   r<  s     r   r  z#FPDF._perform_page_break_if_need_beS  sb    "" 		LLM	'   $$&&&4ur   c                 N    | j         }|                     d           || _         d S )NTr  )r   r  r   r   s     r   r  zFPDF._perform_page_break`  s(    F4   r   c                 "    | j         | j        k    S r%  )r@  r   r,  s    r   r  zFPDF._has_next_pagee  s    $)++r   c              #     K   t          | j        t          j                  sd V  d S d | _        | j        | j        | j        | j        f\  }}}}t          | j	        | j                 j
                  }|                                  	 d V  |                                  t          |dz   | j        dz             D ]
}| j	        |= || _        || j	        | j                 _
        |                     ||           | `d S # |                                  t          |dz   | j        dz             D ]
}| j	        |= || _        || j	        | j                 _
        |                     ||           | `w xY w)Nc                      d S r%  r   r   r   s     r   <lambda>z'FPDF._disable_writing.<locals>.<lambda>o  s    D r   r   )r   r  types
MethodTyper   r@  r   r   rf   r   r  rM  rQ  r^  set_xy)r   	prev_pageprev_pages_countprev_xprev_yr  rW  s          r   _disable_writingzFPDF._disable_writingh  s     $)U%566 	 EEEF00	IFF	7
3	#VV $*TY/677   	EEE!!###+a/1AA1EFF " "JqMM!DI+1DJty!(KK'''			 !!###+a/1AA1EFF " "JqMM!DI+1DJty!(KK'''	MMMMs   C> >A2E0wrapmodec                 L   t          j        |          }t          j        |          }|r(t	          j        dt          t                                 |s|rb|                                 5  | 	                    ||||||||	|
|||||dd|rt          j        n|||          cddd           S # 1 swxY w Y   | j        st          d          t          |t                    st          |t                    rt!          d          t#          j        |          }t%          j        |          }|	dk    r|	d	k    rt"          j        }t$          j        }np|	d
k    rt"          j        }t$          j        }nQ|	dk    rt"          j        }t$          j        }n2|	dk    rt"          j        }t$          j        }nt!          d|	 d          t	          j        d|	 d|j         d|j         dt          t                                 t3          j        |          }d}|| j        }|d	k    r| j        | j        z
  | j        z
  }| j        | j        }}||j        z
  |j         z
  x}}g }|j         s|!                    | j"                   |j        s|!                    | j"                   |t2          j#        k    r| xj        |j         z  c_        | xj        |j$        z  c_        |r;|t2          j#        k    r
| j        dz  n| j%        | j&        |z
  dz  z   | _        | j        }| '                    |          }|(                    dd          }| j)        r| *                    ||          n| +                    ||          }| j,        | j-        }}d	}g }t]          ||||||          }|/                                } | +|!                    |            |/                                } | +|sta          dd	d	|||d          g}|
tc          |          d
k    r|}!nte          ||
          }!|p|}"d}tg          |          D ]\  }#} | 4                    ||j5        z             }$|$r;d}| j        }%| 6                    d           |%| _        | xj        |j$        z  c_        |"r|#d	k    s|$r| j        |j$        z   }&|j5        | j7        z   }'tq          | j9        |&z
  |'z
  |!z            }(te          |(tc          |          |#z
            })tu          ||#|!z  z
  |)|!z            }*| j        |t2          j#        k    r|dz  nd	z
  }%tw          | |%|j         z
  | j        |j$        z
  |%|z   |j        z   | j        |*z   |j5        z   ||r| j<        nd           |#tc          |          d
z
  k    }+| =                    | |!|+r|nt"          j        |+r|nt$          j        d	d|t          d	|j        d	|j                              ||!z  }|+s|t2          j#        k    r|| _        ||k     r%|t$          j        k    r| xj        ||z
  z  c_        |}|r|t$          j        k    r| j        }|d         },|,r5|,j>        r.|t$          j?        t$          j        fv r| @                                 |t$          j        k    r|| _        n%|t$          j        k    r| xj        |j5        z  c_        |r8| j,        |k    r&|| _,        | jA        | j        | j,        z            | _B        || _-        |t"          j        k    r| xj        |j        z  c_        n%|t"          j        k    r| xj        |j         z  c_        t          j        |          }d}-|t          jC        z  r|-|fz  }-|t          j        z  r[g }.|D ]P} g }/| jD        D ]}0|/E                    |0jF                   |.!                    dG                    |/                     Q|-|.fz  }-|t          jH        z  r|-||j$        z   |j5        z   fz  }-tc          |-          d
k    r|-d	         S |-S )a   
        This method allows printing text with line breaks. They can be automatic
        (breaking at the most recent space or soft-hyphen character) as soon as the text
        reaches the right border of the cell, or explicit (via the `\n` character).
        As many cells as necessary are stacked, one below the other.
        Text can be aligned, centered or justified. The cell block can be framed and
        the background painted. A cell has an horizontal padding, on the left & right sides,
        defined by the.c_margin property.

        Args:
            w (float): cell width. If 0, they extend up to the right margin of the page.
            h (float): height of a single line of text.  Default value: None, meaning to use the current font size.
            text (str): string to print.
            border: Indicates if borders must be drawn around the cell.
                The value can be either a number (`0`: no border ; `1`: frame)
                or a string containing some or all of the following characters
                (in any order):
                `L`: left ; `T`: top ; `R`: right ; `B`: bottom. Default value: 0.
            align (fpdf.enums.Align, str): Set text alignment inside the cell.
                Possible values are:
                `J`: justify (default value); `L` or empty string: left align;
                `C`: center; `X`: center around current x position; `R`: right align
            fill (bool): Indicates if the cell background must be painted (`True`)
                or transparent (`False`). Default value: False.
            split_only (bool): **DEPRECATED since 2.7.4**:
                Use `dry_run=True` and `output=("LINES",)` instead.
            link (str): optional link to add on the cell, internal
                (identifier returned by `add_link`) or external URL.
            new_x (fpdf.enums.XPos, str): New current position in x after the call. Default: RIGHT
            new_y (fpdf.enums.YPos, str): New current position in y after the call. Default: NEXT
            ln (int): **DEPRECATED since 2.5.1**: Use `new_x` and `new_y` instead.
            max_line_height (float): optional maximum height of each sub-cell generated
            markdown (bool): enable minimal markdown-like markup to render part
                of text as bold / italics / underlined. Default to False.
            print_sh (bool): Treat a soft-hyphen (\u00ad) as a normal printable
                character, instead of a line breaking opportunity. Default value: False
            wrapmode (fpdf.enums.WrapMode): "WORD" for word based line wrapping (default),
                "CHAR" for character based line wrapping.
            dry_run (bool): if `True`, does not output anything in the document.
                Can be useful when combined with `output`.
            output (fpdf.enums.MethodReturnValue): defines what this method returns.
                If several enum values are joined, the result will be a tuple.
            txt (str): [**DEPRECATED since v2.7.6**] string to print.
            center (bool): center the cell horizontally on the page.
            padding (float or Sequence): padding to apply around the text. Default value: 0.
                When one value is specified, it applies the same padding to all four sides.
                When two values are specified, the first padding applies to the top and bottom, the second to
                the left and right. When three values are specified, the first padding applies to the top,
                the second to the right and left, the third to the bottom. When four values are specified,
                the paddings apply to the top, right, bottom, and left in that order (clockwise)
                If padding for left or right ends up being non-zero then respective c_margin is ignored.

        Center overrides values for horizontal padding

        Using `new_x=XPos.RIGHT, new_y=XPos.TOP, maximum height=pdf.font_size` is
        useful to build tables with multiline text in cells.

        Returns: a single value or a tuple, depending on the `output` parameter value
        zcThe parameter "split_only" is deprecated since v2.7.4. Use instead dry_run=True and output="LINES".r   F)r7  r<  r   rp  ra  r$  r  rq  max_line_heightr  print_shrd  re  r  r   r   outputrf  ru  Nr  rW  r   r   r   r   r9  rZ  z"), must be an int between 0 and 3.r[  r\  r]  r  r   )ra  r  r  r^  Tr  )r<  rd  re  rp  r$  r  ru  r   r   )Irm   newrC   r3  r   r   r   r&   r  
multi_cellr:   LINESr}   rF   r   r   r  rD   rE   rh  rk  rj  rl  ri  r  r2   r  r7  r8  r   r   rI  rG  rb  r   r  rH  r   r9  r  r  ro  rm  rn  r~   r   rY   get_linerZ   r?  rB  r~  r  r  r  r   r   r<  r&  ri   r   ro  rc  LASTrq  r   r   
PAGE_BREAKr  r  r  r  HEIGHT)1r   r7  r<  r   rp  ra  r$  r   r  rq  r  r  r  rd  re  r  r   r  rf  ru  r  r  r  maximum_allowed_widthclearance_marginsnormalized_stringstyled_text_fragmentsr  prev_underlinetotal_height
text_linesmulti_line_breakrt  line_heightbox_requiredtext_line_indexpage_break_requiredr   top_gap
bottom_gaplines_before_break	num_lines
box_heightis_last_line	last_linereturn_valueoutput_linesr  r  s1                                                    r   r  zFPDF.multi_cell  s	   h +g&&?8,, 	MD #*,,     	j 	&&((  !$3%%%!$6@L,22f!#' '                 ,  	W UVVVa 	As!3!3 	J   E""E""Qww
	q	q		q
 7 7 7 7   Ma&(a a:?*a aSXS]a a a #*,,    U##$9A 66&/A 
 %&$5$DD| 	4$$T]333} 	4$$T]333EGFFgl"FF'+  	#uw..

DMTXPQ\UVDV4V F VF ""4(( LLr22  HD,,->III**+<hGG 	 +//4>
)!!
 
 
 %--//	%i((((1133I %  	 %& %  
J "c*oo&:&:KKa11K~v$*3J*?*? ,	  ,	 &OY"&"6"6q7>7I"J"J" &'+$F4((('+% A!5!59L!5&7;.$^dm;
%($&7*:Z*GK)W%X%X" 2C
OOo4UVV	 +55y;7N 
 Fu'7'7a!eeQ? $FW[(EGM)FZ''.8'+5DOO   +c*oo.AAL))+:ee+:ee7=!W\BB * 	 	 	 K'L  EUW$4$4!	!!!l**L 	ETX$5$5 VFrN	 	. 	5TY	<R3R3RGGIIIDHDFFdiFFgn$FF 	,/11"1$(Jt/?$//Q$R!+DNDJFFgm#FFFdiFFgl"FF")&11%00 	4133L%++ 	,L' 9 9	
%/ 7 7D%%do6666##BGGJ$7$78888\O+L%,, 	K\GK7'.HJJL|!!?"s   +6B..B25B2r  c           
         t          j        |          }| j        st          d          t	          |t
                    rt          d          || j        }d}|                     |          	                    dd          }| j
        r|                     |d          n|                     |d          }g }	t          |fd| j        | j        f||          }
| j        | j        z
  | j        z
  }||
                                }| j        | j        z
  | j        z
  }||+|	                    |           |
                                }|+|	sdS t+          |	          D ]S\  }}|d	k    r|                                  |                     ||d	t0          j        t4          j        d|
          }|p|}T|j        r|                                  |S )a  
        Prints text from the current position.
        When the right margin is reached, a line break occurs at the most recent
        space or soft-hyphen character, and text continues from the left margin.
        A manual break happens any time the \n character is met,
        Upon method exit, the current position is left just at the end of the text.

        Args:
            h (float): line height. Default value: None, meaning to use the current font size.
            text (str): text content
            link (str): optional link to add on the text, internal
                (identifier returned by `FPDF.add_link`) or external URL.
            print_sh (bool): Treat a soft-hyphen (\u00ad) as a normal printable
                character, instead of a line breaking opportunity. Default value: False
            wrapmode (fpdf.enums.WrapMode): "WORD" for word based line wrapping (default),
                "CHAR" for character based line wrapping.
            txt (str): [**DEPRECATED since v2.7.6**] text content
        r  zbParameter 'h' must be a number, not a string. You can omit it by passing string content with text=NFr	  r   c                     S r%  r   )r<  rb  s    r   r  zFPDF.write.<locals>.<lambda>  s    i r   )r  r  r   )r<  rp  rd  re  r$  r  )rC   r3  r}   rF   r   r   r  r  r  r  ro  rm  rn  rY   r   r7  r   r8  r  r   rb  r~  rq  ro  rD   r  rE   ri  rc  )r   r<  r   r  r  r  r  r  r  r  r  first_widthrt  
full_widthr  r  rb  s                   @r   writez
FPDF.write  s*   8 ?8,, 	W UVVVa 	H   9A$ //55==dBGG  ED,,->FFF**+<eDD 	 
)!]DM*
 
 
 ftvo5	$--//	Vdm+dm;
	%i((((1133I %  	5*3J*?*? 	D 	D&OY""			44jh 5  H $8#C8    	GGIII##r   
   rl  imgimg_fill_widthncolsgutterbalance
text_alignr  r   r8  skip_leading_spacesc                 <    t          | |||||||||	|
|||          S )a  Establish a layout with multiple columns to fill with text.
        Args:
            text (str, optional): A first piece of text to insert.
            ncols (int, optional): the number of columns to create. (Default: 1).
            gutter (float, optional): The distance between the columns. (Default: 10).
            balance: (bool, optional): Specify whether multiple columns should end at approximately
                the same height, if they don't fill the page. (Default: False)
            text_align (Align or str, optional): The alignment of the text within the region.
                (Default: "LEFT")
            line_height (float, optional): A multiplier relative to the font size changing the
                vertical space occupied by a line of text. (Default: 1.0).
            l_margin (float, optional): Override the current left page margin.
            r_margin (float, optional): Override the current right page margin.
            print_sh (bool, optional): Treat a soft-hyphen (\u00ad) as a printable character,
                instead of a line breaking opportunity. (Default: False)
            wrapmode (fpdf.enums.WrapMode, optional): "WORD" for word based line wrapping,
                "CHAR" for character based line wrapping. (Default: "WORD")
            skip_leading_spaces (bool, optional): On each line, any space characters at the
                beginning will be skipped if True. (Default: False)
        )r   r,  r-  r.  r/  r0  r1  r  r   r8  r  r  r2  )rk   )r   r   r,  r-  r.  r/  r0  r1  r  r   r8  r  r  r2  s                 r   text_columnszFPDF.text_columns)  sF    J )!# 3
 
 
 	
r   c                 0   |r(t          j        dt          t                                 t	          | j        ||
          \  }}}t          |t                    r|                     |||||||||	|
  
        S | 	                    ||||||||||	|
|          S )af  
        Put an image on the page.

        The size of the image on the page can be specified in different ways:
        * explicit width and height (expressed in user units)
        * one explicit dimension, the other being calculated automatically
          in order to keep the original proportions
        * no explicit dimension, in which case the image is put at 72 dpi.
        * explicit width and height (expressed in user units) and `keep_aspect_ratio=True`

        **Remarks**:
        * if an image is used several times, only one copy is embedded in the file.
        * when using an animated GIF, only the first frame is used.

        Args:
            name: either a string representing a file path to an image, an URL to an image,
                bytes, an io.BytesIO, or a instance of `PIL.Image.Image`
            x (float, fpdf.enums.Align): optional horizontal position where to put the image on the page.
                If not specified or equal to None, the current abscissa is used.
                `Align.C` can also be passed to center the image horizontally;
                and `Align.R` to place it along the right page margin
            y (float): optional vertical position where to put the image on the page.
                If not specified or equal to None, the current ordinate is used.
                After the call, the current ordinate is moved to the bottom of the image
            w (float): optional width of the image. If not specified or equal to zero,
                it is automatically calculated from the image size.
                Pass `pdf.epw` to scale horizontally to the full page width.
            h (float): optional height of the image. If not specified or equal to zero,
                it is automatically calculated from the image size.
                Pass `pdf.eph` to scale horizontally to the full page height.
            type (str): [**DEPRECATED since 2.2.0**] unused, will be removed in a later version.
            link (str): optional link to add on the image, internal
                (identifier returned by `FPDF.add_link`) or external URL.
            title (str): optional. Currently, never seem rendered by PDF readers.
            alt_text (str): optional alternative text describing the image,
                for accessibility purposes. Displayed by some PDF readers on hover.
            dims (Tuple[float]): optional dimensions as a tuple (width, height) to resize the image
                before storing it in the PDF. Note that those are the **intrinsic** image dimensions,
                but the image will still be rendered on the page with the width (`w`) and height (`h`)
                provided as parameters. Note also that the `.oversized_images` attribute of FPDF
                provides an automated way to auto-adjust those intrinsic image dimensions.
            keep_aspect_ratio (bool): ensure the image fits in the rectangle defined by `x`, `y`, `w` & `h`
                while preserving its original aspect ratio. Defaults to False.
                Only meaningful if both `w` & `h` are provided.

        Returns: an instance of a subclass of `ImageInfo`.
        zL"type" parameter is deprecated since v2.2.0, unused and will soon be removedr   )
r   r   r   r&   rV   r   r   rR   _vector_image_raster_image)r   r  r   r   r7  r<  r+  r  r~  r  dimskeep_aspect_ratior,  infos                 r   r  z
FPDF.image_  s    |  	M6 #*,,    ((8$EEc4dO,, 	%%T1aAtUH>O   !!
 
 	
r   r:  c           
         d|v r|                      d           |                    ||| j                  \  }}| j        r.|d         dk    r"|s |                     |||||| j                  }|,|                     |           | j        }| xj        |z  c_        || j        }t          |t                    s|
                    ||| |          }t          ||||||| j        | j                  }|	s|
rE|                     |	|
          5  |                     |           d d d            n# 1 swxY w Y   n|                     |           |r|                     |||||           t!          d	i |||dS )
Nsmaskr  )scaleusagesr   )r=  pdf_height_to_flipr~  r  rendered_widthrendered_heightr   )r(  size_in_document_unitsr   r   _downscale_imager  r   r   r   r
   
x_by_alignr_   r<  _marked_sequencer  r  rQ   )r   r  r,  r:  r   r   r7  r<  r  r~  r  r8  r9  stream_contents                 r   r7  zFPDF._raster_image  s     d??%%e,,, **1atv*>>1  	NT(^q%8%8%8((sD!Qdf(MMD 9//222AFFaKFF9A!V$$ 	?1d,=>>A8!Q1/tvRVRX
 
 
  	&H 	&&&UX&FF * *		.)))* * * * * * * * * * * * * * * IIn%%% 	(IIaAq$'''KKKaKKKKKs   D11D58D5svgc                    |j         sE|j        r>|j        r7t          j        dt                                 dd|j        |j        f|_         |dk    r|dk    r|j        rn|j        rgt          |j        t                    r|j        | j        z  dz  n|j        }t          |j        t                    r|j        | j	        z  dz  n|j        }n|j         r|j         \  }}}}nrt          d          |dk    s|dk    rW|j        r|j        r|j        |j        }}n#|j         r|j         \  }}}}nt          d          |dk    r	||z  |z  }n||z  |z  }|,|                     |           | j        }| xj        |z  c_        || j        }t          |t                    s|                    ||| |
          }|
r|                    ||||          \  }}}}|                    d||d          \  }}}|j        t'          j        ||          z  |_        | j        | j        }}	 |                     dd           |s|	rE|                     ||		          5  |                     |           d d d            n# 1 swxY w Y   n|                     |           |                     ||           n# |                     ||           w xY w|r|                     |||||           t3          ||
          S )NzI<svg> has no "viewBox", using its "width" & "height" as default "viewBox"r   r   r   zY<svg> has no "viewBox" nor "height" / "width": w= and h= must be provided to FPDF.image()r   T)r=  r  r  ignore_svg_top_attrsr@  rA  )viewboxr  r  r   r   r&   r   rc   r9  r=  r  r  r   r   r
   rF  scale_inside_boxtransform_to_rect_viewport	transformr/   translationr  rG  r  r  rR   )r   rI  r:  r   r   r7  r<  r  r~  r  r9  _	svg_width
svg_heightr	  old_xold_ys                    r   r6  zFPDF._vector_image  s    { 	6sy 	6SZ 	6M[*,,    Q	3:5CK66a1ffy SZ  "#)W55#CI(3..  "#*g66$CJ)C// 
   [
1a o   !VVqAvvy SZ (+	3::		 .1k+1i o   Avv	MJ.
NY. 9//222AFFaKFF9A!V$$ 	?1d,=>>A 	;..q!Q::JAq!Q331QT 4 
 

1d )*?1*E*EEvtvu
	&KK1 % % ***JJ ) )NN4((() ) ) ) ) ) ) ) ) ) ) ) ) ) ) t$$$KKu%%%%DKKu%%%% 	(IIaAq$'''aCCCCs0   %1J0 I8,J0 8I<<J0 ?I< J0 0Kc           	      
   | j         j        }||z  ||z  }	}d| }
|                    |
          }|d         || j        z  k    r!|d         |	| j        z  k    rt	          |d         |z  |d         |	z            | j        z  }| j                                                            d          r.t          	                    d||d         |d         ||	|           n| j                                        dk    rSt          || j        z            t          |	| j        z            f}|dxx         dz  cc<   |r|}|d         |d         z  |d	         |d         z  k     ra|                    t          ||pt          |          | j         j        |                     t                              d
|
|d         |           |dxx         dz  cc<   nt!          t          ||pt          |          | j         j        |                    }t#          |          dz   |d<   d|d<   |||
<   t                              d|
||d                    n3t%          d| j                   |r|                    |           ||= |}|S )Nzlowres-r7  r<  r   zOVERSIZED: Image %s with size %.1fx%.1fpx is rendered at size %.1fx%.1fpt. Set pdf.oversized_images = 'DOWNSCALE' to reduce embedded image size by a factor %.1f	downscaler>  r   r   z>OVERSIZED: Updated low-res image with name=%s id=%d to dims=%srj  zAOVERSIZED: Generated new low-res image with name=%s dims=%s id=%dz/Invalid value for attribute .oversized_images: )r   imagesr   r   rB  r   r   
startswithr  warningroundr  rT   rU   r  r  rQ   r?  r  )r   r  r,  r:  r7  r<  r=  rX  width_in_ptheight_in_ptlowres_namelowres_infofactorr8  s                 r   rE  zFPDF._downscale_imageB  s   !($%Iq5y\&&&jj--Id&AAAAS	L4+FFFF DI+T#Y-EFF-.  $**,,77?? ;q II     &,,..+==+(CCDD,)DDEE X!# $&DCy49,tAwa/@@@( $ # 7z$'7'7 $ 0 = $	    \' I 	   NNNa'NNNN*$ 3:d#3#3 ,9 	  D !$FaDI%&DN*.F;'LL[#S		    !]dF[]]    	t$$$tDr   c                 ~    t          j        dt          t                                 t	          | j        ||          S )z
        Read an image and load it into memory.

        .. deprecated:: 2.7.7
            Use `fpdf.image_parsing.preload_image` instead.
        zFPDF.preload_image() is deprecated since v2.7.7 and will be removed in a future release. Use `fpdf.image_parsing.preload_image` instead.r   )r   r   r   r&   rV   r   )r   r  r8  s      r   rV   zFPDF.preload_image  sH     	B &((	
 	
 	
 	
 T-tT:::r   c              +     K   | j                             | j                  } | j        dd|d|}| j        }|                     d| d           |V  | j        |k    rt          d          |                     d           dS )	
        Can receive as named arguments any of the entries described in section 14.7.2 'Structure Hierarchy'
        of the PDF spec: iD, a, c, r, lang, e, actualText
        z/Figure)r  mcidz/P <</MCID z>> BDCz,A page jump occured inside a marked sequenceEMCNr   )r   next_mcid_for_pager   r  r  rF   )r   r   rd  struct_elemr   s        r   rG  zFPDF._marked_sequence  s       "55di@@.d. 
!
 
06
 
 Y
		,,,,---9
"" NOOO		%r   c                      | j         j        dd| j        i|\  }}|| j        | j                 _        |                     d           |S )rc  r  r  r   )r   add_marked_contentr   r   struct_parentsr(  )r   r   rg  spids       r   r  zFPDF._add_marked_content  se    
 CD/B 
 
	
%+
 
T 04
49,!!%(((r   c                     | j         | _        |r| xj        |z  c_        dS | j        r| xj        | j        z  c_        dS | xj        | j        z  c_        dS )a  
        Line Feed.
        The current abscissa goes back to the left margin and the ordinate increases by
        the amount passed as parameter.

        Args:
            h (float): The height of the break.
                By default, the value equals the height of the last printed text line
                (except when written by `.text()`). If no text has been written yet to
                the document, then the current font height is used.
        N)r   r   r   r   r  r  s     r   rq  zFPDF.ln  s^      	%FFaKFFFF[ 	%FFdk!FFFFFFdn$FFFFr   c                     | j         S )z-Returns the abscissa of the current position.)r   r,  s    r   get_xz
FPDF.get_x  s	    vr   c                 4    |dk    r|n	| j         |z   | _        dS )z
        Defines the abscissa of the current position.
        If the value provided is negative, it is relative to the right of the page.

        Args:
            x (float): the new current abscissa
        r   N)r7  r   r  s     r   set_xz
FPDF.set_x  s!     1ff$&1*r   c                 <    | j         rt          d          | j        S )z-Returns the ordinate of the current position.z?Using get_y() inside an unbreakable() code block is error-prone)r   rF   r   r,  s    r   get_yz
FPDF.get_y  s+     	Q   vr   c                 L    | j         | _        |dk    r|n	| j        |z   | _        dS )z
        Moves the current abscissa back to the left margin and sets the ordinate.
        If the value provided is negative, it is relative to the bottom of the page.

        Args:
            y (float): the new current ordinate
        r   N)r   r   r<  r   )r   r   s     r   set_yz
FPDF.set_y  s*     1ff$&1*r   c                 Z    |                      |           |                     |           dS )a,  
        Defines the abscissa and ordinate of the current position.
        If the values provided are negative, they are relative respectively to the right and bottom of the page.

        Args:
            x (float): the new current abscissa
            y (float): the new current ordinate
        N)rt  rp  )r   r   r   s      r   r  zFPDF.set_xy  s&     	

1

1r   c                    | j         sw| j        rp	 |                    | j                                      d          S # t          $ r5}t          |j        ||j                 | j        | j        z             |d}~ww xY w|S )z7Check that text input is in the correct format/encodingr   )
text_index	character	font_nameN)	r-  r   encodedecodeUnicodeEncodeErrorrH   startr}   r~   )r   r   errors      r   r  zFPDF.normalize_text  s      	D$< 	{{4#;<<CCINNN%   2${"5;/".@   	 s   ,= 
A<0A77A<sha256c	                    t           st          d          t          |d          5 }	t          j        |	                                |          \  }
}}ddd           n# 1 swxY w Y   |                     |
||||||||	  	         dS )aE  
        Args:
            pkcs_filepath (str): file path to a .pfx or .p12 PKCS12,
                in the binary format described by RFC 7292
            password (bytes-like): the password to use to decrypt the data.
                `None` if the PKCS12 is not encrypted.
            hashalgo (str): hashing algorithm used, passed to `hashlib.new`
            contact_info (str): optional information provided by the signer to enable
                a recipient to contact the signer to verify the signature
            location (str): optional CPU host name or physical location of the signing
            signing_time (datetime): optional time of signing
            reason (str): optional signing reason
            flags (Tuple[fpdf.enums.AnnotationFlag], Tuple[str]): optional list of flags defining annotation properties
        Pendesive.signer not available - PDF cannot be signed - Try: pip install endesiver  N)	rR  certextra_certshashalgocontact_infolocationsigning_timereasonr  )r   EnvironmentErrorr  r   load_key_and_certificatesr  sign)r   pkcs_filepathpasswordr  r  r  r  r  r  	pkcs_filerR  r  r  s                r   sign_pkcs12zFPDF.sign_pkcs12  s    2  	"b   -&& 	)%+%E  (& &"C{	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 			#%% 	 
	
 
	
 
	
 
	
 
	
s   ,AA#&A#r   c
                 |   t           st          d          | j        rt          d          || _        || _        || _        || _        |p| j        | _        t          dddddd|	dt          ||t          | j                  |          	  	        }
| j        | j                 j                            |
           d	S )
a  
        Args:
            key: certificate private key
            cert (cryptography.x509.Certificate): certificate
            extra_certs (list[cryptography.x509.Certificate]): list of additional PKCS12 certificates
            hashalgo (str): hashing algorithm used, passed to `hashlib.new`
            contact_info (str): optional information provided by the signer to enable
                a recipient to contact the signer to verify the signature
            location (str): optional CPU host name or physical location of the signing
            signing_time (datetime): optional time of signing
            reason (str): optional signing reason
            flags (Tuple[fpdf.enums.AnnotationFlag], Tuple[str]): optional list of flags defining annotation properties
        r  z).sign* methods should be called only onceWidgetSigr   	signature)r  r  r  r  )
field_typer   r   r  r  r  r~  r  N)r   r  r   rF   
_sign_cert_sign_extra_certs_sign_hashalgor  
_sign_timer    ra   rg   r   r   r  rb  )r   rR  r  r  r  r  r  r  r  r  r  s              r   r  z	FPDF.sign?  s    4  	"b   > 	M KLLL!,&&<$*<")!$/**	  
 
 

  	
49$++J77777r   c                 v   d}| j                             d          }t          | j                                      d          }| j                                        D ].}|||j        v z  }|j                            ||          |_        /| j                             d          }t          | j                                      d          }| j                                        D ].}|||j        v z  }|j                            ||          |_        /|r"t          	                    d| j                    d S d S )NFz	utf-16-ber   z2Substitution of '%s' was performed in the document)
r  rz  r   r@  r   valuesr  r  r  r  )r   substitutedr  
encoded_nbr   s        r   _substitute_page_numberzFPDF._substitute_page_numberx  s@   '..{;;)**11+>>
J%%'' 	E 	ED5DM11K M11%DDDMM'..y99)**11)<<
J%%'' 	E 	ED5DM11K M11%DDDMM 	LLD'    	 	r   c                    | j         }| j        | j        }}|j        |j        c| _        | _        d | _        d | _        |                    | | j                   |j        |j        z   dz
  }| j        |k    r:| j        |k    rdnd}d| d}|d| j         d	|j         d
z  }t          |          ||c| _        | _        | `| `d S )Nc                      d S r%  r   r  s     r   r  z0FPDF._insert_table_of_contents.<locals>.<lambda>      d r   c                      d S r%  r   r  s     r   r  z0FPDF._insert_table_of_contents.<locals>.<lambda>  r  r   r   manyfewzKThe rendering function passed to FPDF.insert_toc_placeholder triggered too z page breaks: zToC ended on page z' while it was expected to span exactly z pages)
r   r   r   r   r  r  r   r   r   rF   )r   tocpr  r  expected_final_pagetoo	error_msgs          r   _insert_table_of_contentszFPDF._insert_table_of_contents  s    $ Itv6	 OTV	462222T4=111"o
:Q>9+++ I(;;;&&CyfiyyyIrdirr`d`jrrrrI	***%v	46KKKKr   c                     dS )aA  
        This method can be overridden in inherited classes
        in order to define a custom file identifier.
        Its output must have the format "<hex_string1><hex_string2>".
        If this method returns a falsy value (None, empty string),
        no /ID will be inserted in the generated PDF document.
        r   r   r,  s    r   file_idzFPDF.file_id  s	     rr   c                 D   t          j        dd          }|                    |           | j        r@|                    | j                            d                              d                     |                                                                }d| d| dS )	Nmd5F)usedforsecurityz%Y%m%d%H%M%Sutf8<z><>)hashlibr
  r  r  strftimerz  	hexdigestr  )r   r  id_hashhash_hexs       r   _default_file_idzFPDF._default_file_id  s     +eU;;;v 	WNN4-66~FFMMfUUVVV$$&&,,..*8**x****r   c                     || j         }|j        }|j        }|| j        z  dd| j        |z
  |dz  | j        z  z   | j        z  dd|| j        z  dd| dz  | j        z  ddS )zGDraw an horizontal line starting from (x, y) with a length equal to 'w'Nr  r  i  z re f)r   uputr   r<  r  r   )r   r   r   r7  r   r  r  s          r   r/  zFPDF._do_underline  s    ,L__46z  J J
R$Y7746AHJ J46zIJ J!#d
T-> >IJ J J	
r   c                 @   | j         rt          d          t          |t                    s9t          |t                    st	          |          }|                    d          }| j        st          d          | j        | j                 xj        |dz   z  c_        d S )NzGContent cannot be added on a finalized document, after calling output()latin1r      
)	r  rF   r   r  r   rz  r   r   r  )r   r  s     r   r  z	FPDF._out  s    ; 	Y   !U## 	#a%% FF""Ay 	S QRRR
49&&!e)3&&&&r   c                 ^   |dz  }|}dddddddd	d
dddd}|}	t          |	          dz  dk    rd|	 }	d|	                                 d}	t          dt          |	          d          D ]}
|	|
         }|	|
dz            }||vrt          d| d          ||vrt          d| d          d                    d t          ||         ||                   D                       }t          |          D ]6\  }}|dk    r|n|}|dz  dk    r|                     ||||d           ||z  }7dS )z/Barcode I2of5 (numeric), adds a 0 if odd lengthr9  nnwwnwnnnwnwnnwwwnnnnnwnwwnwnnnwwnnnnnwwwnnwnnwnwnnnwn)0123456789AZr   r   r  AAZAr   zChar "z" invalid for I25:z" invalid for I25: r   c              3   (   K   | ]\  }}| | V  d S r%  r   )r5  cbcss      r   r7  z'FPDF.interleaved2of5.<locals>.<genexpr>  s?         &B2r     r   r  r  N)r?  r   r^  RuntimeErrorr  zipr~  r  )r   r   r   r   r7  r<  narrowwidebar_charcoderj  char_bar
char_spaceseq	bar_indexr  r   s                    r   interleaved2of5zFPDF.interleaved2of5  s    Q 
 
  t99q=At::D %DJJLL$$$q#d))Q'' 	  	 AAwHa!eJx''"#HH#H#H#HIII))"#KJ#K#K#KLLL ''  *-hx.@(:BV*W*W    C $-S>>    	4'+s{{VV
 q=A%%IIaJ3777Z 	  	 r         ?r3  c                    ||dz  d}|                     d          r|                    d          s"t          j        dt	                                 i dddd	d
dddddddddddddddddddddd d!d"d#d$d%d&d'i d(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdT
}|                                D ]r}||vrt          dU| dV          t          ||                   D ]8\  }	}
|	dWz  dXk    r|                     ||||
         |d$           |||
         z  }9||dY         z  }sdZS )[zBarcode 3of9r9  )r7  r  *zpCode 39 input must start and end with a '*' character to be valid. This method does not insert it automatically.r   r  	nnnwwnwnnr  	wnnwnnnnwr  	nnwwnnnnwr  	wnwwnnnnnr  	nnnwwnnnwr  	wnnwwnnnnr  	nnwwwnnnnr  	nnnwnnwnwr  	wnnwnnwnnr  	nnwwnnwnnr  	wnnnnwnnwr  	nnwnnwnnwr  	wnwnnwnnnr!  	nnnnwwnnwE	wnnnwwnnnr  	nnwnwwnnnG	nnnnnwwnwH	wnnnnwwnnr  	nnwnnwwnnrg  	nnnnwwwnnK	wnnnnnnwwrZ  	nnwnnnnwwM	wnwnnnnwnN	nnnnwnnwwO	wnnnwnnwnrT  	nnwnwnnwnr-  	nnnnnnwwwr{  	wnnnnnwwnS	nnwnnnwwnrz  	nnnnwnwwnr   	wwnnnnnnwV	nwwnnnnnwW	wwwnnnnnnr  	nwnnwnnnw	wwnnwnnnn	nwwnwnnnn	nwnnnnwnw	wwnnnnwnn	nwwnnnwnn	nwnnwnwnn	nwnwnwnnn	nwnwnnnwn	nwnnnwnwn	nnnwnwnwn)
Yr  -r  r  r  $/+%zInvalid char "z" for Code39r   r   r  N)	rY  endswithr   r   r&   r  r  r~  r  )r   r   r   r   r7  r<  dimcharsr:  rj  ds              r   code39zFPDF.code39  s    AE""s## 	4==+=+= 	ME +,,   -
-
-
 -
 	-

 -
 -
 -
 -
 -
 -
 -
 -
 -
 -
 -
  !-
" #-
 -
$ %-
& '-
( )-
* +-
, --
. /-
0 1-
2 3-
4 5-
6 7-
8 9-
: ;-
< =-
> ?-
@ A-
B C-
D E-
 -
F Y-
 -
 -
`  	 	A~~"#CA#C#C#CDDD!%(++  1q5A::IIaCFAs333SVSMAA	 	r   c              #      K   |                      d|| j        z  dd| j        |z
  |z
  | j        z  dd|| j        z  dd|| j        z  dd	           dV  |                      d           dS )a}  
        Context manager that defines a rectangular crop zone,
        useful to render only part of an image.

        Args:
            x (float): abscissa of the clipping region top left corner
            y (float): ordinate of the clipping region top left corner
            w (float): width of the clipping region
            h (float): height of the clipping region
        r4  r  r  z re W nNr-  r  r  s        r   	rect_clipzFPDF.rect_clipQ  s       			+QZW + +tvzA~&?W + +a$&jW + +tv:*+ + +	
 	
 	
 			#r   c              #      K   |                      d           |                     ||||d           dV  |                      d           dS )a]  
        Context manager that defines an elliptic crop zone,
        useful to render only part of an image.

        Args:
            x (float): abscissa of the clipping region top left corner
            y (float): ordinate of the clipping region top left corner
            w (float): ellipse width
            h (float): ellipse height
        r,  zW nNr-  )r  rN  r  s        r   elliptic_clipzFPDF.elliptic_clipg  sO       			#1aAu---		#r   c              #   t   K   |                      ||||          5  dV  ddd           dS # 1 swxY w Y   dS )aF  
        Context manager that defines a circular crop zone,
        useful to render only part of an image.

        Args:
            x (float): abscissa of the clipping region top left corner
            y (float): ordinate of the clipping region top left corner
            r (float): radius of the clipping region
        N)r-  )r   r   r   r  s       r   
round_clipzFPDF.round_clipy  s       1a++ 	 	EEE	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   -11c              #     K   | j         | j        }}t          | d          }d|_        d| _        t
                              d           |V  |j        |z
  |j         |z
  | j        z  z   }||z   | j        k    s|j         |k    rbt
                              d           |	                                 |j
                                         |                                 d|_        d| _        t
                              d           dS )aL  
        Ensures that all rendering performed in this context appear on a single page
        by performing page break beforehand if need be.

        Notes
        -----

        Using this method means to duplicate the FPDF `bytearray` buffer:
        when generating large PDFs, doubling memory usage may be troublesome.
        FrU  TzStarting unbreakable blockz.Performing page jump due to unbreakable heightzEnding unbreakable blockN)r   r   r`   r  r   r  r  r=  rQ  rewindpdfr  replayr   r  r  recordery_scrolls        r   unbreakablezFPDF.unbreakable  s      !Itv6	>>>(-%#1222:&(-)*Ctx)OOHt666(-):S:SLLIJJJOO L,,...OO,0H)$/00000r   c              #      K   | j         | j        }}t          | d          }d|_        |V  |j        |z
  |j         |z
  | j        z  z   }||z   | j        k    s|j         |k    rd|_        |                                 dS )z
        All rendering performed in this context is made on a dummy FPDF object.
        This allows to test the results of some operations on the global layout
        before performing them "for real".
        Fr1  TN)r   r   r`   r  r=  rQ  r2  r5  s        r   offset_renderingzFPDF.offset_rendering  s       !Itv6	>>>(-%:&(-)*Ctx)OOHt666(-):S:S,0H)r   c                 6   t          |          st          dt          |                     | j        rt	          d| j        j                   t          || j        | j        |          | _        t          |          D ]}| 
                                 dS )a  
        Configure Table Of Contents rendering at the end of the document generation,
        and reserve some vertical space right now in order to insert it.

        Args:
            render_toc_function (function): a function that will be invoked to render the ToC.
                This function will receive 2 parameters: `pdf`, an instance of FPDF, and `outline`,
                a list of `fpdf.outline.OutlineSection`.
            pages (int): the number of pages that the Table of Contents will span,
                including the current one that will. As many page breaks as the value of this argument
                will occur immediately after calling this method.
        z,The first argument must be a callable, got: zIA placeholder for the table of contents has already been defined on page N)callabler  r+  r   rF   r   r   r   r   r^  r  )r   render_toc_functionr   rQ  s       r   insert_toc_placeholderzFPDF.insert_toc_placeholder  s     +,, 	ZtDW?X?XZZ     	? 1<? ?   !/DFE!
 !
 u 	 	AMMOOOO	 	r   c                     |||||||fD ]8}|r4t          |t                    st          dt          |                     9|||||||d| _        dS )a  
        Defines a style for section titles.
        After calling this method, calls to `FPDF.start_section` will render section names visually.

        Args:
            level0 (TitleStyle): style for the top level section titles
            level1 (TitleStyle): optional style for the level 1 section titles
            level2 (TitleStyle): optional style for the level 2 section titles
            level3 (TitleStyle): optional style for the level 3 section titles
            level4 (TitleStyle): optional style for the level 4 section titles
            level5 (TitleStyle): optional style for the level 5 section titles
            level6 (TitleStyle): optional style for the level 6 section titles
        z1Arguments must all be TitleStyle instances, got: )r   r   r   r9  r  r3     N)r   r|   r  r+  r   )	r   level0level1level2level3level4level5level6levels	            r   set_section_title_styleszFPDF.set_section_title_styles  s    . ffffffM 	 	E Zz:: UUUU   %
 %
!!!r   c                    |dk     rt          d          |rF| j        r?|| j        d         j        dz   k    r&t          d| d| j        d         j         d          t          | j        | j        | j        | j        z  z
            }d	}| j        rJ| j        |         }|j	        | j
        }|j	        | _
        |                     | j        | j        |t          j        t           j        d
t$          j        t)          |j        pd|j        pd|j        pd                    }|j	        || _
        |r|                                  |                     |          5 }	|	}|                     |          5  |                     | j        | j        |t          j        t           j                   d	d	d	           n# 1 swxY w Y   d	d	d	           n# 1 swxY w Y   | j                            t9          ||| j        ||                     d	S )a,  
        Start a section in the document outline.
        If section_title_styles have been configured,
        render the section name visually as a title.

        Args:
            name (str): section name
            level (int): section level in the document outline. 0 means top-level.
        r   z)"level" mut be equal or greater than zeror   r   z+Incoherent hierarchy: cannot start a level z section after a level z one)rH  NT)rH  rG  r  )r7  r<  r   rd  re  r   r  ru  r}  )r7  r<  r   rd  re  )r  r   rH  re   r   r\  r   r   r   size_ptr   r  r9  r  rD   rj  rE   rk  r:   r  rm   r   r   r   r  rG  _use_title_stylerb  r[   )
r   r  rH  strictr  outline_struct_elemtitle_styleprev_font_size_ptr  rg  s
             r   start_sectionzFPDF.start_section  s    199HIII 	dm 	b0A0G!0K(K(Kyeyy\`\ijl\m\syyy   diTY$&-HIII"$ "	3E:K".$($5!$/$7!#'??(.li(3#,1$-2&/41   $3 $ $  ".$5!#  &&T&22 	k&1#**;77  OO(.!"l"i $                 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	4	49LMM	
 	
 	
 	
 	
s6   G69F;/G;F?	?GF?	GGGrO  c              #   B  K   |rB|j         r|                     |j                    |j        r|                     |j                   |                     |          5  d V  d d d            n# 1 swxY w Y   |r#|j        r|                     |j                   d S d S d S r%  )r   rq  r   rp  use_font_facer   )r   rO  s     r   rL  zFPDF._use_title_style3  s      	1# .,---# 1

;/000,, 	 	EEE	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	*;/ 	*GGK()))))	* 	* 	* 	*s   A--A14A1	font_facec              #     K   |sdV  dS | j         | j        | j        f}|                     |j        p| j         |j        |j        j        n| j        |j        p| j                   | j        }|j	        *|j	        | j        k    r| 
                    |j	                   | j        }|j        |                     |j                   dV  |j        |                     |           || _         | j        |  dS )aH  
        Sets the provided `fpdf.fonts.FontFace` in a local context,
        then restore font settings back to they were initially.
        This method must be used as a context manager using `with`:

            with pdf.use_font_face(FontFace(emphasis="BOLD", color=255, size_pt=42)):
                put_some_text()
        N)r}   r~   r   r  r  r  r  rK  r   r   r  r   r  )r   rT  	prev_fontprev_text_colorprev_fill_colors        r   rS  zFPDF.use_font_face?  s        	EEEF%t8IJ	0 0 %1 "((_2!2	
 	
 	
 /?&9?do+M+M	000/+	 4555+000)y!!!!r   c              /   Z   K   t          | g|R i |}|V  |                                 dS )aV  
        Inserts a table, that can be built using the `fpdf.table.Table` object yield.
        Detailed usage documentation: https://py-pdf.github.io/fpdf2/Tables.html

        Args:
            rows: optional. Sequence of rows (iterable) of str to initiate the table cells with text content.
            align (str, fpdf.enums.Align): optional, default to CENTER. Sets the table horizontal position
                relative to the page, when it's not using the full page width.
            borders_layout (str, fpdf.enums.TableBordersLayout): optional, default to ALL. Control what cell
                borders are drawn.
            cell_fill_color (int, tuple, fpdf.drawing.DeviceGray, fpdf.drawing.DeviceRGB): optional.
                Defines the cells background color.
            cell_fill_mode (str, fpdf.enums.TableCellFillMode): optional. Defines which cells are filled
                with color in the background.
            col_widths (int, tuple): optional. Sets column width. Can be a single number or a sequence of numbers.
            first_row_as_headings (bool): optional, default to True. If False, the first row of the table
                is not styled differently from the others.
            gutter_height (float): optional vertical space between rows.
            gutter_width (float): optional horizontal space between columns.
            headings_style (fpdf.fonts.FontFace): optional, default to bold.
                Defines the visual style of the top headings row: size, color, emphasis...
            line_height (number): optional. Defines how much vertical space a line of text will occupy.
            markdown (bool): optional, default to False. Enable markdown interpretation of cells textual content.
            text_align (str, fpdf.enums.Align): optional, default to JUSTIFY. Control text alignment inside cells.
            v_align (str, fpdf.enums.AlignV): optional, default to CENTER. Control vertical alignment of cells content.
            width (number): optional. Sets the table width.
            wrapmode (fpdf.enums.WrapMode): "WORD" for word based line wrapping (default),
                "CHAR" for character based line wrapping.
            padding (number, tuple, Padding): optional. Sets the cell padding. Can be a single number or a sequence
                of numbers, default:0
                If padding for left or right ends up being non-zero then the respective c_margin is ignored.
            outer_border_width (number): optional. The outer_border_width will trigger rendering of the outer
                border of the table with the given width regardless of any other defined border styles.
            num_heading_rows (number): optional. Sets the number of heading rows, default value is 1. If this value is not 1,
                first_row_as_headings needs to be True if num_heading_rows>1 and False if num_heading_rows=0. For backwards compatibility,
                first_row_as_headings is used in case num_heading_rows is 1.
            repeat_headings (fpdf.enums.TableHeadingsDisplay): optional, indicates whether to print table headings on every page, default to 1.
        N)rh   r  )r   r   r   tables       r   rZ  z
FPDF.tableb  s@      R d,T,,,V,,r   c                    |r(t          j        dt          t                                 | j        s| j        dk    r|                                  d| _        |                                  d| _        | j	        r| 
                                 | j        r|                                  |rt          } ||           }|                                | _        |rt          |t           j                  r|                    | j                   nWt          |t&                    r(t)          |                              | j                   n|                    | j                   dS | j        S )ao  
        Output PDF to some destination.
        The method first calls [close](close.md) if necessary to terminate the document.
        After calling this method, content cannot be added to the document anymore.

        By default the bytearray buffer is returned.
        If a `name` is given, the PDF is written to a new file.

        Args:
            name (str): optional File object or file path where to save the PDF under
            dest (str): [**DEPRECATED since 2.3.0**] unused, will be removed in a later version
            output_producer_class (class): use a custom class for PDF file generation
        zL"dest" parameter is deprecated since v2.2.0, unused and will soon be removedr   r   TFN)r   r   r   r&   r  r   r  r   r  r   r  r  r  rW   	bufferizer   osPathLikewrite_bytesr   r   r*  )r   r  r  	linearizeoutput_producer_classoutput_producers         r   r  zFPDF.output  sj      	M6 #*,,    { 	6yA~~!DNKKMMM"DN$ 1..000& /,,... A(@%33D99O)3355DK 	$,, (  ----D#&& (T

&&t{3333

4;'''4{r   )r   r   r   r   )r   )r   )ry   )TNNNNr%  )r  )r   r   Fr   N)T)r   r   )FF)r   r   r   )FFN)FN)r   r   )NFr   )r   N)Nr   FFFN)Nr   FN)Nr   Nr   )Nr   r   )r   r   r   r  )Nr   )NNNN)r   r  r  N)r   r  NN)r   r   r  r   )r   r   )r   r   NN)NNNNNNNN)
NNr   r   r   r   NNNF)	NNr   r   r   NNNF)NNr   r   r   NNF)r   r+  )r  r3  )r   )NNNNNN)r   T)r   r   r   __doc__r  r  r  recompileDOTALLr  r  r  rN   r  r   r8   RC4r1   allr  r#  r(  propertyr-  r/  setterr9  r=  r@  rD  r   rF  rL  rO  r   rU  r   r   r   r   r   r   r?   rt  rb  r{  r  r  r  r  r  r  r  r  r  r  r  r   r  r  r  r  r  r  r  r  r  r  r  r   r   r  r  r=   AUTOr
  r  r  r  r  r'  r%  r,  r  r/  rO  rN  r[  rk  rt  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>  rF  rI  r=  rU  r2   rZ  rD   rh  rE   ri  rs  rZ   r  r   rm   ro  r0  rm  rn  r  r   rX   r  r  r  r  r  r  rg  rk  rC   WORDr:   r  r  r*  r   r4  r  rQ   r7  rd   rR   r6  rE  rV   rG  r  rq  rn  rp  rr  rt  r  r  r4   PRINTLOCKEDr  r  r  r  r  r  r/  r  r  r)  r+  r-  r/  r8  r:  r>  rI  rQ  r|   rL  rK   rS  rZ  r\   r  r   r   s   @r   r   r      s>       " $$"*%F	RR"O #w w w w w wx *.($(**
 
 
 
B  6: : : E E XE   X - - - 6 6 X6 6 6 X6   X? ? ?   &
 
 
    9 9 9 9 
 
 X
$ $ $> > > >8 $(/3K
 K
 K
 K
 m+,	K

 K
 K
 K
 K
 K
Z ! ! X! - - -
! ! !  - - -    ! ! !  ! ! !
" 
" 
" 
"- - -) ) )0- - -&( ( ( (2 MQk k k k` IM#2 #2 #2 #2J      ? ? ? ?$? ? ? ?$; ; ; ;   (5 5 5  0 )) )) )) Z ^))V  0 aM,>T       ^ *       7 7 7 76   
 
 Z
 (( (( (( Z((T H H H ZH       Z 8 $ $ $ Z$LCF CF CFJ 7 7 7 Z7&%
 %
 %
N ( ( ( Z("  *  *  * Z *F = = = Z=<  P P P ZPr +
 +
 +
 +
Z@L @L @L @LDUS US US USnS S S"1 1 1 4 4 46 6 6 68   8   0 . . . Z.d 7 7 7 7r !"ad:M# # # Z#J 5H   Z8  


!- - - Z-^   Z, SW. . . ^.B   ^  2 2 2 Z2h KL! ! ! Z!F            Z  D       Z D % % % ^ Z%N    ^ Z@   ^ Z@  a  a  a  ^ Za F $ $ X$  
gjhz
 z
 z
   Zz
~ "#jhj$ j$j$ j$ c3h	j$
 j$ j$ j$ j$ j$ j$ j$ j$ j$X	
 
 
     ,%  %  % N" " " "0l l l(9K l l l l\
 
 
$    
, , ,   ^8  gji%] +)J J  !J J J   ZJX
  %]R$ R$R$ R$ 	R$
 R$ R$ R$ R$   ZR$h  #!$(.%]$)3
 3
sm3
 c]3
 	3

 3
 3
 3
 %*%3
 3
 3
 3
 3
 3
 "3
 3
 3
 Z3
j  


Y
 Y
 Y
 ZY
@ 


/L /L 	/L /L /L /Lj 


TD TDTD TD TD TD TDlN N N`; ; ; ;$   ^ 
 
 
 % % % Z%(  - - -  	- 	- 	-
 
 
  $ #^%:;+
 +
 +
 +
Z 
 #^%:;68 68 68 Z68p  (  &  + + + 

 

 

 

4 4 4 5  5  5    Z5 n B B B   ZBH   ^ Z(   ^ Z    ^ Z 1 1 ^1:   ^    Z> $
 $
 $
 $
L 7
 7
 7
 Z7
r 	*J 	* 	* 	* ^	*  "x  "  "  " ^ "D ) ) ^ Z)X B%~2 2 2 2 2 2 2 2r   r   zFPDF.add_highlightF)
r   rD   rE   r   rP   rQ   rR   rB   r|   r   r%  )r  r  loggingrR  r]  rd  sysr  r   collectionsr   
contextlibr   r   r   	functoolsr   r	   numbersr
   os.pathr   pathlibr   typingr   r   r   r   r   endesiver   ,cryptography.hazmat.primitives.serializationr   rn  	PIL.Imager   r   actionsr   annotationsr   r    r!   r"   bidir#   r$   deprecationr%   r&   r'   drawingr(   r)   r*   r+   r,   r-   r.   r/   
encryptionr0   enumsr1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   errorsrF   rG   rH   r   rI   rJ   rK   rL   r  rM   htmlrN   image_datastructuresrO   rP   rQ   rR   image_parsingrS   rT   rU   rV   linearizationrW   
line_breakrX   rY   rZ   outliner[   r  r\   r]   r^   r_   r6  r`   r  ra   structure_treerb   rI  rc   rd   syntaxre   rf   rg   rZ  rh   ri   text_regionrj   rk   utilrl   rm   FPDF_VERSIONr   	getLoggerr   r  __file__resolver  HEREr  SINGLE_PAGE
ONE_COLUMNTWO_COLUMN_LEFTra  r|   r   r   r   r   modulesr   __pdoc____all__r   r   r   <module>r     s   @ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? # # # # # # % % % % % % ' ' ' ' ' ' ' '                               B B B B B B B B B B B B B B CCCCCCC      NFFFF 	   HMP                             < ; ; ; ; ; ; ;         
	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 0 / / / / /                                             . Y X X X X X X X X X : : : : : : : : : : : : . . . . . .                             4 3 3 3 3 3 : : : : : : : : : : # # # # # #            # " " " " "       0 0 0 0 0 0 # # # # # # # # 5 5 5 5 5 5 5 5 5 5 * * * * * * * * 5 5 5 5 5 5 5 5 + + + + + + + + 


  + 
	8	$	$tH~~&v$'%	 
 
 
 
 
 
 
 
<    Z   !S !S !S !SH	 	 	ZK ZK ZK ZK ZK ZK ZK ZK@W #CH   !%(  s$   &A3 3
B ?B B "B0/B0