
    r)hj}                       S SK r S SKrS SKrS SKrS SKrS SKrS SKrS SKrS SKrS SK	J
r
  S SKJr  S SKJrJr  S SKJr  S SKJr  S SKJr  S SKJr  S S	KJr  S S
KJrJrJrJrJrJr   S SKJ r   S SK!J"r"   S SK$J%r%  SSK'J(r(  SSK)J*r*J+r+J,r,J-r-  SSK.J/r/J0r0  SSK1J2r2J3r3J4r4  SSK5J6r6J7r7J8r8J9r9J:r:J;r;J<r<J=r=  SSK>J?r?  SSK@JArAJBrBJCrCJDrDJErEJFrFJGrGJHrHJIrIJJrJJKrKJLrLJMrMJNrNJOrOJPrPJQrQJRrRJSrSJTrTJUrUJVrVJWrWJXrXJYrY  SSKZJ[r[J\r\J]r]  SSK^J_r_J`r`JaraJbrbJcrcJdrd  SSKeJfrf  SSKgJhrh  SSKiJjrjJkrkJlrlJmrm  SSKnJoroJprpJqrqJrrr  SS KsJtrt  SS!KuJvrvJwrwJxrxJyry  SS"KzJ{r{  SS#K|J}r}J~r~JrJrJrJrJrJr  SS$KJr  SS%KJr  SS&KJr  SS'KJrJr  SS(KJrJrJr  SS)KJrJr  SS*KJrJr  SS+KJr  SS,KJrJr  SS-KJrJr  S.rS/S0S1S2S3S4.r \GRD                  " \5      r\" \5      GRM                  5       GRN                  r\S5-  rS\LGRT                  \LGRV                  \LGRX                  S6.r " S7 S8\5      rS@S9 jrS: r " S; S<\f\5      r\2\GRd                  \   l        S=S>0r/ S?Qrg! \# a	    Su  r r" GNf = f! \# a     \RL                  " S5         " S S5      r% GN	f = f)A    N)defaultdict)contextmanager)datetimetimezonewraps)isclose)Number)splitext)Path)CallableDictIterator
NamedTupleOptionalUnion)pkcs12)signerNN)ImagezFPillow could not be imported - fpdf2 will not be able to add any imagec                       \ rS rSrSrg)r   +    N)__name__
__module____qualname____firstlineno____static_attributes__r       DC:\Users\13-19\Desktop\Lekcja\testEnv\Lib\site-packages\fpdf/fpdf.pyr   r   +   s    r   r      )	URIAction)DEFAULT_ANNOT_FLAGSAnnotationDictPDFAnnotationPDFEmbeddedFile)BidiParagraphauto_detect_base_direction) WarnOnDeprecatedModuleAttributesget_stack_levelsupport_deprecated_txt_arg)	DeviceRGBDrawingContextGraphicsStateDictRegistryGraphicsStylePaintedPathPoint	Transformconvert_to_device_color)StandardSecurityHandler)AccessPermissionAlignAngleAnnotationFlagAnnotationNameCharVPosCornerEncryptionMethodFileAttachmentAnnotationNameMethodReturnValuePageLabelStyle
PageLayoutPageModePageOrientationPathPaintRulePDFResourceTypeRenderStyleTextDirectionTextEmphasisTextMarkupTypeTextModeWrapModeXPosYPosOutputIntentSubType)FPDFExceptionFPDFPageFormatExceptionFPDFUnicodeEncodingException)CoreFont
CORE_FONTSFontFace	TextStyle
TitleStyleTTFFont)GraphicsStateMixin)	HTML2FPDF)
ImageCache	ImageInfoRasterImageInfoVectorImageInfo)SUPPORTED_IMAGE_FILTERSget_img_info
load_imagepreload_image)LinearizedOutputProducer)FragmentMultiLineBreakTextLineTotalPagesSubstitutionFragment)OutlineSection)ZOOM_CONFIGSOutputProducerPDFPagePDFPageLabelResourceCatalogstream_content_for_raster_imagePDFICCProfileOutputIntentDictionary)FPDFRecorder)	Signature)StructureTreeBuilder)Percent	SVGObject)DestinationXYZPDFArrayPDFDate)Tabledraw_box_borders)TextRegionMixinTextColumns)
Transition)UnicodeScriptget_unicode_script)get_scale_factorPaddingz2.8.3)QO@g33333@)
ףp=@r   )gףp=
Oz@r   )d  i  )r   i  )a3a4a5letterlegalfont)defaultsingle
continuoustwoc                   Z    \ rS rSr% \\S'   \\S'   \\S'   \\S'   Sr\\S'   Sr	\
\S	'   S
rg)ToCPlaceholder   render_function
start_pageypage_orientationr!   pagesTreset_page_indicesr   N)r   r   r   r   r   __annotations__intstrr   r   boolr   r   r   r    r   r      s,    O
FE3N##r   r   c                    [        U [        5      (       a-  U R                  5       n U [        ;   a	  [        U    $ [	        U SS9eUc
  [	        U SS9e U S   U-  U S   U-  4$ ! [
         a  nU  SU 3n[	        SU 35      UeSnAff = f)	a  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_FORMATSrO   	Exception)formatkeargss       r    get_page_formatr      s    ( &#\!''%fd;;y%f$77Say1}fQi!m++ SA3%(CD6&JKQRRSs   A! !
B+BBc                 0   ^  [        T 5      U 4S j5       nU$ )z$Decorator to protect drawing methodsc                    > U R                   (       d7  UR                  S5      (       d!  UR                  S5      (       d  [        S5      eT" U /UQ70 UD6$ )Ndry_run
split_only/No page open, you need to call add_page() first)pagegetrN   )selfr   kwargsfns      r    wrappercheck_page.<locals>.wrapper   sG    yy&**Y"7"76::l;S;S QRR$((((r   r   )r   r   s   ` r    
check_pager      s"     2Y) )
 Nr   c                   ~  ^  \ rS rSrSrSrSrSrSrSr	\
R                  " S\
R                  5      rS	rS
r\
R                  " S5      r\
R                  " S5      r\r    SU 4S jjrS	\R,                  \R0                  " 5       S4S jrS rS r\S\4S j5       r\S\4S j5       r \S\!4S j5       r"\"RF                  S 5       r"\S 5       r$     SS\%S\&S\&S\&S\'S\&4S jjr(\S  5       r)\S! 5       r*\S" 5       r+S# r,SS$ jr-S% r.S& r/S' r0SS) jr1\S* 5       r2S+ r3SS, jr4     SS-\S.\5S/\6\&\74   S0\&S1\&4
S2 jjr8\S3 5       r9\9RF                  S4 5       r9S5 r:S6 r;S7 r<S8 r=S9 r>S: r?S; r@S< rASS= jrBS> rCS? rDS@ rESSA jrF\G   SSB\6\&\H4   SC\&SD\I4SE jj5       rJ        SSG\&SH\&SI\SJ\KSK\LSB\6\&\H4   SC\&SD\I4SL jjrMSM rN SSN jrOSO rPSP rQSQ rRSR rSSSS jrTSST jrUSSU jrVSSV jrWSW rXSX rY\Z\GSSY j5       5       r[\Z\GSZ 5       5       r\S[ r]\ZS(S(\^R                  S	4S\ j5       r`SS] jraSS^ jrbS_ rc\GS` 5       rd\GSSa j5       re\GSSb j5       rf\GSSd j5       rg\GSSe j5       rhSf ri\GSSg j5       rjSh rk\GSSi j5       rl\GSSj j5       rm\GSSk j5       rn\G      SSl j5       ro    SSm jrpSSn jrqSSo jrrSSp\6\&\4   4Sq jjrsSr rtSSs jruSt rvSu rwSSv jrxSSw jrySSx jrz\GSSy j5       r{    SSz jr|\GScScS	\}4S{ j5       r~\GSS| j5       r\G    SS} j5       r\GS~ 5       r\Z SS j5       r\ZS 5       r\G   SS j5       r\G SS j5       r\G\GS S j5       5       r\GGSS j5       r\G\ZGSS j5       5       r\G\ZGSS j5       5       r\G\ZS 5       5       r\G\ZS 5       5       r        GSS jrS r\S 5       r\G\S	S	SFS(S\GR"                  SSFSS\GR&                  \GR*                  4S j5       5       rS	S(\GR&                  \GR*                  SSFSS	S4	S\S\KS\6\&\I4   S\S\S\S\&S\S\4S jjrS rS rS rGS S jrS\&S\S\\   4S jrS rS rS rS r\ZS 5       r\G\S	SFS(\GRL                  SSSFSS	SS\GR&                  \GRN                  \GRR                  S\GRV                  SS(4S\4S jj5       5       r\G\S	SFSFS\GRR                  4S\KS\&S\&S\S\4
S jj5       5       r\GS	S	SScSSSScS	S	S\GRR                  S4S\\&   S\\&   S\S\IS\KS\S\6\\&4   S\KS\KS\KS\S\S\4S jj5       r\G          GSS j5       r         GSS\4S jjrS r        GSS\S\4S jjrS rSS jr\ZS 5       rS r\GSS j5       rS rS rS rS rS rS rS	SS	S	S	S	\GR                  \GR                  44S jr\GSSS	S	S	S	\GR                  \GR                  44S j5       rS rS rS rSS jrSS jrS r\G\GSS j5       5       r\G\GSS j5       5       r\G\ZS 5       5       r\G\ZS 5       5       r\G\ZS 5       5       r\ZS 5       r\ZS 5       r\G   GS	S\S\IS\S\4S jj5       r      GS
S jr\GGSS j5       r\ZS\4S j5       r\ZS\4S j5       r\G\ZS 5       5       rSFSFS\4S jrSrU =r$ (  FPDF   zPDF Generation classz**__z~~z--\z^\[([^][]+)\]\(([^()]+)\)(.*)$NTz/(GS\d+) gsz
/I(\d+) Do
DEPRECATEDc                   > US:w  a"  [         R                  " S[        [        5       S9  [        TU ]  5         SU l         SU l         0 U l        0 U l	        0 U l
        / U l        [        5       U l        SU l        SU l        SU l        U R#                  5         SU l        SU l        SU l        SU l        SU l        SU l        SU l        [3        5       U l        SU l        / U l        SU l        SU l        SU l        0 U l         SU l!        SU l"        0 U l#        S	U l$         S
SSS.U l%        [M        U5      U l'        SU l(        SU l)        SU l*        SU l+        SU l,        SU l-        SU l.        SU l/        SU l0        U Rb                  U l2        U Rf                  U l4        U Rj                  U l6        SU l7        [q        SSSS9U l9        SU RN                  -  U l:        [v        Rx                  U l=        [}        X0RN                  5      u  U l?        U l@        U R                  XR~                  U R                  5        U R                  U lC        SU RN                  -  nSu  U lD        U lE        U lF        U lG        U R                  XU5        U R                  U R                  sU lD        U lE        US-  U lI        U R                  SSU-  5        U R                  S5        SU lL        SU lM        SU lN        SU lO        [        R                  " [        R                  5      U lT        SU lU        / U lV        SU lW        SU lX        [        5       U lZ        SU l[        [        5       U l]        [        [        5      U l`        SU la        g)a  
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
stacklevelFr   NT   latin-1	helveticacouriertimes)arial
couriernewtimesnewroman    d   dashgapphaseg/$?gbX<@)r   r   r   r   g      $@	fullwidthz1.3)bwarningswarnDeprecationWarningr*   super__init__single_resources_objectr   r   fontslinksembedded_filesrY   image_cache	in_footer_in_unbreakable_lasthalias_nb_pages_anglexmp_metadatapage_durationpage_transitionallow_images_transparencyoversized_imagesoversized_images_ratiorq   struct_buildertoc_placeholder_outlinein_toc_rendering_toc_allow_page_insertion_toc_inserted_pages_output_intents	_sign_keytitlesection_title_stylescore_fonts_encodingfont_aliasesr~   r   font_family
font_style	underlinestrikethroughfont_size_ptfont_stretchingchar_spacingcurrent_fontcurrent_font_is_set_on_pageDEFAULT_DRAW_COLOR
draw_colorDEFAULT_FILL_COLOR
fill_colorDEFAULT_TEXT_COLOR
text_colorpage_backgrounddictdash_pattern
line_widthrI   FILL	text_moder   dw_ptdh_pt_set_orientationcur_orientationdef_orientationxr   l_margint_margin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_pointsrk   _resource_catalogr   list_text_quad_pointsbuffer)r   orientationunitr   font_cache_dirmargin	__class__s         r    r   FPDF.__init__   s3   ( \)MM6 #*, 	',$	
 		 *,


 %<$ #)-& $&'#24#.0 %).&#$ !
$&!#, + !#$
 "$' "" +0(111111# aQa8$&&.! "1!@
DJk::tzzB#33 &7A4t}(  q6z2k*"& %\\(,,7!%"$*/'%)"0I0K-(-%!0!2 "-T!2 r   Fc           	      *    [        U UUUUUS9U l        g)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)r4   r  )r   r&  r'  r)  permissionsr*  s         r    set_encryptionFPDF.set_encryption  s#    0 "9)'"/-"
r   c                     U R                   " U /UQ70 UD6nU R                  5          UR                  U5        SSS5        g! , (       d  f       g= f)at  
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.9**]
        numeric indentation of `<li>` elements - Set `tag_styles` instead
    dd_tag_indent (int): [**DEPRECATED since v2.7.9**]
        numeric indentation of `<dd>` elements - Set `tag_styles` instead
    table_line_separators (bool): enable horizontal line separators in `<table>`. Defaults to `False`.
    ul_bullet_char (str): bullet character preceding `<li>` items in `<ul>` lists.
        Can also be configured using the HTML `type` attribute of `<ul>` tags.
    li_prefix_color (tuple, str, fpdf.drawing.DeviceCMYK, fpdf.drawing.DeviceGray, fpdf.drawing.DeviceRGB): color for bullets
        or numbers preceding `<li>` tags. This applies to both `<ul>` & `<ol>` lists.
    heading_sizes (dict): [**DEPRECATED since v2.7.9**]
        font size per heading level names ("h1", "h2"...) - Set `tag_styles` instead
    pre_code_font (str): [**DEPRECATED since v2.7.9**]
        font to use for `<pre>` & `<code>` blocks - Set `tag_styles` instead
    warn_on_tags_not_matching (bool): control warnings production for unmatched HTML tags. Defaults to `True`.
    tag_indents (dict): [**DEPRECATED since v2.8.0**]
        mapping of HTML tag names to numeric values representing their horizontal left indentation. - Set `tag_styles` instead
    tag_styles (dict[str, fpdf.fonts.TextStyle]): mapping of HTML tag names to `fpdf.TextStyle` or `fpdf.FontFace` instances
N)HTML2FPDF_CLASSlocal_contextfeed)r   textr   r   html2pdfs        r    
write_htmlFPDF.write_html  sB    4 ''>t>v>!MM$ "!!s   A
Ac                 :    [        U R                  U5      U l        g N)maxr  )r   versions     r    _set_min_pdf_versionFPDF._set_min_pdf_version  s    t//9r   returnc                     U R                   nU R                  (       a  US-  nU R                  (       a  US-  n[        R                  " U5      $ )zIThe current text emphasis: bold, italics, underline and/or strikethrough.SU)r   r   r   rG   coerce)r   r   s     r    emphasisFPDF.emphasis  sB     __
#J>>#J"":..r   c                 Z    U R                   =(       a    U R                   R                  S:H  $ )NTTF)r   typer   s    r    is_ttf_fontFPDF.is_ttf_font  s$      DT%6%6%;%;u%DDr   c                     U R                   $ r7  )r  rF  s    r    	page_modeFPDF.page_mode  s    r   c                     [         R                  " U5      U l        U R                  [         R                  :X  a  U R	                  S5        g U R                  [         R
                  :X  a  U R	                  S5        g g )N1.61.5)rA   r@  r  USE_ATTACHMENTSr:  USE_OC)r   rJ  s     r    rJ  rK    sU    "//)4??h666%%e,__/%%e, 0r   c                 6    U R                   R                  5       $ r7  )r   valuesrF  s    r    output_intentsFPDF.output_intents  s    ##**,,r   subtypeoutput_condition_identifieroutput_conditionregistry_namedest_output_profileinfoc                     UR                   U R                  ;   a  [        SUR                   -   S-   5      e[        UUUUUU5      U R                  UR                   '   U R	                  S5        g)a  
Adds desired Output Intent to the Output Intents array:

Args:
    subtype (OutputIntentSubType, required): PDFA, PDFX or ISOPDF
    output_condition_identifier (str, required): see the Name in
        https://www.color.org/registry.xalter
    output_condition (str, optional): see the Definition in
        https://www.color.org/registry.xalter
    registry_name (str, optional): "https://www.color.org"
    dest_output_profile (PDFICCProfile, required/optional):
        PDFICCProfile | None # (required  if
        output_condition_identifier does not specify a standard
        production condition; optional otherwise)
    info (str, required/optional see dest_output_profile): human
        readable description of profile
zadd_output_intent: subtype 'z' already exists.1.4N)valuer   
ValueErrorrn   r:  )r   rU  rV  rW  rX  rY  rZ  s          r    add_output_intentFPDF.add_output_intent  ss    4 ==D000.>ATT  /E'/
W]]+ 	!!%(r   c                 N    U R                   U R                  -
  U R                  -
  $ )zD
Effective page width: the page width minus its horizontal margins.
)wr  r_marginrF  s    r    epwFPDF.epw       
 vv%55r   c                 N    U R                   U R                  -
  U R                  -
  $ )zD
Effective page height: the page height minus its vertical margins.
)hr	  b_marginrF  s    r    ephFPDF.eph  rf  r   c                 ,    [        U R                  5      $ )z*
Returns the total pages of the document.
)lenr   rF  s    r    pages_countFPDF.pages_count  s    
 4::r   c                 ^    U R                  X5        U R                  U R                  U5        g)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_marginFPDF.set_margin"  s(     	(  !5!5v>r   c                     U R                  U5        U R                  U:  d  U R                  U R                  :X  a  X l        X l        US:X  a  UnX0l        g)a  
Sets the document left, top & optionally 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
N)set_left_marginr   r	  rc  )r   lefttoprights       r    r
  FPDF.set_margins,  sG     	T"66C<466T]]2FB;Er   c                 p    U R                   U:  d  U R                   U R                  :X  a  Xl         Xl        g)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  rr  s     r    rw  FPDF.set_left_margin?  s(     66F?dff5Fr   c                     Xl         g)zk
Sets the document top margin.

Args:
    margin (float): margin in the unit specified to FPDF constructor
N)r	  rr  s     r    set_top_marginFPDF.set_top_marginK  	     r   c                     Xl         g)zm
Sets the document right margin.

Args:
    margin (float): margin in the unit specified to FPDF constructor
N)rc  rr  s     r    set_right_marginFPDF.set_right_marginT  r  r   r   c                 X    Xl         X l        U R                  U R                  -
  U l        g)a*  
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)rq  ri  rh  page_break_trigger)r   autor"  s      r    r  FPDF.set_auto_page_break]  s$      $"&&&4=="8r   c                     U R                   [        R                  :X  a  U R                  U R                  4$ U R                  U R                  4$ )zGReturn a pair (width, height) in the unit specified to FPDF constructor)r  rB   PORTRAITr  r  rF  s    r    default_page_dimensionsFPDF.default_page_dimensionsk  sF    
 ##'?'?? ZZ$	
 **djj)	
r   c                    [         R                  " U5      U l        U R                  [         R                  L a  X l        X0l        OX0l        X l        U R                  U R                  -  U l        U R
                  U R                  -  U l        [        U S5      (       a'  U R                  U R                  U R                  5        g g )Nrq  )rB   r@  r  r  w_pth_ptr   rb  rh  hasattrr  rq  ri  )r   r  page_width_ptpage_height_pts       r    r  FPDF._set_orientationt  s    .55kB?#;#;;%I&I&I%ITVV#TVV#4*++$$T%9%94==I ,r   c                     U[         ;   d  [        U[        5      (       d  Xl        OUS:w  a  [	        SU 35      e[
        R                  X"5      U l        g)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".
r   zIncorrect zoom display mode: N)rg   r   r   	zoom_moderN   LAYOUT_ALIASESr   page_layout)r   zoomlayouts      r    r  FPDF.set_display_mode  sK    $ <z$'<'<!NY"?v FGG)--f=r   use_shaping_enginefeatures	directionscriptlanguagec                    U(       d  SU l         g SSKnU(       a   [	        U[
        5      (       d  [        S5      eU(       d  0 nSnU(       a\  [	        U[        5      (       a  UO[        R                  " U5      nU[        R                  [        R                  4;  a  [        S5      eSUUUUSSS.U l         g! [         a  n[        S5      UeSnAff = f)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"
Nr   ziThe 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)r  r  r  r  r  fragment_directionparagraph_direction)
text_shaping	uharfbuzzImportErrorrN   r   r   rF   r@  LTRRTL)	r   r  r  r  r  r  r  exctext_directions	            r    set_text_shapingFPDF.set_text_shaping  s    . " $D	 Jx66O  H  i77 ")))4 
 m&7&79J9J%KK#f 
 #' ' "&#'
O  	{	s   B: :
CCCc                     U R                   $ r7  )_page_layoutrF  s    r    r  FPDF.page_layout  s       r   c                     U(       a  [         R                  " U5      OS U l        U R                  [         R                  [         R                  4;   a  U R                  S5        g g )NrN  )r@   r@  r  TWO_PAGE_LEFTTWO_PAGE_RIGHTr:  )r   r  s     r    r  r    sL    >IJ--k:t!9!9:;T;T UU%%e, Vr   c                     Xl         g)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_compressionFPDF.set_compression  s	     !r   c                     Xl         g)a	  
Defines the title of the document.

Most PDF readers will display it when viewing the document.
There is also a related `fpdf.prefs.ViewerPreferences` entry:

    pdf.viewer_preferences = ViewerPreferences(display_doc_title=True)

Args:
    title (str): the title
Nr   )r   r   s     r    	set_titleFPDF.set_title  s	     
r   c                 B    Xl         U(       a  U R                  S5        gg)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
r\  N)langr:  )r   r  s     r    set_langFPDF.set_lang  s     	%%e, r   c                     Xl         g)zZ
Defines the subject of the document.

Args:
    subject (str): the document main subject
N)subject)r   r  s     r    set_subjectFPDF.set_subject  s	     r   c                     Xl         g)zT
Defines the author of the document.

Args:
    author(str): the name of the author
N)author)r   r  s     r    
set_authorFPDF.set_author'  s	     r   c                     Xl         g)za
Associate keywords with the document

Args:
    keywords (str): a space-separated list of words
N)keywords)r   r  s     r    set_keywordsFPDF.set_keywords0  s	     !r   c                     Xl         g)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_creatorFPDF.set_creator9  s	     r   c                     Xl         g)zProducer of documentN)producer)r   r  s     r    set_producerFPDF.set_producerC  s     r   c                     U R                   (       a  [        S5      e[        U[        5      (       d  [	        S[        U5       35      eUR                  (       d  UR                  5       nXl        g)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   rN   r   r   	TypeErrorrE  tzinfo
astimezoner  )r   dates     r    set_creation_dateFPDF.set_creation_dateG  sX    >>T  $))A$t*NOO{{??$D!r   c                 j    SUS S ;   a  [        S5      eXl        U(       a  U R                  S5        g g )Nz	<?xpacket2   z@fpdf2 already performs XMP metadata wrapping in a <?xpacket> tagr\  )r^  r   r:  )r   r   s     r    set_xmp_metadataFPDF.set_xmp_metadataS  s?    ,s++R  )%%e, r   c                 ~    [         R                  " S[        [        5       S9  US:w  a  [	        SU S35      eX l        g)z
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*   rN   r   )r   optr]  s      r    set_doc_optionFPDF.set_doc_option\  sG     	S &(	
 ''";C5 BCC#( r   c                     U[         ;  a$  [        SU SSR                  [         5       35      eXR                  l        US:X  a  U R                  S5        gg)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   	JPXDecoderN  N)r]   r^  joinr   image_filterr:  )r   r  s     r    set_image_filterFPDF.set_image_filtert  se     66L> "&&(gg.E&F%GI  )5%;&%%e, 'r   c                     Xl         g)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` / `.strikethrough` attributes 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   FPDF.alias_nb_pages  s
    , #(r   label_stylelabel_prefixlabel_startc                    S nU R                   U R                  ;   a(  U R                  U R                      R                  5       nO:U R                   S:  a*  U R                  U R                   S-
     R                  5       nS nU(       d  U(       d  U(       a  U(       ae  Uc  UR                  5       nUc  UR	                  5       nUc<  U R
                  (       a  U R
                  R                  (       d  UR                  5       nU(       a  [        R                  " USS9OS n[        XU5      nU R                  U R                      R                  XE5        g )Nr!   Tcase_sensitive)r   r   get_page_label	get_style
get_prefixr   r   	get_startr?   r@  rj   set_page_label)r   r  r  r  current_page_labelnew_page_labels         r    r  FPDF.set_page_label  s    "99

"!%DII!6!E!E!GYY]!%DIIM!:!I!I!K,+!&"4">">"@K'#5#@#@#BL&((T-A-A-T-T"4">">"@K  %%k$G 
 *+[QN

499,,-?Pr   r   r  r   sameduration
transitionc	           	      
   U R                   (       a  [        S5      eSU l        U R                  n	U R                  n
U R
                  nU R                  nU R                  nU R                  nU R                  nU R                  nU R                  nU R                  nU R                  =(       a6    U R                  =(       a#    U R                  U R                   R"                  :  nU R                  S:  a(  U R                  (       a  U(       a  U R%                  5         U R                  S:X  a  SO&U R&                  U R                     R)                  5       nSnU(       d  U(       d  U(       a*  U(       a  [*        R,                  " USS9OSn[/        XgU5      nU R1                  UUUU=(       d    U R2                  U=(       d    U R4                  U R7                  5       (       + S9  U R&                  U R                     R9                  UU5        U R:                  (       a  [=        U R:                  [>        5      (       aZ  U R@                  " U R:                  6   U RC                  SSU RD                  U RF                  SS	9  U R@                  " URH                  6   O3U RK                  U R:                  SSU RD                  U RF                  5        U RM                  S
5        Xl        U RM                  XRN                  -  S S35        U	(       a  U RQ                  XU5        Xl        XRR                  :w  a-  U RM                  URU                  5       RW                  5       5        Xl        XRX                  :w  a-  U RM                  URU                  5       R[                  5       5        Xl	        U R                  (       a  U R                  (       a  U R]                  5         U R                  U:w  a'  Xl        U RM                  XRN                  -  S S35        U	(       a  U RQ                  XU5        U R                  U:w  a3  Xl        U RM                  URU                  5       RW                  5       5        U R                  U:w  a3  Xl        U RM                  URU                  5       R[                  5       5        Xl	        US:w  a  U R_                  U5        US:w  a  U Ra                  U5        U[c        SSSS9:w  a  U Re                  US   US   US   5        gg)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.
    label_style (str or PageLabelStyle): Defines the numbering style for the numeric portion of each
        page label. Possible values are:
        - "D": Decimal Arabic numerals.
        - "R": Uppercase Roman numerals.
        - "r": Lowercase Roman numerals.
        - "A": Uppercase letters (A to Z for the first 26 pages, followed by AA to ZZ, etc.).
        - "a": Lowercase letters (a to z for the first 26 pages, followed by aa to zz, etc.).
    label_prefix (str): Prefix string applied to the page label, preceding the numeric portion.
    label_start (int): Starting number for the first page of a page label range.
zCA page cannot be added on a closed document, after calling output()Fr   NTr  )new_pageFstylez2 J.2f wr   r   r   r   r   )3r  rN   r   r   rA  r   r   r   r   r   r   r   r   r   r   r   r   r   _render_footerr   r  r?   r@  rj   
_beginpager   r   _has_next_pager  r   r   tupleset_fill_colorrectrb  rh  	colors255image_outr   set_fontr   	serializeupperr   r   headerset_stretchingset_char_spacingr   _write_dash_pattern)r   r  r   r  r  r  r  r  r  familyrA  sizelwdcfctc
stretchingr   r   in_toc_extra_pager  r  s                         r    add_pageFPDF.add_page  s   V ;;U  ,1(!!==  ________))
(((( !! <..<		D00;;; 	
 99q=$"7"7;L! IIND

499(=(L(L(N 	 ,+  %%k$G 
 *+[QN 	***.$..,,.. 	 	
 	

499,,-?P$..66##T%9%9:		!Qc	:##R\\2

4//AtvvtvvF		%		R&&[%R() MM&D1 (((IIblln**,-(((IIblln**,- %%$*H*HKKM??b  OIIffS),-MM&D1??b  OIIblln**,-??b  OIIblln**,-
+1!!,/4QAQ77$$V$l5&9<;P 8r   c                    SU l         U R                  (       a   U R                  5         U R                  5         U R	                  5         U R                  (       a   U R                  5         U R                  5         SU l         g )NTF)r   r   _push_local_stack_start_local_contextfooter_end_local_context_pop_local_stackrF  s    r    r  FPDF._render_footerR  s]     ""$%%'##%!!#r   c                 |   U =R                   S-  sl         U R                  (       aE  U R                  (       a4  U =R                  S-  sl        [	        U R
                  5      S-   U l         SnU(       aO  [        [        5       UUU R                   S9nXpR
                  U R                   '   U(       a  U R                  S5        OU R
                  U R                      nU R                  U l
        U R                  U l        SU l        SU l        SU l        U(       a#  U(       d  U(       a  [!        SU S	U S
U 35      eO[U(       a  [#        X R$                  5      OU R&                  U R(                  4u  pU R+                  U=(       d    U R,                  X5        UR/                  U R0                  U R2                  5        g )Nr!   T)contentsr  r  indexrN  r   r   r   zInconsistent parameters: same=z but orientation=z format=)r   r   r   r   rm  r   ri   	bytearrayr:  r  r  r	  r   r   r   r   r^  r   r   r  r  r  r  set_dimensionsr  r  )
r   r  r   r  r  r  r  r   r  r  s
             r    r  FPDF._beginpage_  sc    			Q	  T%C%C$$)$DJJ!+DIH"!%ii	D %)JJtyy!))%0::dii(D"f 4TF:KK=X`ag`hi  % 4:/

DJJ?W *M !!3t33] 	DIItyy1r   c                     g)a  
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.

Note that header rendering can have an impact on the initial
(x,y) position when starting to render the page content.
Nr   rF  s    r    r  FPDF.header      r   c                     g)a<  
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   rF  s    r    r!  FPDF.footer  r-  r   c                     U R                   $ )zGet the current page numberr   rF  s    r    page_noFPDF.page_no  s    yyr   c                 P    U R                   U R                     R                  5       $ r7  )r   r   	get_labelrF  s    r    r  FPDF.get_page_label  s    zz$))$..00r   c                     [        XU5      nX@R                  :w  aO  X@l        U R                  S:  a8  U R                  U R                  R	                  5       R                  5       5        ggg)a  
Defines the color used for all stroking operations (lines, rectangles and cell borders).
Accepts either a single greyscale value, 3 values as RGB components, a single `#abc` or `#abcdef` hexadecimal color string,
or an instance of `fpdf.drawing.DeviceCMYK`, `fpdf.drawing.DeviceRGB` or `fpdf.drawing.DeviceGray`.
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)r3   r   r   r  r  r  )r   rgbr   s        r    set_draw_colorFPDF.set_draw_color  V     -Q15
((Oyy1}		$//335;;=>  )r   c                     [        XU5      nX@R                  :w  aO  X@l        U R                  S:  a8  U R                  U R                  R	                  5       R                  5       5        ggg)a  
Defines the color used for all filling operations (filled rectangles and cell backgrounds).
Accepts either a single greyscale value, 3 values as RGB components, a single `#abc` or `#abcdef` hexadecimal color string,
or an instance of `fpdf.drawing.DeviceCMYK`, `fpdf.drawing.DeviceRGB` or `fpdf.drawing.DeviceGray`.
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)r3   r   r   r  r  r   )r   r8  r9  r:  r   s        r    r  FPDF.set_fill_color  r=  r   c                 &    [        XU5      U l        g)a  
Defines the color used for text.
Accepts either a single greyscale value, 3 values as RGB components, a single `#abc` or `#abcdef` hexadecimal color string,
or an instance of `fpdf.drawing.DeviceCMYK`, `fpdf.drawing.DeviceRGB` or `fpdf.drawing.DeviceGray`.
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)r3   r   )r   r8  r9  r:  s       r    set_text_colorFPDF.set_text_color  s     2!:r   c                     U(       a  UOU R                  U5      nSnU R                  X5       H  nXER                  5       -  nM     U$ )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_preload_bidirectional_text	get_width)r   s
normalizedmarkdownrb  frags         r    get_string_widthFPDF.get_string_width  sG     A!4!4Q!744QAD!!A Br   c                     XR                   :w  a9  Xl         U R                  S:  a"  U R                  XR                  -  S S35        ggg)a  
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_widthFPDF.set_line_width  sD     OO##Oyy1}		UVV^C034  $r   c                    [        U[        [        R                  [        [
        [        [        S5      45      (       a.  [        U[
        5      (       a  UR                  U l	        gXl	        g[        S[        U5       35      e)a  
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 containing 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  rE  r
  r   r  )r   
backgrounds     r    set_page_backgroundFPDF.set_page_background  sp     bjj%E4:N
 
 *i00'1';';$'1$:# r   c           	   #   v  #    U R                   b  [        S5      e[        5       nX l          Uv   SU l         U R                  5       nU R                  [        U R                  U R                  5      U R                  U R                  U4nU(       a  UR                  " / UQUP76 nOUR                  " U6 nU R                  R                  U5       HG  nU R                  R                  [         R"                  UR%                  S5      U R&                  5        MI     U R(                  R                  U5       HP  nU R                  R                  [         R*                  [-        UR%                  S5      5      U R&                  5        MR     U R/                  U5        U R1                  S5        g! SU l         f = f7f)at  
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\  )r  rN   r-   _current_graphic_styler  r1   r  r   r   rh  render_debugrender	_GS_REGEXfinditerr  addrD   EXT_G_STATEgroupr   
_IMG_REGEXX_OBJECTr   r  r:  )r   debug_streamcontextstarting_stylerender_argsrenderedmatchs          r    drawing_contextFPDF.drawing_context  sk     %%1K  !"%,"	.M)-D&44611$&&$&&!FFFF
 ++G[G,GH~~{3H^^,,X6E""&&++U[[^TYY 7
 __--h7E""&&((#ekk!n*=tyy 8 			(!!%(= *.D&s   )F9F- E=F9-	F66F9c              #     #    U R                   R                  [        R                  XR                  5        UR                  5       nU R                   R                  [        R                  X R                  5      nU R                  SU S35         Sv   U R                  U R                  R                  5       R                  5       5        g! U R                  U R                  R                  5       R                  5       5        f = f7f)zC
Create a context for using a shading pattern on the current page.
z/Pattern cs /z scnN)r  r]  rD   SHADDINGr   get_patternPATTERNr  r   r  r   )r   shadingpatternpattern_names       r    use_patternFPDF.use_patternM  s      	""?#;#;WiiP%%'--11##Wii
 			M,t45	;IIdoo//1779:DIIdoo//1779:s   BD	C 8D	9DD	c                 ~   [        5       nU R                  Ul        U R                  Ul        U R
                  U R                  :w  a  U R
                  Ul        U R                  U R                  :w  a  U R                  Ul        U R                  nUS   US   4nUS   S:X  d	  US   S:X  a  S nX1l        US   Ul        U$ )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    rX  FPDF._current_graphic_style^  s    _ $ > >
 //??d555"ooBO??d555 OOBM%%	!&)9U+;<Oq l1o&:L!-(1	r   c              #      #    U R                  US9 n[        XS9nX6R                  l        Uv   UR	                  U5        SSS5        g! , (       d  f       g= f7f)a  
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`.

rb  )r  r   N)rh  r0   r  
paint_ruleadd_item)r   r  r   r~  rb  ctxtpaths          r    new_pathFPDF.new_pathv  sJ       !!|!<(D$.JJ!JMM$	 =<<s   A/A
	A

AAc                 x    U R                  US9 nUR                  U5        SSS5        g! , (       d  f       g= f)a  
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)rh  r  )r   r  rb  r  s       r    	draw_pathFPDF.draw_path  s/     !!|!<MM$ =<<s   +
9c                 p   [        U[        [        45      (       a  US:  d  [        S5      e[        U[        [        45      (       a  US:  d  [        S5      e[        U[        [        45      (       a  US:  d  [        S5      e[	        XUS9nX@R
                  :w  a  X@l        U R                  XU5        gg)ak  
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   ro  s        r    set_dash_patternFPDF.set_dash_pattern  s     4#u..419MNN3e--#(LMM53,//EQJGHHD7''' '$$T6 (r   c                     U(       a_  U(       a4  SXR                   -  S SX R                   -  S SX0R                   -  S S3nO&SXR                   -  S SX0R                   -  S S3nOSnU R                  U5        g )N[z.3f z] z dz[] 0 d)r   r  )r   r   r   r   dstrs        r    r  FPDF._write_dash_pattern  su    4&&=-QsVV|C.@5&&=QTBUUWX4&&=-Rvvc/B"ED		$r   c           
          U R                  XR                  -  S SU R                  U-
  U R                  -  S SX0R                  -  S SU R                  U-
  U R                  -  S S35        g)z
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   rh  )r   x1y1x2y2s        r    line	FPDF.line  sj     			FF{3q$&&2+!7 <CVVC?PPQtvv%c*$0	
r   c                 &   U(       a"  [         R                  " S[        [        5       S9  U(       a  Uc  [        R
                  nOB[        R                  " U5      nU(       a%  U[        R                  :X  a  [        SU SU 35      eSnU HM  nU R                  US   U R                  -  S S	U R                  US
   -
  U R                  -  S S	U 35        SnMO     U(       a  U R                  S5        U R                  S	UR                   35        g)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!   lz h)r   r   r   r*   rE   DFr@  Dr^  r  r   rh  operator)r   
point_listfillpolygonr  r  points          r    polylineFPDF.polyline  s      MM: #*, EMNNE&&u-E. 8iwO  EII8dff$S)DFFU1X,=+G*LAhZX H	  
 IIdO		Aenn%&'r   c                 &    U R                  XSUS9  g)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  FPDF.polygon  s     	jTGr   r!   c                     [         R                  " S[        [        5       S9  U R	                  XV5        U R                  XX45        U R	                  5         g)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_lineFPDF.dashed_line	  sK      	T &(	
 	k8		""!r   c                 >   [         R                  " U5      nUSLa  U R                  XX4XVU5        gU R                  XR                  -  S SU R
                  U-
  U R                  -  S SX0R                  -  S SU* U R                  -  S SUR                   3	5        g)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)rE   r@  _draw_rounded_rectr  r   rh  r  )r   r  r   rb  rh  r  round_cornerscorner_radiuss           r    r	  	FPDF.rect&  s    < ""5)%##A!mTIIvv:c"!TVVaZ466$9##>aFF
3?Oq2;s#4'79r   c                 T   UnX4:  a  UnUS:X  a  US-  nXxS-  :  a  Xx-  nX4=pX-   U4=pX-   X$-   4=pXU-   4=nnXU-   XU-   /nX"X$-   X$-   /nUSL af  [         R                  R                  [         R                  R                  [         R                  R                  [         R
                  R                  4n[        S U 5       5      n[         R                  U;   a)  U R                  US   US   SU-  SSUS9  X-   U4n	XU-   4n
[         R                  U;   a4  U R                  US	   SU-  -
  US	   SU-  SSUS9  X-   U-
  U4nX-   X'-   4n[         R
                  U;   a?  U R                  US
   SU-  -
  US
   SU-  -
  SU-  SSUS9  X-   X$-   U-
  4nX-   U-
  X$-   4n[         R                  U;   a4  U R                  US   US   SU-  -
  SU-  SSUS9  X-   X$-   4nXU-   U-
  4nUR                  (       a  U R                  U	UUUUUUU
U	/	SS9  UR                  (       a  U R                  U	S   U	S	   US   US	   5        U R                  US   US	   US   US	   5        U R                  US   US	   US   US	   5        U R                  US   US	   U
S   U
S	   5        g g )Nr      r   Tc              3   N   #    U  H  n[         R                  " U5      v   M     g 7fr7  )r;   r@  ).0rcs     r    	<genexpr>*FPDF._draw_rounded_rect.<locals>.<genexpr>f  s     H-BfmmB//-s   #%   i  r   r!      Z   r  )r;   	TOP_RIGHTr]  TOP_LEFTBOTTOM_RIGHTBOTTOM_LEFTr  arcis_fillr  is_drawr  )r   r  r   rb  rh  r  r  r8  minpoint_1point_8point_2point_3point_4point_5point_6point_7coor_xcoor_ys                      r    r  FPDF._draw_rounded_rectM  s   5C6aAa<HAF"UAJ&UAEN*AJ&'UA1u%qu%D   &&%%##))""((	M H-HH},HHVAYq	1q5#s%HHuajGa%jG??m+HHVAYQ&q	1q5#qHNuqy!nGuaenG.HHVAYQ&q	AE(91q5!RuHUuaeai(Guqy!%(G-/HHVAYq	AE 11q5"cHOuaenGa%!)nG==MM
    ==IIgaj'!*gaj'!*EIIgaj'!*gaj'!*EIIgaj'!*gaj'!*EIIgaj'!*gaj'!*E	 r   c                 j    [         R                  " U5      nU R                  XX4UR                  5        g)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)rE   r@  _draw_ellipser  )r   r  r   rb  rh  r  s         r    ellipseFPDF.ellipse  s*    " ""5)1u~~6r   c                 f   XS-  -   nX$S-  -   nUS-  nUS-  n	S[         R                  " S5      S-
  -  U-  n
S[         R                  " S5      S-
  -  U	-  nU R                  Xh-   U R                  -  S SU R                  U-
  U R                  -  S SXh-   U R                  -  S SU R                  U-
  U-   U R                  -  S SXj-   U R                  -  S SU R                  U-
  U	-   U R                  -  S SX`R                  -  S SU R                  U-
  U	-   U R                  -  S S35        U R                  Xj-
  U R                  -  S SU R                  U-
  U	-   U R                  -  S SXh-
  U R                  -  S SU R                  U-
  U-   U R                  -  S SXh-
  U R                  -  S SU R                  U-
  U R                  -  S S35        U R                  Xh-
  U R                  -  S SU R                  U-
  U-
  U R                  -  S SXj-
  U R                  -  S SU R                  U-
  U	-
  U R                  -  S SX`R                  -  S SU R                  U-
  U	-
  U R                  -  S S35        U R                  Xj-   U R                  -  S SU R                  U-
  U	-
  U R                  -  S SXh-   U R                  -  S SU R                  U-
  U-
  U R                  -  S SXh-   U R                  -  S SU R                  U-
  U R                  -  S SU 35        g )	Nr   gUUUUUU?r!   r  r  r   cz c )mathsqrtr  r   rh  )r   r  r   rb  rh  r  cxcyrxrylxlys               r    r  FPDF._draw_ellipse  s?   QYQYUUdiilQ&'",diilQ&'",		Gtvv%c*!TVVb[DFF,B3+GsGtvv%c*!TVVb[2-=,G+LAGtvv%c*!TVVb[2-=,G+LA;s#1dffrkB&6$&&%@$ERI	
 			Gtvv%c*!TVVb[2-=,G+LAGtvv%c*!TVVb[2-=,G+LAGtvv%c*!TVVb[DFF,B3+GrK	
 			Gtvv%c*!TVVb[2-=,G+LAGtvv%c*!TVVb[2-=,G+LA;s#1dffrkB&6$&&%@$ERI	
 			Gtvv%c*!TVVb[2-=,G+LAGtvv%c*!TVVb[2-=,G+LAGtvv%c*!TVVb[DFF,B3+Gs8*V	
r   c                 B    U R                  X-
  X#-
  SU-  SU-  U5        g)a  
Outputs a circle.
It can be drawn (border only), filled (with no border) or both.

WARNING: This method changed parameters in [release 2.8.0](https://github.com/py-pdf/fpdf2/releases/tag/2.8.0)

Args:
    x (float): Abscissa of upper-left bounding box.
    y (float): Ordinate of upper-left bounding box.
    radius (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
r   N)r  )r   r  r   radiusr  s        r    circleFPDF.circle  s$    $ 	QZQZVUKr   c           
         US-  nX-   nX'-
  n	/ n
[        SUS-   5       H  nX[        R                  " [        R                  " SU-  U-  5      [        R                  " U5      -   5      -  -   X[        R                  " [        R                  " SU-  U-  5      [        R                  " U5      -   5      -  -   4nU
R                  U5        M     U R                  XS9  g)aA  
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)ranger  cosradianssinappendr  )r   r  r   numSides	polyWidthrotateDegreesr  r  centerXcenterYpointsir  s                r    regular_polygonFPDF.regular_polygon  s    & Q**q(Q,'AtxxcHn12T\\-5PP(  $((cHn12T\\-5PP#  E
 MM%  ( 	V)r   c                 |   [         R                  " U5      n/ n	[        SUS-  S-   5       H}  n
XS-  S:X  a  UOU[         R                  " U5      -  -   nX*S-  S:X  a  UOU[         R                  " U5      -  -   nU	R                  X45        U[         R                  " SU-  5      -  nM     U R                  U	SUS9  g)an  
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!   r  T)r  r  N)r  r  r  r  r  r  r  )r   r  r   r_inr_outcornersrotate_degreesr  thr  r  corner_xcorner_ys                r    star	FPDF.star  s    ( \\.)
q7Q;!+,AUaZETTXXb\IIHUaZETTXXb\IIHx23$,,sW}--B - 	j$e<r   c                 F  ^^^ ^!^"^#^$ [         R                  " U5      nTc  TmTS-  mTS-  mUT-   m!UT-   m"S m#UUU#4S jnT#" U5      n[        R                  " U5      m [        R                  " U5      m$UUU U!U"U$4S jnUUU U$4S jnU" U5      nU" U5      nU(       d  UU::  a  US[        R
                  -  -  nO#U(       a  UU:  a  US[        R
                  -  -  nU" U5      nU	(       a  U R                  T!U R                  -  S SU R                  T"-
  U R                  -  S S	35        U R                  US
   U R                  -  S SU R                  US   -
  U R                  -  S S35        OFU R                  US
   U R                  -  S SU R                  US   -
  U R                  -  S S	35        Sn[        U[        R                  " [        UU-
  5      S[        R
                  -  U-  -  5      5      nUU-
  U-  n[        R                  " U5      [        R                  " SS[        R                  " US-  5      S-  -  -   5      S-
  -  S-  nUnU" U5      nU" U5      n[        U5       GH)  nUnUnUU-  nU" U5      nU" U5      nUS
   UUS
   -  -   US   UUS   -  -   /nUS
   UUS
   -  -
  US   UUS   -  -
  /nSnUUS-
  :X  a  U
(       d  SUR                   3nU R                  US
   U R                  -  S SU R                  US   -
  U R                  -  S SUS
   U R                  -  S SU R                  US   -
  U R                  -  S SUS
   U R                  -  S SU R                  US   -
  U R                  -  S S3U-   5        GM,     U
(       as  U	(       a  U R                  SUR                   35        gU R                  T!U R                  -  S SU R                  T"-
  U R                  -  S SUR                   35        gg)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                 .    U [         R                  -  S-  $ )Nr  )r  pi)degs    r    
deg_to_radFPDF.arc.<locals>.deg_to_radR  s    =3&&r   c                    > T" U S-  5      n [         R                  " [         R                  " U 5      T-  [         R                  " U 5      T-  5      nUS:  a  US[         R                  -  -  nU$ )Nr  r   r   )r  atan2r  r  r  )angleetaar:  r  s     r    angle_to_param FPDF.arc.<locals>.angle_to_paramU  sY    us{+E**TXXe_q0$((5/A2EFCQwq477{"Jr   c                    > T[         R                  " U 5      -  nT[         R                  " U 5      -  nTUT-  -   UT-  -
  TUT-  -   UT-  -   /$ r7  )r  r  r  )	r  	a_cos_eta	b_sin_etar  r:  	cos_thetar  r  	sin_thetas	      r    evaluateFPDF.arc.<locals>.evaluatea  sa    DHHSM)IDHHSM)I Y**Y-BBY**Y-BB r   c                    > T[         R                  " U 5      -  nT[         R                  " U 5      -  nU* T-  UT-  -
  U* T-  UT-  -   /$ r7  )r  r  r  )r  	a_sin_eta	b_cos_etar  r:  r  r  s      r    derivative_evaluate%FPDF.arc.<locals>.derivative_evaluatej  s[    DHHSM)IDHHSM)I 
Y&Y)>>
Y&Y)>> r   r  r  z mr   r!   z l   r  r   r  zh z l )rE   r@  r  r  r  r  r  r   rh  r  ceilabsr  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_primer  p1p1_primecontrol_point_1control_point_2endr  r  r  r  r  s%      `  `                         @@@@@r    r  FPDF.arc$  s=   D ""5)9A	Q	QUU	'	 ;'HHUO	HHUO		 		 	 #;/	 +W	1q477{"G7i/TWW$Iy) IIdffS)DFFRK466+A#*FbIJIIq>DFF*3/q$&&;q>2ITVV1STW0XXZ[ IIq>DFF*3/q$&&;q>2ITVV1STW0XXZ[
 
		#g	&9":a$''kJ>V"WX
 9$)499QTXXeai5HA5M1M-M#NQR#RSVWWd^&t,qABHEMD$B*40H!!uux{'::BqEEHUVKDW<WXO!!uux{'::BqEEHUVKDW<WXOCAEz-%..)*II&q)DFF237q$&&?STCU:UY]Y_Y_9_`c8dde&q)DFF237q$&&?STCU:UY]Y_Y_9_`c8dde!utvv~c*!TVVbe^tvv,Ec+J"NPST .  		Bu~~./0		DFF{3'q$&&2+)?(DCGWX	 r   c
                 :    U R                  UUUUUUUUSSU	5        g)aK  
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_arcFPDF.solid_arc  s1    > 		
r   c           	      @   [        U5      nUS;  a  [        S5      e[        R                  " U5      nU R	                  5        nUS   nUS   US   p[        Xx5      n	UR                  U	5        US   n
U
S   U
S   pUS   nUS   US   pUS:X  a  US   nUS   US   nn[        Xx5      n[        R                  nUR                  (       a"  UR                  (       d  [        R                  nO2UR                  (       a!  UR                  (       d  [        R                  nUUR                  l        UUR                  l        US:X  a  UR!                  XXWW5        OUS:X  a  UR!                  XXX5        UR                  U5        SSS5        g! , (       d  f       g= f)	u  
Outputs a quadratic or cubic Bézier curve, defined by three or four coordinates.

Args:
    point_list (list of tuples): List of Abscissa and Ordinate of
                                segments that should be drawn. Should be
                                three or four tuples. The first and last
                                points are the start and end point. The
                                middle point(s) are the control point(s).
    closed (bool): True to draw the curve as a closed path, False (default)
                                for it to be drawn as an open path.
    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
)r  r  zWpoint_list should contain 3 tuples for a quadratic curve or 4 tuples for a cubic curve.r   r!   r   r  r  N)rm  r^  rE   r@  rh  r0   r  rC   STROKE_FILL_NONZEROr  r  STROKEFILL_NONZEROr  r~  
auto_closecurve_to)r   r  closedr  r  r  r+  r  r  
dummy_pathr)  r  r  p3x3y3p4x4y4r  rules                        r    bezierFPDF.bezier  sp   " Z2  ""5)
 !!#tABUBqE$R,JMM*%ABUBqEABUBqE{]A1Br&D !44D}}U]]$++u}}$11$(DJJ!$*DJJ!{bbb"51bbb5MM$E $##s   EF
Fc                 "   U(       d  [        S5      e[        [        U5      5      S   R                  5       nUS;  a  [        SU S35      eUS:w  a"  [        R
                  " S[        [        5       S9  S	R                  [        UR                  5       5      5      n[        S
 U 5       5      (       a  [        SU 35      eS[        4 H=  nU(       d  M  [        U5      U-  R                  5       (       d  M/  [        U5      U-  n  O   [        SU 35      eUc  UR                   nUR                  5        U 3nXR"                  ;   d
  U[$        ;   a"  [        R
                  " SU S3[        5       S9  g['        XX5      U R"                  U'   g)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. "" for regular, include 'B' for bold, and/or '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   *   #    U  H	  oS ;  v   M     g7fBINr   r  r   s     r    r   FPDF.add_font.<locals>.<genexpr>I  s     6fT!   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   rR   rV   )	r   r  r  fnameuniextparentfont_file_pathfontkeys	            r    add_fontFPDF.add_font$  s    <==s5z"1%++-663C5 9[ [  ,MM6 #*, u{{}-.6666KE7S  M*FVu$,,..!%f!5 + $&?w$GHH>#((F\\^$UG,jj Gz$9MM3G9<LM*, %dGK

7r   r  c                 r   U(       d  U R                   nUR                  5       n[        U[        5      (       a  UR                  nSR                  [        UR                  5       5      5      n[        S U 5       5      (       a  [        SU 35      eSU;   a  SU l
        UR                  SS5      nOSU l
        SU;   a  SU l        UR                  SS5      nOSU l        XR                  ;   aX  X-   U R                  ;  aF  [        R                   " SU S	U R                  U    S
3["        [%        5       S9  U R                  U   nO0US;   a*  U(       a#  [        R                   " SU S3[%        5       S9  SnU(       d  U R&                  nU R                   U:X  a,  U R(                  U:X  a  [+        U R&                  U5      (       a  gX-   nX@R                  ;  a2  U[,        ;  a  [/        SU S35      e[1        XU5      U R                  U'   Xl         X l        X0l        U R                  U   U l        SU l        g)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, fpdf.enums.TextEmphasis): empty string (by default) or a combination
        of one or several letters among B (bold), I (italic), S (strikethrough) 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   *   #    U  H	  oS ;  v   M     g7f)BISUNr   rI  s     r    r   FPDF.set_font.<locals>.<genexpr>  s     8%V#%rK  z;Unknown style provided (only B/I/S/U letters are allowed): r?  TFr>  z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() beforehand)r   r   r   rG   r  r  rM  r  rN  r^  r   replacer   r   r   r   r   r   r*   r   r   r	   rR   rN   rQ   r   r   )r   r  r  r  rX  s        r    r  FPDF.set_fontf  s   4 %%Fe\**KKEu{{}-.8%888MeWU  %<!DNMM#r*E"DN%<!%DMM#r*E!&D&&&6>+KMM$VHN4;L;LV;T:UNO"*,	 &&v.F11eMM  ). .*,
 E$$D &5())400 .**$j(#&wi 0G H 
 #+4%"@DJJw "  JJw/+0(r   c                 V    [        U R                  U5      (       a  gXl        SU l        g)zP
Configure the font size in points

Args:
    size (float): font size in points
NF)r	   r   r   )r   r  s     r    set_font_sizeFPDF.set_font_size  s(     4$$d++ +0(r   c                     SUR                    SUS S3nU(       a  SU S3nU R                  R                  [        R                  UR                   U R
                  5        SU l        U$ )z
Set font and size for current page.
This step is needed before adding text into page and not needed in set_font and set_font_size.
/Fr  r   TfBT  ETT)r  r  r]  rD   FONTr   r   )r   r   r   wrap_in_text_objectsls        r    _set_font_for_pageFPDF._set_font_for_page  sb    
 $&&<,C0rd#B""?#7#7K+/(	r   c                     U R                   U:X  a  gXl         U R                  S:  a  U R                  SUS S35        gg)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   ri  r  z Tc ET)r   r   r  )r   spacings     r    r  FPDF.set_char_spacing  sB     '#99q=IIGC=/0 r   c                     U R                   U:X  a  gXl         U R                  S:  a  U R                  SUS S35        gg)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   ri  r  z Tz ET)r   r   r  )r   r  s     r    r  FPDF.set_stretching  sC     :-)99q=IIJs+623 r   c                 .   / nU Hw  nSnU R                    HL  nUR                  SS5      R                  SS5      UR                  5       :X  d  M9  UR                  U5        SnMN     U(       a  Mj  [	        SU S35      e   [        U5      U l        X l        g)	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   ra  r   r  rN   r  r  r  )r   fallback_fontsexact_matchfallback_font_idsfallback_fontfoundrX  s          r    set_fallback_fontsFPDF.set_fallback_fonts  s     +ME::??3+33C<@S@S@UU%,,W5 E	 &
 5#/>_`  , #((9":*5'r   c                     [        US:X  a  U R                  OUU R                  XR                  -  -
  X R                  -  US9n[	        U R
                  5      S-   nXPR
                  U'   U$ )a  
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.
rv  )ry  rx  r  r!   )rt   r   r  r   rm  r   )r   r   r  r   r  link
link_indexs          r    add_linkFPDF.add_link	  sa    $ DII		AJ&VV	
 _q(
!%

:r   c                     U R                   U   nUS:X  a  U R                  OUUl        U R                  X R                  -  -
  Ul        X0R                  -  Ul        XQl        g)aM  
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.
rv  N)r   r   page_numberr  r   ry  rx  r  )r   r  r   r  r   r  s         r    set_linkFPDF.set_link1	  sN    $ zz$(,
49999q66z)J		r   c           
      F   Su  pU(       a  [        U[        5      (       a  [        U5      nO_XPR                  ;   d!   SU S[	        U R                  5       S35       eU R                  U   n	U	R
                  (       d  [        SU S35      e[         S
XR                  -  U R                  X R                  -  -
  X0R                  -  X@R                  -  UU	S.UD6n
U R                  U R                     R                  R                  U
5        Ub  U R                  SUS	9  U
$ )aX  
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=)zCannot insert link z with no page number assigned)r  r   rN  heightactiondestz/Link)struct_typealt_text)Link)r   r   r"   r   rm  r  r^  r$   r   r  r   r   annotsr  _add_marked_content)r   r  r   rb  rh  r  r  r   r  r  
link_annots              r    r  	FPDF.linkI	  s!   $ "$$$"4 JJ&X1$}S_DUUVWX&zz$'''$-dV3PQ  $	
&&jii!ff*$ff*vv:	
 	

 	

499$$++J7 $$8$Lr   c                    U(       a  U(       a  [        S5      eU(       a  [        S5      e[        U5      nUR                  S5       nUR                  5       nSSS5        UR                  nUR                  5       nUc.  [        R                  " UR                  5      R                  5       nO$U(       d  [        S5      eU(       d  [        S5      e[        S U R                   5       5      nX8;   a  [        U S35      e[        SUUUS	.UD6n	U R                  R                  U	5        U R                  S
5        U	$ ! , (       d  f       N= f)a  
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   @   #    U  H  oR                  5       v   M     g 7fr7  )basename)r  files     r    r  "FPDF.embed_file.<locals>.<genexpr>	  s      )
(;MMOO(;s   z' has already been embedded in this file)r  r&  modification_dater\  r   )r^  r   openreadnamestatr   fromtimestampst_mtimer  setr   r&   r  r:  )
r   	file_pathbytesr  r  r   
input_filestatsalready_embedded_basenamesembedded_files
             r    
embed_fileFPDF.embed_filez	  s9   .  !NOO !QRRYI%") & ~~HNN$E ($,$:$:5>>$J$U$U$W! !UVV K  &) )
(,(;(;)
 &
" 1z)PQRR' 
/
 	
 	""=1!!%(5 &%s   D??
Ec                    U R                   " U40 UD6n	U	R                  S5        [        SX R                  -  U R                  X0R                  -  -
  X@R                  -  XPR                  -  U	R                  5       U(       a  [        R                  " U5      OSUS9n
U R                  U R                     R                  R                  U
5        U
$ )a  
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FileAttachmentN)	file_specr  flags)r  set_globally_enclosedr$   r   r  r  r=   r@  r   r   r  r  )r   r  r  r   rb  rh  r  r  r   r  
annotations              r    file_attachment_annotationFPDF.file_attachment_annotation	  s    . 	<V<++E2#JIIFF
"JJ#--/>B-44T:	

 	

499$$++J7r   c                 D   [        SXR                  -  U R                  X R                  -  -
  X@R                  -  XPR                  -  4UU(       a  [        R                  " U5      OSS.UD6nU R
                  U R                     R                  R                  U5        U$ )u  
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
    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.
TextN)r&  r  )	r$   r   r  r9   r@  r   r   r  r  )	r   r  r   r2  rb  rh  r  r   r  s	            r    text_annotationFPDF.text_annotation	  s      $JIIFF
"JJ	
 04&&t,$	
 	

 	

499$$++J7r   c                    U R                   (       d  [        S5      eU R                  (       d5  U R                  U R	                  U R
                  U R                  5      5        Uc  U R                  nUc  U R                  nUc  U R                  nUc  U R                  USSS9n[        SX R                  -  U R                  X0R                  -  -
  X@R                  -  XPR                  -  4USU R                  R                  5        SU R
                  R                    SU R                  S	 S
3S.UD6nU R"                  U R$                     R&                  R)                  U5        U$ )a  
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
    color (tuple): a tuple of numbers in the range 0.0 to 1.0, representing a colour used for the annotation background
    border_width (float): width of the annotation border
3No font set, you need to call set_font() beforehandTFrH  rI  FreeText(z /Fr  r  z Tf))r&  default_appearance)r   rN   r   r  rn  r   r   r  r   	font_sizerK  r$   r   r  r   r  r  r   r   r  r  )r   r2  r  r   rb  rh  r   r  s           r    free_text_annotationFPDF.free_text_annotation	  sD   4  UVV//IId--d.?.?ARARST9A9A9A9%%dte%LA#JIIFF
"JJ	
 !"4??#<#<#>"?s4CTCTCVCVBWWXY]YjYjknXoost	
 	

 	

499$$++J7r   c                    [        SX R                  -  U R                  X0R                  -  -
  X@R                  -  XPR                  -  4SU0UD6nU R                  U R                     R
                  R                  U5        U$ )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
Actionr  )r$   r   r  r   r   r  r  )r   r  r  r   rb  rh  r   r  s           r    
add_actionFPDF.add_action*
  s{     $JIIFF
"JJ
 
 

 	

499$$++J7r   c           	   +     #    U R                   (       a  [        S5      eSU l         Sv   U R                  R                  5        H  u  pgU R                  " UU4UUUUS.UD6  M      [        [        5      U l        SU l         g7f)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_pointsmodification_timer   colorF)r  rN   r  itemsadd_text_markup_annotationr   r  )r   r2  rE  r  r  r   r   r  s           r    	highlightFPDF.highlightB
  s     " (( >??(,%!%!7!7!=!=!?D++ ("3  "@ "-T!2(-%s   B Bc              /      #    [         R                  " S[        [        5       S9  U R                  " U0 UD6   S v   S S S 5        g ! , (       d  f       g = f7f)Nz:add_highlight() has been renamed to highlight() in v2.5.5.r   )r   r   r   r*   r  )r   r   r   s      r    add_highlightFPDF.add_highlightd
  s>     H&(	

 ^^T,V, -,,s   5AA	A
AAc                    U R                  S5        [        R                  " U5      R                  nUc  U R                  nUc  U R
                  n[        USSS2   5      n[        USSS2   5      n	[        USSS2   5      n
[        USSS2   5      n[        U4UU	UX-
  X-
  UUUS.UD6nU R                  U   R                  R                  U5        U$ )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
rM  Nr   r   r!   )r&  r  r   rN  r  r  r  r  )r:  rH   r@  r]  r  r   r  r8  r$   r   r  r  )r   rE  r2  r  r  r  r   r   x_miny_minx_maxy_maxr  s                r    r  FPDF.add_text_markup_annotationn
  s    8 	!!%($$T*00$ $ 2 2<99DK1%&K1%&K1%&K1%&#
-=/#
 

 	

4&&z2r   c                 R  ^  [        U 4S jU 5       S5      n[        USSS2   5      n[        USSS2   5      n[        USSS2   5      n	[        USSS2   5      n
[         SUU
X-
  X-
  UUUUS.UD6nT R                  T R
                     R                  R                  U5        U$ )	uS  
Adds add an ink annotation on the page.

Args:
    coords (tuple): an iterable of coordinates (pairs of numbers) defining a path
    text (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 (float): thickness of the path stroke.
c              3   ~   >#    U  H2  u  pUTR                   -  TR                  U-
  TR                   -  4v   M4     g 7fr7  )r   rh  )r  r  r   r   s      r    r  &FPDF.ink_annotation.<locals>.<genexpr>
  s1     Q&TVVdffqjDFF%:;&s   :=r   r   Nr   r!   )r  r   rN  r  ink_listr&  border_widthr  )Ink)sumr  r8  r$   r   r   r  r  )r   coordsr2  r  r  r   r  r  r  r  r  r  s   `           r    ink_annotationFPDF.ink_annotation
  s      Q&QSUVHQTTN#HQTTN#HQTTN#HQTTN##
-=%
 

 	

499$$++J7r   c                 $   U R                   (       d  [        S5      eU R                  U5      nU R                  (       d5  U R	                  U R                  U R                  U R                  5      5        SXR                  -  S SU R                  U-
  U R                  -  S S3/nU R                  [        R                  :w  a-  UR                  SU R                   SU R                  S S35        UR                  U R                  R                  U5       S35        US	:w  a"  U R                   (       d"  U R"                  (       d  U R$                  (       a  U R'                  US
SS9nUS	:w  ad  U R                   (       a!  UR                  U R)                  XU5      5        U R"                  (       a!  UR                  U R+                  XU5      5        U R$                  (       a&  U R,                  nUSU-  -  nU R/                  XXV5        / nU R0                  U R2                  :w  a8  UR                  U R2                  R5                  5       R7                  5        5        U(       a  S/U-   U-   S/-   nU R	                  SR9                  U5      5        g)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

Notes
-----

`text()` lacks many of the features available in `FPDF.write()`,
`FPDF.cell()` and `FPDF.multi_cell()` like markdown and text shaping.
r  ri  r  r   Td Tr r  rj  r   TFr  g?qQN)r   rN   rD  r   r  rn  r   r   r   rh  r  rI   r   r  r   encode_textr   r   r  rK  _do_underline_do_strikethroughr  _add_quad_pointsr   r   r  r   r  )r   r  r   r2  rm  rb  rh  attr_ls           r    r2  	FPDF.text
  s   (  UVV""4(//IId--d.?.?ARARSTAJs#1dffqjDFF%:3$?sCD>>X]]*II$..)dooc-B"EF
		T&&22489=>BJDNNd.@.@**%%dte%LArz>>IId00q9:%%IId44Q1=>,,NNS1W%%aA1??doo-MMT__668>>@AC"$u,B		#((2,r   c                 &   [         R                  " S[        [        5       S9  Uc  U R                  nUc  U R
                  nU R                  S:w  a  U R                  S5        Xl        US:w  a  U[        R                  S-  -  n[        R                  " U5      n[        R                  " U5      nX R                  -  nU R                  U-
  U R                  -  nSUS S	US S	U* S S	US S	US
 S	US
 SU* S
 S	U* S
 S3nU R                  U5        gg)z:
.. 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  r  q .5Fr  .2F cm 1 0 0 1  cm)r   r   r   r*   r  r   r   r  r  r  r  r  r   rh  r   r  r  r   crG  r  r  s           r    rotateFPDF.rotate
  s    	> &(	
 9A9A;;!IIcNA:TWWs]"EAAVVB&&1*&BQsG1QsG1aRHAaWAbXQr#h G3s)1bSIS2  IIaL r   c              #     #    Uc  U R                   nUc  U R                  nU[        R                  S-  -  n[        R                  " U5      [        R
                  " U5      pTX R                  -  U R                  U-
  U R                  -  pvU R                  5          U R                  US SUS SU* S SUS SUS SUS SU* S SU* S S35        Sv   SSS5        g! , (       d  f       g= f7f)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.
Nr  r  r  r  r  r  )
r  r   r  r  r  r  r   rh  r0  r  r  s           r    rotationFPDF.rotation  s     6 9A9A3xx1VVdffqjDFF2B!IIS'1S'A2c(!Ac7!Bs81RH E3s)1bSIS2  "!!s   BC.9C	C.
C+'C.c              #   J  #    SnUc  U R                   nUc  U R                  n[        [        [        R
                  " U[        R                  S-  -  5      U5      U* 5      n[        [        [        R
                  " U[        R                  S-  -  5      U5      U* 5      nX0R                  -  U R                  U-
  U R                  -  pvU R                  5          U R                  SUS SUS SUS SUS S	US S
US S35        Sv   SSS5        g! , (       d  f       g= f7f)aS  
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        Nr  z1 .5fr  z 1 r   cm 1 0 0 1 - -r  )r  r   r8  r  r  r  r  r   rh  r0  r  )r   axayr  r   lim_valr  r  s           r    skew	FPDF.skewD  s     & 9A9ATXXbDGGcM23W=xHTXXbDGGcM23W=xHVVdffqjDFF2B!IIRHAbXSC"S :s82bXS2  "!!s   CD#/D		D#
D D#c              #   D  #    Uu  p4 [         R                  " U5      R                  n[        R
                  " [        R                  " US-  5      5      n[        R                  " [        R                  " US-  5      5      nX0R                  -  U R                  U-
  U R                  -  pU R                  5          U R                  US SUS SUS SUS-  S SUS SU	S SUS SU	S S35        S	v   S	S	S	5        g	! [         a    Un Nf = f! , (       d  f       g	= f7f)
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  rv  r  r  r  r  N)r7   r@  r]  r^  r  r  r  r  r   rh  r0  r  )
r   originr  r  r   r   r  r:  r  r  s
             r    mirrorFPDF.mirrorf  s    " 	LL'--E HHT\\%!),-HHT\\%!),-VVdffqjDFF2B!IIS'1S'1S'1R4*AbXQr#h Gs82bXS2  "!  	E	 "!s@   D  C= BD ;9D4	D =D	D DD 
DD c              +      #    U R                   (       a  [        S5      eU R                  5         U R                  " S0 UD6  Sv   U R	                  5         U R                  5         g7f)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
* char_vpos
* char_spacing
* dash_pattern
* denom_lift
* denom_scale
* draw_color
* fill_color
* fill_opacity
* font_family
* font_size
* font_size_pt
* font_style
* font_stretching
* intersection_rule
* line_width
* nom_lift
* nom_scale
* paint_rule
* strikethrough
* stroke_cap_style
* stroke_join_style
* stroke_miter_limit
* stroke_opacity
* sub_lift
* sub_scale
* sup_lift
* sup_scale
* text_color
* text_mode
* text_shaping
* underline

Font size can be specified in document units with `font_size` or in points with `font_size_pt`.

Args:
    **kwargs: key-values settings to set at the beginning of this context.
z@cannot create a local context inside an unbreakable() code blockNr   )r   rN   r  r   r"  r#  )r   r   s     r    r0  FPDF.local_context  s[     j R  	 !!+F+!s   A$A&c	                    SU	;   a#  Ub  [        S5      eU	S   U R                  -  nU	S	 Sn
U	R                  5        H  u  pUS;   a  [        SU S35      eU[        R                  ;   a4  U
c
  [        5       n
[        XU5        US:X  a  U R                  S5        M`  Mb  US	;   a  [        XU5        Mv  [        SU 35      e   U
(       ae  U R                  R                  U
5      nU R                  R                  [        R                  XR                  5        U R                  S
U S35        OU R                  S5        Uc  Uc  UbH  U R                  U=(       d    U R                   Uc  U R"                  OUU=(       d    U R$                  5        Ub  U R'                  U5        Ub  U R)                  U5        Ub  U R+                  U5        Ub  U R-                  U5        Ub  U R.                  " S0 UD6  gg)z
This method starts a "q/Q" context in the page content stream,
and inserts operators in it to initialize all the PDF settings specified.
r  Nz0font_size & font_size_pt cannot be both provided)rv  rx  rw  ru  zUnsupported setting: zH - This can be controlled through dash_pattern / draw_color / line_width
blend_moder\  )	char_vposr   r   
denom_liftdenom_scaler   nom_lift	nom_scaler   sub_lift	sub_scalesup_lift	sup_scaler  r  r   r   zq /z gsr  r   )r^  r   r  r/   MERGE_PROPERTIESsetattrr:  r  register_styler  r]  rD   r^  r   r  r  r   r   r   rO  r;  r  rA  r  )r   r   r   r   r   r   r   r   r   r   ry  keyr]  gs_names                 r    r   FPDF._start_local_context  s     &  ' !STT!+.7L{# ,,.JC   !+C50xy  m444:&B',&--e4 '  & 5) #8!>??K )L ;;JJ2NG""&&'B'BGYYWIIG9C()IIcN #%'MM/t//#-#5:1 1 1	 !
+!
+!
+!
+#!!1L1 $r   c                 &    U R                  S5        g)z>
This method ends a "q/Q" context in the page content stream.
r  N)r  rF  s    r    r"  FPDF._end_local_context%  s     			#r   c                     U R                   $ )aF  
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.
)rq  rF  s    r    accept_page_breakFPDF.accept_page_break+  s     ###r   c                    U R                   (       d  [        S5      e[        U[        5      (       d  [        U[        5      (       a  [	        S5      e[        U[
        5      (       a%  US;  a  [        R                  " S[        5       S9  Sn[        R                  " U5      n[        R                  " U5      n[        R                  " U5      nU[        R                  :X  a  [	        S5      eUS:w  a  US	:X  a!  [        R                  n[        R                  nO]US:X  a!  [        R                   n[        R"                  nO6US
:X  a!  [        R$                  n[        R"                  nO[	        SU S35      e[        R                  " SU SUR&                   SUR&                   S3[(        [        5       S9  U R+                  U5      nU R,                  (       a  U R/                  X:5      OU R1                  X:5      nU R3                  [5        US	S	U[        R                  :X  a  [        R6                  OUUUSS9UUUUUUU	U
S9	$ )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 / strikethrough / underlined.
        Supports `\` as escape character. 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.rL  F
text_widthnumber_of_spacesalignr  	max_widthtrailing_nl)new_xnew_yr  r  centerprevent_font_change)r   rN   r   r   r^  r   r   r   r*   rK   r@  rL   r6   JRIGHTTOPLMARGINNEXTLEFTr  r   rD  r  rE  _preload_font_styles_render_styled_text_linerd   L)r   rb  rh  r2  borderlnr&  r  r  r+  rI  r)  r*  styled_txt_fragss                 r    cell	FPDF.cell6  s   r  UVVaAs!3!3J  fc""vV';MMZ*, FE"E"U#EGGY  Qw

q		q				 8 =7 7  MM&&(T)9%**]SXS]S]R^^_a #*, ""4(    ,,T<**4: 	
 ,, !"!&%''!1eggu!  (# - 
 	
r   	text_linerh  r6  r)  r*  r  r  r+  paddingc                 ~   [        U[        5      (       a&  US;  a   [        R                  " S[	        5       S9  SnO6[        U[
        5      (       a!  [        U5      R                  S5      (       a  SnU	c  [        SSSS5      n	S=pU	R                  S:X  a  U R                  nU	R                  S:X  a  U R                  nUR                  nU(       d5  [        UR                  5       H  u  pUR                  US:g  S9nUU-  nM     UR                   nUc$  UR                  (       d  [#        S5      eX-   U-   nO,US:X  a&  U R$                  U R&                  -
  U R(                  -
  nU(       a%  U R*                  U R,                  U-
  S	-  -   U l        O6UR.                  [0        R2                  :X  a  U =R(                  US	-  -  sl        SnUR5                  5       nU H!  nUR6                  U:  d  M  UR6                  nM#     Uc  UnU R9                  U5      n/ nU R:                  nU R(                  U	R                  -
  U-  nU R(                  U-   U	R                  -   U-  nU R<                  U R>                  -
  U	R@                  -   U-  nU R<                  U R>                  U-   -
  U	RB                  -
  U-  nU(       a4  US:X  a  S
OSnURE                  US SUS SUU-
  S SUU-
  S SU 3	5        O-US:X  a'  URE                  US SUS SUU-
  S SUU-
  S S35        [        U[
        5      (       a  SU;   a!  URE                  US SUS SUS SUS S35        SU;   a!  URE                  US SUS SUS SUS S35        SU;   a!  URE                  US SUS SUS SUS S35        S
U;   a!  URE                  US SUS SUS SUS S35        U RF                  (       a(  U RI                  U R(                  U R>                  UU5        U R(                  nSnS=nnSn [J        RL                  n!U RN                  n"U RP                  n#U RR                  n$U RT                  n%U RV                  n&U RX                  n'Sn(U RZ                  n)U(       Ga  UR.                  [0        R\                  :X  a	  UU-
  U-
  n*O9UR.                  [0        R^                  [0        R2                  4;   a	  UU-
  S	-  n*OUn*UU*-  nSn+UR.                  [0        R`                  :X  a)  URb                  (       a  UU-
  U-
  U-
  URb                  -  n+URE                  SU R(                  U*-   U-  S SU R<                  U R>                  -
  SU-  -
  SU-  -
  U-  S S35        [        U5       GHS  u  p[        U[d        5      (       a(  U Rf                  U Rh                     Rk                  U5        URl                  S   U):w  a>  URl                  S   n)URE                  U)Ro                  5       Rq                  5       5        Sn(U+(       a#  URV                  S:w  a  U+S-  URV                  -  nOU+nU&URV                  :w  a+  URV                  n&URE                  URV                  S S35        U'URX                  :w  a+  URX                  n'URE                  URX                  S S35        U Rr                  (       Gd  U
(       a  URt                  n"URP                  n#URR                  n$URE                  S U"Rv                   SU#S S!35        U Rx                  R{                  [|        R~                  U"Rv                  U Rh                  5        UR                  n!OURt                  =n"U l'        URP                  =n#U l(        URR                  =n$U l)        U R                  U R                  U"U#5      5        UR                  n!OU"URt                  :w  d0  U#URP                  :w  d   U$URR                  :w  d  U!UR                  :w  aP  URt                  n"URP                  n#URR                  n$URE                  U R                  U"U#SS"95        UR                  n!UR                  n,U,U :w  a  URE                  U,S S#35        U,n URT                  [        R                  :w  d  URT                  U%:w  a8  URT                  n%URE                  URT                   S$UR                  S S%35        UR                  UUU+U R(                  U*-   U-   U R>                  SU-  SU-  -   -   U R<                  5      n-U-(       a  URE                  U-5        UR                  US:g  S9U+UR                  R                  S5      -  -   n.UR                  (       a]  URE                  U R                  U R(                  U*-   U-   U R>                  SU-  -   SUR6                  -  -   U.URt                  5      5        UR                  (       a]  URE                  U R                  U R(                  U*-   U-   U R>                  SU-  -   SUR6                  -  -   U.URt                  5      5        UR                  (       aW  U R                  U R(                  U*-   U-   U R>                  SU-  -   SUR6                  -  -
  U.UR6                  UR                  S&9  UR                  (       d  UnUU.-  nGMV     URE                  S'5        U(       aL  U R                  U R(                  U*-   U R>                  SU-  -   SWR6                  -  -
  UUR6                  U5        U(       a  US:w  d  U S:w  d{  U![J        RL                  :w  dg  U"U RN                  :w  dW  U#U RP                  :w  dG  U$U RR                  :w  d7  U%U RT                  :w  d'  U((       d   U&U RV                  :w  d  U'U RX                  :w  a  S(SR                  U5       S)3n/OSR                  U5      n/U R                  U/5        U=(       d    U R6                  U lQ        U[        R                  :X  a  U =R(                  U-  sl        OU[        R                  :X  a  UU l        OU[        R                  :X  a  UU-   U l        OU[        R                  :X  a  U(       a  UU-   U-
  U l        OUU l        OzU[        R                  :X  a  UUS*-  -   U l        OXU[        R                  :X  a  U R*                  U l        O2U[        R                  :X  a  U R$                  U R&                  -
  U l        U[        R                  :X  a  U =R>                  U-  sl        U[        R                  :X  a  U R                  U l        U[        R                  :X  a  U R<                  U R                  -
  U l        U$ )+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, 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.
    prevent_font_change (bool): ensure no font settings (family / size / style)
        change during this call.

Returns: a boolean indicating if page break was triggered
r  r  r   r!   LTRBr   )
initial_cszA'text_line' must have fragments if 'text_line.text_width' is Noner   rv  fr  r  r  z re Sr5  r  r  TRg        Fri  g      ?g333333?r  r   Tr   z Tzz Tcrg  rh  )rl  z Tsr  r  )r  r   rb  rh  r  ETr  z Qg       @)`r   r   r   r   r*   r   r  
issupersetr   rx  r  rz  r$  	enumerate	fragmentsrF  r'  r^  rb  rc  r  r  rd  r&  r6   Xget_ordered_fragmentsr  _perform_page_break_if_need_ber   rh  r   ry  bottomr  r  r  r:   LINEr   r   r   r  r   r   r   rB  Cr-  r%  re   r   r   add_text_substitutiongraphics_stater  r   r   r   r  r  r]  rD   rk  r  r  rn  liftrI   r   r   render_pdf_text
characterscountr   r  r   r  r  rG  r  r   rK   r.  STARTENDWCONTCENTERr0  RMARGINrL   r1  TMARGINr	  BMARGINri  )0r   r;  rh  r6  r)  r*  r  r  r+  r<  r,  
l_c_margin
r_c_marginstyled_txt_widthr  rJ  unscaled_widthrb  max_font_sizerF  page_break_triggeredrm  r   rx  rz  ry  rJ  ops_starts_width
current_wsfrag_wscurrent_liftcurrent_char_vposr   current_font_size_ptcurrent_font_stylecurrent_text_modecurrent_font_stretchingcurrent_char_spacingfill_color_changedlast_used_colordxword_spacingrO  r_text
frag_widthrG  s0                                                   r    r4  FPDF._render_styled_text_line  s5   ^ fc""vV';MMZ*, F$$V)?)?)G)GF?aAq)G"##
<<1J==AJ$//$Y%8%89!%16!B N2  : 9&& W  !-
:A!V&/A]]dhhla%77DF__'FFa!eOF335	D~~- $  9A#BB1EFF %*!gmm+q0vv,1&&DFFQJ''..8A=!BIIc
!C9AeDj-=Qvcz#>NdSURVWXq[IIc
!C9AeDj-=Qvcz#>NeTU fc""f}		T#JaCyD:Qvcl$OPf}		T#JaCyE#;aCyMNf}		U3KqS	U3KqDQRf}		T#Jas|3uSk6#,dST((!!$&&$&&!Q7&&""
W$MM((#00!__ NN"&"6"6#00"//%'')^&66UWWegg$66**a/rMGL%'')i.H.H
NZ/2BB.. / IItvv{a',AFFTVVOcAg-m0CCqHMSR %Y/d$BCCJJtyy)??E&&|4G&*&9&9,&GOIIo779??AB)-&D$8$8C$?*S043G3GGG*G*d.B.BB.2.B.B+II!5!5c :#>?'4+<+<<+/+<+<(II!2!23 7s;<777*'+yy/3/@/@,-1__*		B|~~&6a8LS7QQT"UV..22+00,..$)) -1NN) <@99Dt'8CGCTCTT,t/@?CN*T_		 33 , 4 -1NN) DII-+t/@/@@)T__<(DNN: $(99L+/+<+<()-&II//(005 0  )-%yy<'IIc
#./#'LNNhmm3~~)::(,%II 0T__S4ILM-- FFRK')FFcAgm(;;<FF IIf%!^^ Av ,  4??#8#8#==>
 >>II** FFRK'1 FFcAg.#2FG& II	 %%II.. FFRK'1 FFcAg.#2FG& II	 99II&&2+/&&C!G,dnn0DE$..!YY   ''!(J:%k 0n IIdO		FFRKFFcAg&#*>?$NN 
 c!3&$54#4#44'4+<+<<%8$6%*d.B.BB'4+<+<<"b)HHRLIIaL )4>> DJJFFaKFdjj DFdhhw&DFdjj  7*Z7 dkk!w},DFdll"]]DFdll"VVdmm+DF DIIFFaKFDLL ]]DFDLL VVdmm+DF##r   c                    U R                   U R                     R                  XR                  -  U R                  U-
  U R                  -  X-   U R                  -  U R                  U-
  U R                  -  XR                  -  U R                  U-
  U-
  U R                  -  X-   U R                  -  U R                  U-
  U-
  U R                  -  /5        g r7  )r  r   extendr   rh  r   r  r   rb  rh  s        r    r  FPDF._add_quad_points
  s    tyy)00FF
!tvv%$&& !tvv%FF
!a466)$&& !a466)		
r   c                 x   U R                   (       d  U R                  X5      $ U R                   S   (       a  U R                   S   O
[        U5      n[        XS9nUR	                  5       nUR
                  U R                   S'   / nU H&  u  pxXR                   S'   X`R                  Xr5      -  nM(     [        U5      $ )zW"
Break the text into bidirectional segments and preload font styles for each fragment
r  )r2  base_directionr  r  )r  r3  r(   r'   get_bidi_fragmentsrx  r  )	r   r2  rI  r  	paragraphdirectional_segmentsrF  	bidi_textbidi_directions	            r    rE   FPDF._preload_bidirectional_text  s       ,,T<<   - k*+D1 	 "tP	(;;=3<3K3K/0	)=%I6D23229GGI *> Yr   c                    U(       d
  [        5       $ U R                  nU R                  (       a  US-  nU R                  (       a  US-  n[        U R	                  X5      5      nU(       a  U R
                  nSU l        [        S U 5       5      (       a  U R                  SS9  [        S U 5       5      (       a  U R                  SS9  [        S	 U 5       5      (       a  U R                  S
S9  [        S U 5       5      (       a  U R                  SS9  U H.  nU R                  UR                  UR                  -      Ul
        M0     U R                  US9  XPl        U$ )a  
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>  r   c              3   >   #    U  H  oR                   S :H  v   M     g7f)rv  Nr   r  rJ  s     r    r  ,FPDF._preload_font_styles.<locals>.<genexpr>D       G6Fd??c)6F   rv  r   c              3   >   #    U  H  oR                   S :H  v   M     g7f)rw  Nr  r  s     r    r  r  G  r  r  rw  c              3   >   #    U  H  oR                   S :H  v   M     g7frG  r  r  s     r    r  r  J  s     H7Gt??d*7Gr  rH  c              3   >   #    U  H  oR                   S :H  v   M     g7f)r   Nr  r  s     r    r  r  M  s     F5ET??b(5Er  r   )r  r   r   r   _parse_charsr   rN  r  r   r   r   )r   r2  rI  prev_font_styler8  r   rJ  s          r    r3  FPDF._preload_font_styles.  s*    7N//>>s"Os"O !2!24!BC99D DIG6FGGGC(G6FGGGC(H7GHHHD)F5EFFFB'( JJt'7'7$//'IJ	 ) MMM0Ir   c                 B  ^ ^ [         R                  " U5      mT R                   Vs/ s H-  n[        U5      T R                  U   R
                  ;   d  M+  UPM/     nnU(       d  g[        UU 4S jU 5       S5      nU(       a  U$ T R                  (       a  gUS   $ s  snf )z
Returns which fallback font has the requested glyph.
This method can be overridden to provide more control than the `select_mode` parameter
of `FPDF.set_fallback_fonts()` provides.
Nc              3   f   >#    U  H&  nTR                   U   R                  T:X  d  M"  Uv   M(     g 7fr7  )r   rA  )r  r   rA  r   s     r    r  )FPDF.get_fallback_font.<locals>.<genexpr>f  s)     WodD1A1J1Jh1VTTos   !1	1r   )rG   r@  r  ordr   cmapnextr  )r   charr  font_idfonts_with_charfont_with_matching_emphasisrA  s   `     @r    get_fallback_fontFPDF.get_fallback_fontW  s      &&u-  22
24yDJJw/444 2 	 

 &*WoW'
# '..**q!!
s   *BBr2  rI  c              #   &  ^ ^^^^^^^#    U(       d  T R                   (       d  T R                  (       d  T R                  (       a  [        UR	                  T R                  5      5       Hl  u  p4US:  a1  [        T R                  T R                  5       T R                  5      v   U(       d  ME  [        UT R                  5       T R                  5      v   Mn     g[        UT R                  5       T R                  5      v   g/ ST R                  ;   ST R                  ;   [        T R                  5      [        T R                  5      4u  mmmmmSmSmUUUUUUU U4S jnT R                  (       a  T R                  R                  nO/ nSnU(       Ga  USS T R                   T R"                  T R$                  T R&                  4;   nUS   n	[)        US   5      n
U
[*        R,                  [*        R.                  T4;  a  T(       a  T(       a	  U" 5       v   U
mT R                  (       a  US[1        T R                  5       T R                  :X  a  T(       a	  U" 5       v   T R                  5       nT(       a  SOST(       a  SOS-   US'   TUS	'   TUS
'   [        T R                  UT R                  5      v   U[1        T R                  5      S nGMF  U(       Ga  U(       a  T(       a	  TS   U	:w  a  [1        U5      S:  d	  US   U	:w  a  US:  a  TSUS-   S-  *  OTmUS-  S:X  a  T(       a	  U" 5       v   USS T R                   :X  a  T(       + mUSS T R"                  :X  a  T(       + mUSS T R$                  :X  a  T(       + mUSS T R&                  :X  a  T(       + mUSS nGM  US   T R2                  :X  a  US-   OSnT R4                  R7                  U5      nU(       a  UR9                  5       u  pnT(       a	  U" 5       v   T R                  5       nT R:                  US
'   T R<                  (       a  T R<                  US'    [?        U5      nT RA                  US9n[        [E        U5      UT R                  US9v   GM  T R                  (       a  US   S:w  a  [G        US   5      U;  a  T(       a  SOST(       a  SOS-   nT RI                  US   U5      nU(       aP  UT:X  a  TRK                  US   5        USS nGMx  T(       a	  U" 5       v   UmTRK                  US   5        USS nGM  T(       a  T(       a	  U" 5       v   SmTRK                  US   5        USS nU(       a  GM  T(       a
  U" 5       v   gg! [B         a     GN.f = f7f)zSplit text into fragmentsr   Nrv  rw  c                  H  > TR                  5       n T(       a  SOST(       a  SOS-   U S'   TU S'   TU S'   T(       aL  SR                  S T 5       5      U S'   SR                  S	 T 5       5      U S'   TR                  T   U S
'   S mS m[        T	U TR                  5      n/ m	U$ )Nrv  r   rw  r   r   r   c              3   R   #    U  H  oR                  5       (       d  M  Uv   M     g 7fr7  )islowerr  r  s     r    r  2FPDF._parse_chars.<locals>.frag.<locals>.<genexpr>  s      04!		AA4   '	'r   c              3   R   #    U  H  oR                  5       (       d  M  Uv   M     g 7fr7  )isupperr  s     r    r  r    s      /4!		AA4r  r   )_get_current_graphics_stater  r   rb   r   )
gstatefragmentcurrent_fallback_fontcurrent_text_scriptin_bold
in_italicsin_strikethroughin_underliner   txt_frags
     r    rJ  FPDF._parse_chars.<locals>.frag  s    557F+2C!r$F<  '7F?#".F;$(* 040 )}% (*ww /4/ (|$ *.4I)J~&(,%&*#H
 HOr   r   r   r   r   r   rv  r  r!   r   r1  )r  
)&r  r  r  rE  splitre   r  r   rb   r   r   r   r   rG  r   r  MARKDOWN_BOLD_MARKERMARKDOWN_ITALICS_MARKERMARKDOWN_STRIKETHROUGH_MARKERMARKDOWN_UNDERLINE_MARKERr}   r|   COMMONUNKNOWNrm  MARKDOWN_ESCAPE_CHARACTERMARKDOWN_LINK_REGEXrg  groupsMARKDOWN_LINK_UNDERLINEMARKDOWN_LINK_COLORr   r  r^  r  r  r  r  )r   r2  rI  seqfragment_textrJ  font_glyphsnum_escape_chars	is_markerhalf_markertext_scriptr  is_link	link_text	link_destr   r  r{  r  r  r  r  r  r  r  s   `                 @@@@@@@r    r  FPDF._parse_charso  sL     1 1$:Q:Q&&*3JJt667+&C Qw< 33 <<> FF 
 %}&)4+K+K+Mtvv + 4!A!A!CTVVLL4??"4??"##$ I
E':'7 !%"	 	4 ++00KKRa)),,22..	% I q'K,T!W5K$$%%## 
  3&L&1#&&6#d55674;R;RR"f!==?F3:C)r,F<( /?F?+*6F;'8// 
  D$;$; < >?D %")DTQ$q'[*@ ,a/ !!A&6&:q%@#AB% 
 (!+q0#"&&L8t'@'@@*1kG8t'C'CC-7J8t'I'II3C/C,8t'E'EE/;+;L#ABx  Aw$"@"@@ %q( !
 2288>181A.I$"f!==?F*.*F*FF;'///3/G/G|,"9~$(MMtM$<	 #Y&	  DGtOCQLK<W 'R:C2N $ 6 6tAw F $(== Q0#ABx "f,9)OODG,8D$&L(,%OODG$8DU dV &L ; & s8   B V.NVV  DV.V 
V
VVVc                     U R                   U-   U R                  :  =(       a$    U R                  (       + =(       a    U R                  $ )a  
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  r   r  )r   r  s     r    will_page_breakFPDF.will_page_break  s<     FFVOd555 'NN"'&&	
r   c                     U R                  U5      (       aH  [        R                  SU R                  U R                  UU R
                  5        U R                  5         gg)Nz;Page break on page %d at y=%d for element of height %d > %dTF)r  LOGGERdebugr   r   r  _perform_page_breakr   rh  s     r    rI  #FPDF._perform_page_break_if_need_be,  sP    ""LLM		'' $$&r   c                 &   U R                   (       a  U R                  (       a  g U R                  n/ nU R                  5       (       aV  UR	                  U R                  5       5        U R                  5         U R                  5         U R                  5       (       a  MV  SU l        U R                  5         U R                  SS9  U R                  5         [        U5       H*  nU R                  5         SUS'   U R                  " S0 UD6  M,     Xl        g )NFT)r  r   r   )r  r   r  !_is_current_graphics_state_nestedr  r  r#  r"  r   r  r  reversedr   )r   r  gs_stackprev_gss       r    r  FPDF._perform_page_break9  s    %%FF 4466OOD<<>?!!# ##% 4466 ,1( 4 )G""$5:G12%%00 * r   c                 4    U R                   U R                  :  $ r7  )rn  r   rF  s    r    r  FPDF._has_next_pageS  s    $))++r   c              #   >  #    [        U R                  [        R                  5      (       d  S v   g S U l        U R                  U R
                  U R                  U R                  4u  pp4[        U R                  U R                     R                  5      nU R                  5          S v   U R                  5         [        US-   U R
                  S-   5       H  nU R                  U	 M     Xl        XPR                  U R                     l
        U R                  X45        U ?g ! U R                  5         [        US-   U R
                  S-   5       H  nU R                  U	 M     Xl        XPR                  U R                     l
        U R                  X45        U ?f = f7f)Nc                      g r7  r   )r   r   s     r    <lambda>'FPDF._disable_writing.<locals>.<lambda>]  s    Dr   r!   )r   r  types
MethodTyper   rn  r  r   ru   r   r  r  r#  r  set_xy)r   	prev_pageprev_pages_countprev_xprev_yr  ps          r    _disable_writingFPDF._disable_writingV  sQ    $))U%5%566 0	IIFFFF	7
3	V $**TYY/667 	!!#+a/1A1AA1EFJJqM G!I+1JJtyy!(KK'	 !!#+a/1A1AA1EFJJqM G!I+1JJtyy!(KK'	s    B$F'D" +A7F"A8FFwrapmodec                    [         R                  " U5      n[        R                  " U5      nU(       a"  [        R
                  " S[        [        5       S9  U(       d  U(       aR  U R                  5          U R                  UUUUUUUU	U
UUUUUSSU(       a  [        R                  OUUUS9sSSS5        $ U R                  (       d  [        S5      e[        U[        5      (       d  [        U[        5      (       a  [!        S5      e["        R                  " U5      n[$        R                  " U5      nU	S:w  a  U	S	:X  a!  ["        R&                  n[$        R(                  nOU	S
:X  a!  ["        R*                  n[$        R(                  nO]U	S:X  a!  ["        R,                  n[$        R(                  nO6U	S:X  a!  ["        R&                  n[$        R.                  nO[!        SU	 S35      e[        R
                  " SU	 SUR0                   SUR0                   S3[        [        5       S9  [2        R                  " U5      nSnUc  U R4                  nUS	:X  a&  U R6                  U R8                  -
  U R:                  -
  nU R:                  U R<                  nnUUR>                  -
  UR@                  -
  =nn/ nUR@                  (       d  URC                  U RD                  5        UR>                  (       d  URC                  U RD                  5        U[2        RF                  :w  a  U =R:                  UR@                  -  sl        U =R<                  URH                  -  sl        U(       aS  U[2        RF                  :X  a  U R6                  S-  OU RJ                  U RL                  U-
  S-  -   U l        U R:                  nU RO                  U5      nURQ                  SS5      nU RR                  (       a  U RU                  UU5      OU RW                  UU5      nU RX                  nU RZ                  nU R\                  nS	n/ n[_        UUUUUUS9n U Ra                  5       n!U!b&  URC                  U!5        U Ra                  5       n!U!b  M&  U(       d  [c        SS	S	UUUSS9/nU
b  [e        U5      S
:X  a  Un"O[g        X*5      n"U=(       d    Un#Sn[i        U5       GH  u  n$n!U Rk                  UURl                  -   5      (       a!  SnU =R<                  URH                  -  sl        U#(       Ga%  U$S	:X  d  U(       Ga  U R<                  URH                  -   n%URl                  U Rn                  -   n&[q        U Rr                  U%-
  U&-
  U"-  5      n'[g        U'[e        U5      U$-
  5      n([u        UU$U"-  -
  U(U"-  5      n)U R:                  U[2        RF                  :X  a  US-  OS	-
  n*[w        U U*UR@                  -
  U R<                  URH                  -
  U*U-   UR>                  -   U R<                  U)-   URl                  -   UU(       a  U Rx                  OS5        U$[e        U5      S
-
  :H  n+U R{                  U!U"U+(       a  UO["        R,                  U+(       a  UO[$        R(                  S	SU[        S	UR>                  S	UR@                  5      US9	  UU"-  nU+(       a  GM  U[2        RF                  :X  d  GM  UU l        GM     UU:  a.  U[$        R(                  :X  a  U =R<                  UU-
  -  sl        UnU(       a   U[$        R.                  :X  a  U R<                  nUS   n,U,(       aE  U,R|                  (       a4  U[$        R~                  [$        R(                  4;   a  U R                  5         U[$        R.                  :X  a  UU l        O3U[$        R(                  :X  a  U =R<                  URl                  -  sl        U(       a  UU l-        UU l,        UU l.        U["        R&                  :X  a   U =R:                  UR>                  -  sl        O3U["        R,                  :X  a  U =R:                  UR@                  -  sl        [        R                  " U5      nSn-U[        R                  -  (       a  U-U4-  n-U[        R                  -  (       aa  / n.U HS  n!/ n/U!R                   H  n0U/R                  U0R                  5        M      U.RC                  SR                  U/5      5        MU     U-U.4-  n-U[        R                  -  (       a   U-UURH                  -   URl                  -   4-  n-[e        U-5      S
:X  a  U-S	   $ U-$ ! , (       d  f       GN= f)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 / strikethrough / underlined.
        Supports `\` as escape character. 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)rb  rh  r2  r6  r&  r  r  r7  max_line_heightrI  print_shr)  r*  r  r   r   outputr+  r<  Nr  r  r   r   r!   r   r  r  z"), must be an int between 0 and 3.r   r!  r"  rL  r   )r&  r  r  r#  T)rh  r)  r*  r6  r  r  r<  r,  rv  r   )Gr   newrJ   r@  r   r   r   r*   r  
multi_cellr>   LINESr   rN   r   r   r^  rK   rL   r.  r1  r0  r2  r/  r  r6   r  rb  rc  r  r   rz  rx  r  r  rG  ry  r  rd  rD  ra  r  rE  r3  r   r   r   rc   get_linerd   rm  r  rE  rI  rJ  ri  r   rh  r8  rx   r   r4  r(  LASTr7  
PAGE_BREAKrF  rt  rQ  r  HEIGHT)1r   rb  rh  r2  r6  r&  r  r   r  r7  r  rI  r  r)  r*  r  r   r  r+  r<  r_  r  r  maximum_allowed_widthclearance_marginsnormalized_stringstyled_text_fragmentsprev_current_fontr  prev_underlinetotal_height
text_linesmulti_line_breakr;  line_heightbox_requiredtext_line_indextop_gap
bottom_gaplines_before_break	num_lines
box_heightr  is_last_line	last_linereturn_valueoutput_linesrQ  rJ  s1                                                    r    r  FPDF.multi_cells  s   j ++g&??8,MMD #*, j&&(!$3%%%!$6@,22f!#' '  )(,  UVVaAs!3!3J  E"E"Qw

		q		q				q

 8 =7 7  MM&&(T)9%**]SXS]S]R^^_a #*, U#$9A 6&/A 
 %&$5$DD||$$T]]3}}$$T]]3EGGFFgll"F'++ #uww.
DMMTXXPQ\UVDV4V F VVF ""4( LLr2    ,,->I**+<hG 	 !--//
)!!
 %--/	%i((113I %  %& %
J "c*o&:Ka1K~v$*3J*?&OY221w~~3EFF'+$'++%A!59M&&7;;.$^^dmm;
%($&&7*:Z*GK)W%X" 2C
Oo4UV	 +55y;7N
 FFu'7a!eQ? $FFW[[(EGMM)FFZ''..8'+DOO +c*o.AAL))+e+e7==!W\\B$, * 
 K'L<EUWW$4S +@V !		!!l**LETXX$5 VVFrN	..5TYY		<R3RGGIDHHDFdiiFFgnn$F-DO 1D+DNDJJFFgmm#FdiiFFgll"F"))&1%000133L%+++L'	
%//D%%doo6 0##BGGJ$78	 (
 \O+L%,,,\GKK7'..HJJL|!?"S )(s   48e$$
e3r  c                   ^ [         R                  " U5      nU R                  (       d  [        S5      e[	        U[
        5      (       a  [        S5      eUc  U R                  nSnU R                  U5      R                  SS5      nU R                  (       a  U R                  US5      OU R                  US5      n/ n	[        UU4S jU R                  U R                  4UUS9n
U R                  U R                   -
  U R"                  -
  nUmU
R%                  5       nU R                  U R&                  -
  U R"                  -
  nUmUb&  U	R)                  U5        U
R%                  5       nUb  M&  U	(       d  g[+        U	5       HW  u  pUS:  a  U R-                  5         U R/                  UUS[0        R2                  [4        R6                  SUS	9nU=(       d    UnMY     UR8                  (       a  U R-                  5         U$ )
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=Fr  r   c                    > T$ r7  r   )rh  r'  s    r    r  FPDF.write.<locals>.<lambda>  s    ir   )r  r  r   )rh  r6  r)  r*  r  r  )rJ   r@  r   rN   r   r   r^  r  rD  ra  r  rE  r3  rc   r  rb  r  rc  r  r  r  rE  r7  r4  rK   rU  rL   r/  r(  )r   rh  r2  r  r  r  r_  r  r  r  r  first_widthr;  
full_widthr  r  r'  s                   @r    write
FPDF.write  s   8 ??8, UVVaH  9A$ //5==dBG    ,,->F**+<eD 	 
)!]]DMM*
 fftvvo5	$--/	VVdmm+dmm;
	%i((113I % *3J*?&O"	44jjhh 5 H $8#C8  +@   GGI##r   
   r2  imgimg_fill_widthncolsgutterbalance
text_alignr  r  rc  skip_leading_spacesc                 .    [        U UUUUUUUUU	U
UUUS9$ )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)
)r2  r  r  r  r  r  r  r  r  rc  r  r  r  )rz   )r   r2  r  r  r  r  r  r  r  r  rc  r  r  r  s                 r    text_columnsFPDF.text_columns  s<    J )!# 3
 	
r   c                    U(       a"  [         R                  " S[        [        5       S9  [	        U R
                  X5      u  pn[        U[        5      (       a  U R                  XXX4XWXU5      $ U R                  UUUUUUUUUU	U
U5      $ )a  
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.
        `fpdf.enums.Align.C` can also be passed to center the image horizontally;
        and `fpdf.enums.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.

If `y` is provided, this method will not trigger any page break;
otherwise, auto page break detection will be performed.

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*   r`   r   r   r\   _vector_image_raster_image)r   r  r  r   rb  rh  rE  r  r   r  dimskeep_aspect_ratior  rZ  s                 r    r  
FPDF.imageL  s    B MM6 #*, ((8(8$E4dO,,%%4A!5DU  !!
 	
r   c                    SU;   a  U R                  S5        UR                  XgU R                  S9u  pgUc2  U R                  U5        U R                  nU =R                  U-  sl        Uc  U R
                  n[        U[        5      (       d  U R                  XFXsU5      nU(       a  UR                  XEXg5      u  pEpgU R                  (       a+  US   S:X  a"  U(       d  U R                  XX6XpR                  S9n[        X4XVX|U R                  U R                  S9nU	(       d  U
(       a*  U R                  XS9   U R                  U5        S S S 5        OU R                  U5        U(       a  U R!                  XEXgU5        U R"                  R%                  [&        R(                  US   U R*                  5        [-        S
0 UDXgS	.D6$ ! , (       d  f       No= f)Nsmaskr\  )scaleusagesr!   )r   pdf_height_to_flipr   r  r  rendered_widthrendered_heightr   )r:  size_in_document_unitsr   rI  r   r  r   r
   
x_by_alignscale_inside_boxr   _downscale_imagerl   rh  _marked_sequencer  r  r  r]  rD   ra  r   r[   )r   r  r  rZ  r  r   rb  rh  r  r   r  r  r  stream_contents                 r    r  FPDF._raster_image  s    d?%%e, **1tvv*> 9//2AFFaKF9A!V$$a/@AA..qQ:JA!  T(^q%8((DQff(MD8Q1tvvRVRXRX
 H&&U&F		.) GF IIn%IIaA$'""?#;#;T#Y		RKKaKK GFs   6G
Gc                 r   U(       a  UR                  SSX#5      u    pbn[        R                  " U5      nU[        R                  :X  a  U R                  U-
  S-  $ U[        R
                  :X  a  U R                  U-
  U R                  -
  $ U[        R                  :X  a  U R                  $ [        SU 35      e)Nr   r   z*Unsupported 'x' value passed to .image(): )
r)  r6   r@  rL  rb  rB  rc  r5  r  r^  )r   r  rb  rh  img_infor  _s          r    r(  FPDF.x_by_align  s    !221a>JAqQLLO<FFQJ!##<66A:--<== EaSIJJr   svgc                 *   UR                   (       d^  UR                  (       aM  UR                  (       a<  [        R                  " S[        5       S9  SSUR                  UR                  4Ul         US:X  Ga   US:X  a  UR                  (       a  UR                  (       a  [        UR                  [        5      (       a  UR                  U R                  -  S-  OUR                  n[        UR                  [        5      (       a  UR                  U R                  -  S-  OUR                  nOUR                   (       a  UR                   u    pnO[        U[        5      (       a  SOUn[        U S35      eUS:X  d  US:X  a|  UR                  (       a)  UR                  (       a  UR                  UR                  pO-UR                   (       a  UR                   u    pnO[        S5      eUS:X  a  X~-  U-  nOXo-  U-  nUc2  U R                  U5        U R                  nU =R                  U-  sl        Uc  U R                  nU(       a  UR                  XEXg5      u  pEpg[        U[         5      (       d  U R#                  XFXsU5      nUR%                  SXgS	S
9u    nnUR&                  [(        R*                  " XE5      -  Ul        U R                  U R                  nn U R-                  SS5        U	(       d  U
(       a*  U R/                  XS9   U R1                  U5        S S S 5        OU R1                  U5        U R-                  UU5        U(       a  U R3                  XEXgU5        [5        XgS9$ ! , (       d  f       NC= f! U R-                  UU5        f = f)NzI<svg> has no "viewBox", using its "width" & "height" as default "viewBox"r   r   r   z<svg>zT has no "viewBox" nor "height" / "width": w= and h= must be provided to FPDF.image()zY<svg> has no "viewBox" nor "height" / "width": w= and h= must be provided to FPDF.image()r!   T)r   rN  r  ignore_svg_top_attrsr#  r$  )viewboxrN  r  r   r   r*   r   rr   rd  rj  r  r^  rI  r   r  r)  r
   r(  transform_to_rect_viewport	transformr2   translationr  r+  r  r  r\   )r   r  r2  rZ  r  r   rb  rh  r  r   r  r  r0  svg_id	svg_width
svg_heightr  old_xold_ys                      r    r  FPDF._vector_image  s    {{syySZZMM[*, Q		3::5CK6a1fyySZZ "#))W55 II(3.  "#**g66 JJ)C/ 
  [[
1$.tU$;$; hrs  !VqAvyySZZ(+		3:::.1kk+1 o  AvMJ.NY. 9//2AFFaKF9A..qQ:JA!!V$$a/@AA331T 4 

1d )*?*?*EEvvtvvu
	&KK1 ***JNN4( KJ t$KKu%IIaA$'aCC KJ
 KKu%s$   /M> M-M> -
M;7M> >Nc           	      z   U R                   R                  nXF-  XV-  pSU 3n
US   XR                  -  :  Ga  US   XR                  -  :  Gal  [        US   U-  US   U	-  5      U R                  -  nU R                  R                  5       R                  S5      (       a#  [        R                  SUUS   US   UU	U5        U$ U R                  R                  5       S:X  Ga  [        XR                  -  5      [        XR                  -  5      4nUS==   S-  ss'   US   S	:X  ag  U R                  R                  nUR                  5        H=  u  u  pnU[        R                  :X  d  M  US
   U;   d  M)  UR                  US
   5        M?     UR!                  U
5      nU(       a  UnUS   US   -  US	   US   -  :  a^  UR#                  [%        UU=(       d    ['        U5      U R                   R(                  U5      5        [        R+                  SU
US
   U5        US==   S-  ss'   U$ [-        [%        UU=(       d    ['        U5      U R                   R(                  U5      5      n[/        U5      S-   US
'   SUS'   X7U
'   [        R+                  SU
UUS
   5         U$ [1        SU R                   35      eU$ )Nzlowres-rb  rh  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   r  z>OVERSIZED: Updated low-res image with name=%s id=%d to dims=%szAOVERSIZED: Generated new low-res image with name=%s dims=%s id=%dz/Invalid value for attribute .oversized_images: )r   imagesr   r  r   r   
startswithr  warningroundr  resources_per_pager  rD   ra  remover   updater^   r_   r  r  r[   rm  r^  )r   r  r  rZ  rb  rh  r   rA  width_in_ptheight_in_ptlowres_namefactorr  rE  r0  rtyperesourcelowres_infos                     r    r*  FPDF._downscale_imageB  s   !!(($%Iqy\v&I&A&AAAS	L+F+FFF DI+T#Y-EF--.  $$**,77??q II B k &&,,.+=+(C(CCD,)D)DDE X!#>Q&)-)?)?)R)R&0B0H0H0J,
H O$<$<<chAV$OODI6 1K %jj5&DCy49,tAwa/@@( $ # 7z$'7 $ 0 0 = = $	 \' I 	 Na'N. + +$ 3:d#3 ,,99 	D !$FaDI%&DN*.;'LL[#S		  !EdF[F[E\]  r   c                 r    [         R                  " S[        [        5       S9  [	        U R
                  X5      $ )zs
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*   r`   r   )r   r  r  s      r    r`   FPDF.preload_image  s6     	B &(	
 T--t::r   c              +   "  #    U R                   R                  U R                  5      nU R                  " SSUS.UD6nU R                  nU R	                  SU S35        Uv   U R                  U:w  a  [        S5      eU R	                  S5        g7f)	
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 occurred inside a marked sequenceEMCNr   )r   next_mcid_for_pager   r  r  rN   )r   r   rT  struct_elemr   s        r    r+  FPDF._marked_sequence  s      ""55dii@.. 
!
06
 YY
		KvV,-99
" OPP		%s   BBc                     U R                   R                  " SSU R                  0UD6u  p#X0R                  U R                     l        U R                  S5        U$ )rS  r  r\  r   )r   add_marked_contentr   r   struct_parentsr:  )r   r   rW  spids       r    r  FPDF._add_marked_content  sZ    
 !//BB 
		
%+
 04

499,!!%(r   c                     U R                   U l        Ub  U =R                  U-  sl        gU R                  (       a   U =R                  U R                  -  sl        gU =R                  U R                  -  sl        g)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    r7  FPDF.ln  sL     =FFaKF[[FFdkk!FFFdnn$Fr   c                     U R                   $ )z-Returns the abscissa of the current position.)r  rF  s    r    get_x
FPDF.get_x  s    vvr   c                 F    US:  a  Xl        gU R                   U-   U l        g)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)rb  r  )r   r  s     r    set_x
FPDF.set_x  s     1f$&&1*r   c                 R    U R                   (       a  [        S5      eU R                  $ )z-Returns the ordinate of the current position.z?Using get_y() inside an unbreakable() code block is error-prone)r   rN   r   rF  s    r    get_y
FPDF.get_y  s&    Q  vvr   c                 h    U R                   U l        US:  a  Xl        gU R                  U-   U l        g)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  rh  r   )r   r   s     r    set_y
FPDF.set_y  s(     1f$&&1*r   c                 H    U R                  U5        U R                  U5        g)z
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)rj  rd  )r   r  r   s      r    r  FPDF.set_xy  s     	

1

1r   c                 6   U R                   (       d<  U R                  (       a+   UR                  U R                  5      R                  S5      $ U$ ! [         a>  n[        UR                  XR                     U R                  U R                  -   S9UeSnAff = f)z7Check that text input is in the correct format/encodingr   )
text_index	character	font_nameN)	rG  r   encodedecodeUnicodeEncodeErrorrP   startr   r   )r   r2  errors      r    rD  FPDF.normalize_text  s     D$<$<{{4#;#;<CCINN  & 2${{";;/"..@ 	s   )A 
B9BBsha256c	                     [         (       d  [        S5      e[        US5       n	[        R                  " U	R                  5       U5      u  pnSSS5        U R                  W
WWUUUUUUS9	  g! , (       d  f       N&= f)a  
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)	r  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_filer  r{  r|  s                r    sign_pkcs12FPDF.sign_pkcs12  s    2 v"b  -&)%+%E%E (&"C{ ' 			#%% 	 
	
	 '&s   )A,,
A:r   c
                    [         (       d  [        S5      eU R                  (       a  [        S5      eXl        X l        X0l        X@l        U=(       d    U R                  U l        [        SSSSSSU	S[        UU[        U R                  5      US9S9	n
U R                  U R                     R                  R                  U
5        g	)
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
rz  z).sign* methods should be called only onceWidgetSigr   	signature)r~  r  r  r  )
field_typer  r   rN  r  r  r   r]  N)r   r  r   rN   
_sign_cert_sign_extra_certs_sign_hashalgor  
_sign_timer%   rp   rv   r   r   r  r  )r   r  r{  r|  r}  r~  r  r  r  r  r  s              r    r  	FPDF.sign?  s    4 v"b  >> KLL!,&&<$*<*<")!$//*	

  	

499$$++J7r   c                 >   U R                   nU R                  U R                  p2UR                  UR                  sU l        U l        SU l        U R                  UR                  U R                  U R                  5        UR                  X R                  5        SU l        UR                  UR                  -   S-
  nU R                  U:w  aV  U R                  (       dE  U R                  U:  a  SOSnSU S3nUSU R                   S	UR                   S
3-  n[        U5      eU R                  (       GaV  U R                  5         [!        U R                  5       Vs/ s H0  opR                  R#                  [%        U R                  5      5      PM2     nn['        [)        U5      5      n0 n	[!        UR                  S-   U R*                  [%        U5      -   S-   5       H  n
XR                  ;   a*  UR-                  U R                  R#                  U
5      5        UR#                  S5      =oR                  U
'   XUR/                  5       '   UR1                  U
5        UR2                  SL d  M  XR5                  5       l        M     [%        U5      S:X  d   S[%        U5       35       eU R                   Hj  nU	R9                  UR:                  5      nUc  M#  UR<                  R?                  US9Ul        Xl        UR@                  (       d  MZ  XR@                  l!        Ml     U RD                  RF                  n[I        [J        5      nURM                  5        H"  u  u  nnnU	R9                  UU5      U4nUUU'   M$     XRD                  l#        X#sU l        U l        g s  snf )NTFr!   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 pagesr   z#new_pages: r1  )'r   r   r   r   r   r  r   r  r  r   r   r   r   rN   r   r  r  poprm  r  r  rn  r  r'  	set_indexr   r  str   r  r  ra  rW  _page_numberr  rE  r   r  r  )r   tocpr  r  expected_final_pagetoo	error_msgr0  	new_pagesindices_remap
page_indexr   section	new_indexrE  new_resources_per_pager  resource_typerM  r  s                       r    _insert_table_of_contentsFPDF._insert_table_of_contentsx  s   ## IItvv6 OOTVV	46 $d33TZZLT==1 %"oo

:Q>99++D4R4R II(;;&CefiejjxyI-dii[8_`d`j`j_kkqrrI	**###! :?t?W?W9X9XA

s4::/9X   Xi01IM#!#T%5%5I%F%J
 +$$TZZ^^J%?@09a0@@zz*-.8djjl+z***e3/9''), y>Q&G,s9~6F(GG&==)--g.A.AB	(#*<<#7#7Y#7#GGL*3'***;D++8 ) "&!7!7!J!J%0%5":L:R:R:T6,mh$((kBMR.6&s+ ;U 9O""5%	46Es   7Nc                     g)a  
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.
rv  r   rF  s    r    file_idFPDF.file_id  s     r   c                 0   [         R                  " SSS9nUR                  U5        U R                  (       a9  UR                  U R                  R	                  S5      R                  S5      5        UR                  5       R                  5       nSU SU S3$ )	Nmd5F)usedforsecurityz%Y%m%d%H%M%Sutf8<z><>)hashlibr  rG  r  strftimerr  	hexdigestr  )r   r  id_hashhash_hexs       r    _default_file_idFPDF._default_file_id  s}     ++eU;vNN4--66~FMMfUV$$&,,.8*Bxj**r   c                    Uc  U R                   nXR                  -  S SU R                  U-
  UR                  S-  U R                  -  -   U R                  -  S SX0R                  -  S SUR
                  * S-  U R                  -  S S3$ )zZ
Draw an horizontal line under some text,
starting from (x, y) with a length equal to 'w'
r  r     re f)r   r   rh  upr  utr   r   r  r   rb  r   s        r    r  FPDF._do_underline      
 <$$D66z#a
TWWt^dnn<<FsK166z#ax$!2!2237u>	
r   c                    Uc  U R                   nXR                  -  S SU R                  U-
  UR                  S-  U R                  -  -   U R                  -  S SX0R                  -  S SUR
                  * S-  U R                  -  S S3$ )z\
Draw an horizontal line through some text,
starting from (x, y) with a length equal to 'w'
r  r  r  r  )r   r   rh  spr  ssr   r  s        r    r  FPDF._do_strikethrough  r  r   c                 ^   U R                   (       a  [        S5      e[        U[        5      (       d1  [        U[        5      (       d  [	        U5      nUR                  S5      nU R                  (       d  [        S5      eU R                  U R                     =R                  US-   -  sl        g )NzGContent cannot be added on a finalized document, after calling output()latin1r      
)	r  rN   r   r  r   rr  r   r   r&  )r   rG  s     r    r  	FPDF._out  s    ;;Y  !U##a%%F"Ayy QRR

499&&!e)3&r   c                    US-  nUnSSSSSSSS	S
SSSS.nUn	[        U	5      S-  S:w  a  SU	 3n	SU	R                  5        S3n	[        S[        U	5      S5       H  n
X   nXS-      nX;  a  [        SU S35      eX;  a  [        SU S35      eSR	                  S [        X   X   5       5       5      n[        U5       H1  u  pUS:X  a  UOUnUS-  S:X  a  U R                  X#UUS5        UU-  nM3     M     g)z/Barcode I2of5 (numeric), adds a 0 if odd lengthr  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   2   #    U  H  u  pU U 3v   M     g 7fr7  r   )r  cbcss      r    r  'FPDF.interleaved2of5.<locals>.<genexpr>  s      *W2$rd*Ws   r%  r  N)rm  r   r  RuntimeErrorr  ziprE  r	  )r   r2  r  r   rb  rh  narrowwidebar_charcoder  char_bar
char_spacer  	bar_indexr  r   s                    r    interleaved2of5FPDF.interleaved2of5  sH    Q 
  t9q=Atf:D DJJL>$q#d)Q'AwH!eJ'"VH:5G#HII)"VJ<7J#KLL '' *-h.@(BV*W C $-S>	'+s{V
 q=A%IIaJ37Z $2 (r   c                 n   XDS-  S.nUR                  S5      (       a  UR                  S5      (       d  [        R                  " S[	        5       S9  0 SS_SS	_S
S_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_S S!_S"S#_S$S%_S&S'_0 S(S)_S*S+_S,S-_S.S/_S0S1_S2S3_S4S5_S6S7_S8S9_S:S;_S<S=_S>S?_S@SA_SBSC_SDSE_SFSG_SHSI_ESJSKSLSMSNSOSPSQSRSSST.
EnUR                  5        HZ  nX;  a  [        SUU SV35      e[        Xx   5       H+  u  pU	SW-  SX:X  a  U R                  X#Xj   US$5        X&U
   -  nM-     X&SY   -  nM\     gZ)[zBarcode 3of9r  )rb  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  	wnnnnwnnwrv  	nnwnnwnnwrL  	wnwnnwnnnr  	nnnnwwnnwE	wnnnwwnnnr  	nnwnwwnnnG	nnnnnwwnwH	wnnnnwwnnrw  	nnwnnwwnnr-  	nnnnwwwnnK	wnnnnnnwwr5  	nnwnnnnwwM	wnwnnnnwnN	nnnnwnnwwO	wnnnwnnwnP	nnwnwnnwnr  	nnnnnnwwwrB  	wnnnnnwwnr>  	nnwnnnwwnrA  	nnnnwnwwnr?  	wwnnnnnnwV	nwwnnnnnwW	wwwnnnnnnrG  	nwnnwnnnw	wwnnwnnnn	nwwnwnnnn	nwnnnnwnw	wwnnnnwnn	nwwnnnwnn	nwnnwnwnn	nwnwnwnnn	nwnwnnnwn	nwnnnwnwn	nnnwnwnwn)
Yr  -rL  r  r  $/+%zInvalid char "z" for Code39r   r   r%  N)	rB  endswithr   r   r*   r  r  rE  r	  )r   r2  r  r   rb  rh  dimcharsr  r  ds              r    code39FPDF.code39-  s    E"s##4==+=+=MME +,-
-
-
 -
 	-

 -
 -
 -
 -
 -
 -
 -
 -
 -
 -
 -
  !-
" #-
$ %-
& '-
( )-
* +-
, --
. /-
0 1-
2 3-
4 5-
6 7-
8 9-
: ;-
< =-
> ?-
@ A-
B C-
D E-
F Y-
` A~"^A3l#CDD!%(+q5A:IIaCFAs3V , SMA r   c              #      #    U R                  SXR                  -  S SU R                  U-
  U-
  U R                  -  S SX0R                  -  S SX@R                  -  S S3	5        Sv   U R                  S5        g7f)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
r  r  r  z re W nNr  r  ru  s        r    	rect_clipFPDF.rect_clips  sy      			QZ$AtvvzA~&?%DAa&&jQTEUUVvv:c"'+	
 			#s   A:A<c              #   ~   #    U R                  S5        U R                  XX4S5        Sv   U R                  S5        g7f)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  r  ru  s        r    elliptic_clipFPDF.elliptic_clip  s2      			#1u-		#s   ;=c              #   l   #    U R                  XX35         Sv   SSS5        g! , (       d  f       g= f7f)a  
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   r8  s       r    
round_clipFPDF.round_clip  s%      a+ ,++s   4#	4
14c              #     #    U R                   U R                  p![        U SS9nSUl        SU l        [
        R                  S5        Uv   UR                  U-
  UR                   U-
  U R                  -  -   nX$-   U R                  :  d  UR                   U:  aV  [
        R                  S5        UR                  5         UR                  R                  5         UR                  5         SUl        SU l        [
        R                  S5        g7f)a  
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r  TzStarting unbreakable blockz.Performing page jump due to unbreakable heightzEnding unbreakable blockN)r   r   ro   r_  r   r  r  rj  r  rewindpdfr  replayr   r  r  recordery_scrolls        r    unbreakableFPDF.unbreakable  s      !IItvv6>(-%#12::&(--)*Ctxx)OOt666(--):SLLIJOO LL,,.OO,0H)$/0s   D
Dc              #   .  #    U R                   U R                  p![        U SS9nSUl        Uv   UR                  U-
  UR                   U-
  U R                  -  -   nX$-   U R
                  :  d  UR                   U:  a  SUl        UR                  5         g7f)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".
Fr@  TN)r   r   ro   r_  rj  r  rA  rD  s        r    offset_renderingFPDF.offset_rendering  s      !IItvv6>(-%::&(--)*Ctxx)OOt666(--):S,0H)s   BBrender_toc_functionr   allow_extra_pagesr   c                    US:  a  [        SU 35      e[        U5      (       d  [        S[        U5       35      eU R                  (       a"  [        SU R                  R                   35      e[        UU R                  U R                  U R                  UU5      U l        X0l        [        U5       H  nU R                  5         M     g)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.
At least one page break is triggered by this method.

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.
    allow_extra_pages (bool): If set to `True`, allows for an unlimited number of
        extra pages in the ToC, which may cause discrepancies with pre-rendered
        page numbers. For consistent numbering, using page labels to create a
        separate numbering style for the ToC is recommended.
    reset_page_indices (bool): Whether to reset the pages indices after the ToC. Default to True.
r!   z3'pages' parameter must be equal or greater than 1: z,The first argument must be a callable, got: zIA placeholder for the table of contents has already been defined on page N)r^  callabler  rE  r   rN   r   r   r   r   r  r   r  r  )r   rL  r   rM  r   r0  s         r    insert_toc_placeholderFPDF.insert_toc_placeholder  s    4 19EeWM  +,,>tDW?X>YZ   00;;<>   .IIFF   
 *;&uA$$& r   c                     XX4XVU4 H8  nU(       d  M  [        U[        5      (       a  M#  [        S[        U5       35      e   UUUUUUUS.U l        g)al  
Defines a style for section titles.
After calling this method, calls to `FPDF.start_section` will render section names visually.

Args:
    level0 (TextStyle): style for the top level section titles
    level1 (TextStyle): optional style for the level 1 section titles
    level2 (TextStyle): optional style for the level 2 section titles
    level3 (TextStyle): optional style for the level 3 section titles
    level4 (TextStyle): optional style for the level 4 section titles
    level5 (TextStyle): optional style for the level 5 section titles
    level6 (TextStyle): optional style for the level 6 section titles
z0Arguments must all be TextStyle instances, got: )r   r!   r   r  r  r     N)r   rT   r  rE  r   )	r   level0level1level2level3level4level5level6levels	            r    set_section_title_stylesFPDF.set_section_title_styles  se    . fffMEuZy99FtE{mT  N %
!r   c                 &   US:  a  [        S5      eU(       aY  U R                  (       aH  X R                  S   R                  S-   :  a)  [        SU SU R                  S   R                   S35      e[        U R                  U R
                  U R                  U R                  -  -
  S9nS	nU R                  (       Ga  U R                  U   nUR                  b  U R                  nUR                  U l
        [        R                  n[        UR                  [        [        45      (       a   [        R                   " UR                  5      nU R#                  U R$                  U R&                  U[(        R*                  [,        R.                  S
[0        R2                  U[5        UR6                  =(       d    S[        UR                  [8        [:        45      (       a  UR                  OSUR<                  =(       d    SS9S9	n	UR                  b  WU l
        U	(       a  U R?                  5         U RA                  US9 n
U
nU RC                  U5         U R#                  U R$                  U R&                  UU[(        R*                  [,        R.                  UR                  [        RD                  :H  S9  S	S	S	5        S	S	S	5        U R                  RG                  [I        XU R                  XE5      5        g	! , (       d  f       NG= f! , (       d  f       NP= f)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.
    strict (bool): whether to raise an exception if levels increase incorrectly,
        for example with a level-3 section following a level-1 section.
r   z)"level" mut be equal or greater than zerorv  r!   z+Incoherent hierarchy: cannot start a level z section after a level z one)ry  NT)ry  rx  rJ  )	rb  rh  r2  r)  r*  r   r  r&  r<  r  )rb  rh  r2  r&  r)  r*  r+  )%r^  r   r[  rt   r   r  r   r   r   size_ptr   r6   r5  r   r  r   r@  r  rd  r  rK   r0  rL   r1  r>   r  r   r	  r   r  ri  r  r+  use_text_stylerL  r  rf   )r   r  r[  strictr  outline_struct_elem
text_styleprev_font_size_ptr&  r_  rW  s              r    start_sectionFPDF.start_section1  sl    19HIIdmmb0A0G0G!0K(K=eWD[\`\i\ijl\m\s\s[ttxy  diiTYY$&&-HI"$$$2259J!!-$($5$5!$.$6$6!GGE*--s|<<Z%8%89#'??((..llii(33"++0q &j&9&9C<HH #++%..3! $3 $ & !!-$5!#&&T&2k&1#((4OO((..!#"ll"ii)22egg= $  5 3 	4		4M	
 54 32s%   ;LA!K10L1
K?	;L
Lrc  c              #   z  #    S nU(       a  UR                   (       a  U R                  UR                   5        UR                  (       at  [        UR                  [        [
        45      (       a/  U R                  nUR                  U l        U R                  U l        O [        R                  SUR                  5        U R                  U5         S v   S S S 5        U(       a,  UR                  (       a  U R                  UR                  5        Ub  X l        U R                  U l        g g ! , (       d  f       N]= f7f)Nz@Unsupported '%s' value provided as l_margin to .use_text_style())r	  r7  r  r   r  r   r  r  r  use_font_faceri  )r   rc  prev_l_margins      r    r`  FPDF.use_text_stylex  s     ""
++,""j11E3<@@$(MMM$.$7$7DM!]]DFLLZ"++ 
+ ,*--GGJ''($)M]]DF %	 ,+s   CD;D*AD;*
D84D;	font_facec              #     #    U(       d  Sv   gU R                   U R                  U R                  4nU R                  UR                  =(       d    U R                   UR
                  b  UR
                  R                  OU R                  UR                  =(       d    U R                  5        SU l        U R                  nUR                  b5  UR                  U R                  :w  a  U R                  UR                  5        U R                  nUR                  b  U R                  UR                  5        Sv   UR                  b  U R                  U5        X0l	        U R                  " U6   g7f)a  
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()

Known limitation: in case of a page jump in this local context,
the temporary style may "leak" in the header() & footer().
NF)r   r   r   r  r  rA  r  r_  r   r   r  rA  r   r  )r   rk  	prev_fontprev_text_colorprev_fill_colors        r    rh  FPDF.use_font_face  s     %%t8I8IJ	0 0 0 %%1 ""((__2!2!2	
 ,1(//??&9??doo+M	0//+	 4 45+0)y!s   E+E-c              /   R   #    [        U /UQ70 UD6nUv   UR                  5         g7f)aO  
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.DeviceCMYK, 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.VAlign): 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)rw   rZ  )r   r   r   tables       r    rr  
FPDF.table  s*     R d,T,V,s   %'c           
      P   U(       a"  [         R                  " S[        [        5       S9  [        R
                  " 5         U R                  (       Gd3  U R                  S:X  a  U R                  5         U R                  5         U R                  (       a  U R                  5         U R                  (       a  U R                  R                  5        H  nUR                  5        Hr  nUR                   R#                  UR%                  5       R'                  S5      UR)                  [+        U R,                  5      5      R'                  S5      5      Ul        Mt     M     U(       a  [.        nU" U 5      nUR1                  5       U l        U(       a  [3        U[4        R6                  5      (       a  UR9                  U R                  5        g[3        U[*        5      (       a%  [;        U5      R9                  U R                  5        gUR=                  U R                  5        gU R                  $ )a  
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   r   N)r   r   r   r*   r}   cache_clearr  r   r  r  r   r  r  r   rR  get_text_substitutionsr&  ra  get_placeholder_stringrr  render_text_substitutionr   rn  ra   	bufferizer   osPathLikewrite_bytesr   r  )r   r  r  	linearizeoutput_producer_classr   substitution_itemoutput_producers           r    r  FPDF.output  s     MM6 #*, 	&&({{{yyA~!##..0&& JJ--/D-1-H-H-J)(,(=(=-DDFMM ) .FF #D$4$4 5$fY/) .K 0 (@%3D9O)335DK$,,  -
 	 D#&&T
&&t{{3  

4;;'{{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  rq  ri  r  r  r   r  r   r  r  r  r   r   r   r  r  r   r  r   r   r   r   r   r   r   r   rh  r  r   r   r   r   r  r  r  r   r   r   r   r   r   r  r   r  r   r   r  r  rc  r   r   r  r   r   r  r	  r   r  r  r   r   r   r  rb  r  r  r   r   r  )portraitmmA4r   )NNNNN)rv  )r   )r   )TNNNNr7  )z{nb})NNN)r   r   Fr   NNNN)T)rv  rv  )FF)r   r   r   )FFN)FN)r!   r!   )NFr   )r   N)Nr   FFFN)Nr   FN)Nr   Nr   )Nr   r   )r   r   rv  null)NNNN)r!   r!   N)	Highlightr!   r!   r   N)r  NN)r   r  r!   )r   r   )r   r   NN)NNNNNNNN)
NNr   r   r   r   NNNF)	NNr   r   r   NNNF)NNr   r   r   NNF)r!   r  )g      ?r  )r!   FT)NNNNNN)r   T)r   r   r   r   __doc__r  r  r  r  r  recompileDOTALLr  r  r  r[  r`  rX   r/  r   r<   RC4r5   allr,  r4  r:  propertyrG   rA  r   rG  rA   rJ  setterrS  rM   r   rm   r_  rd  rj  rn  rs  r
  rw  r  r  r  r  r  r  r   r   rF   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!  r2  r  r;  r  rA  rK  rO  rU  r   rh  rq  rX  rC   AUTOr  r  r  r  r  r  r  r  r	  r  r  r  r  r  r  r  r2  rC  rY  r  rd  rn  r  r  r}  r  r  r  r  r#   r  r  r  r  r  r  r  r  r+   r2  r  r  r  r  r0  r   r"  r  r6   r5  rK   r.  rL   r/  r9  rd   r   r4  r  rE  r3  r  r   rb   r  r  rI  r  r  r  r-  r1  rJ   WORDr>   r  r  r  r   r  r  r[   r  r(  rs   r\   r  r*  r`   r+  r  r7  ra  rd  rg  rj  r  rD  r8   PRINTLOCKEDr  r  r  r  r  r  r  r  r  r4  r7  r:  r=  rG  rJ  r   rP  r\  re  rT   r`  rS   rh  rr  rh   r  r   __classcell__)r#  s   @r    r   r      s~   "$(! $ $**%F		R"

>*IM*JO #Pj *..$((*
B <: /, / / ET E E 8   - - - - ,0 $!-1&)$&) &)&) 	&)
 &) +&) &)P 6 6 6 6  ?&
9 
 
J>4 $(/3M
 M
 M
 m+,	M

 M
 M
^ ! ! - -
!-!!
"-)0-&(0  37 	Q3./Q Q 	Q Q@ !%26 QQ Q 	Q
 Q Q 3./Q Q Qh IM&2P1?&?&;(50 5)  5)n ;  ;0 aM,>,>T    * 76 
 
 (( ((T H H    8 $ $LCFJ 7 7&%
N L L&  *  *F = =<  P Pr +
Z> @@LD[15l1B+C [1z
1
1 46880 . .d 7r !"ad:M# #J  8  


1 1f  . IM. .B    2 2h =>! !F -    - ^    D %  %N   @   @ ;   ; ~ \2| $ $  
ggjjhh|
   |
B "#jjhh!R$R$ R$ c3h	R$
 R$ R$ R$ R$ R$ R$h

 ,' R"0k k k(9K kZ
 4,  8  ggjjii%]] ++)I  !I   IV
  %]]R$R$ R$ 	R$
 R$ R$   R$h  #!$(.%]]$)3
sm3
 c]3
 	3

 3
 3
 3
 %*%3
 3
 3
 3
 3
 3
 "3
 3
j  


\
 \
F 


1L 	1Lf
K" 


VD VD 	VDpN`;$   
 % %(-	-
$ ##^%:%:;+
Z 
 ##^%:%:;68 68p7.r+ 

4 5    5 n B   BH   (        1 1:    "'#'0'%0' 0'  	0'
 !0' 0'j $
L D
 D
L # # #. $"x $" $"L )  )X B%~; ;r   r   zFPDF.add_highlightF)
r   rK   rL   r   rZ   r[   r\   rI   rU   r   r7  )r  rR  loggingr  rz  r  sysr  r   collectionsr   
contextlibr   r   r   	functoolsr   r	   numbersr
   os.pathr   pathlibr   typingr   r   r   r   r   r   ,cryptography.hazmat.primitives.serializationr   endesiver   r  	PIL.Imager   r   actionsr"   annotationsr#   r$   r%   r&   bidir'   r(   deprecationr)   r*   r+   drawingr,   r-   r.   r/   r0   r1   r2   r3   
encryptionr4   enumsr5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   rH   rI   rJ   rK   rL   rM   errorsrN   rO   rP   r   rQ   rR   rS   rT   rU   rV   rN  rW   htmlrX   image_datastructuresrY   rZ   r[   r\   image_parsingr]   r^   r_   r`   linearizationra   
line_breakrb   rc   rd   re   outlinerf   r  rg   rh   ri   rj   rk   rl   rm   rn   rE  ro   r  rp   structure_treerq   r2  rr   rs   syntaxrt   ru   rv   rr  rw   rx   text_regionry   rz   transitionsr{   unicode_scriptr|   r}   utilr~   r   FPDF_VERSIONr   	getLoggerr   r  __file__resolverV  HERErO  SINGLE_PAGE
ONE_COLUMNTWO_COLUMN_LEFTr  r   r   r   r   modulesr#  __pdoc____all__r   r   r    <module>r     s*    	   	 	 
   # % '      H H C	   < 
	 	 	 0      6 Y X Q Q .    4  $	 	 	 #  0 # 5 5 * 5 # = + 


 + 
		8	$H~&&v$$''%%	$Z $!SH	}T }TFj #CH   !%(Sp   NFF 
  MMP s$   (I 5I II"JJ