� J�g�U����ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl m Z ddl m Z ddl m Z mZddlmZddlmZddlmZddlmZdd lmZdd lmZmZmZmZmZmZ dd lm Z dd l!m"Z"n#e#$rd \Z Z"YnwxYw ddl$m%Z%n(#e#$r ej&d��Gd�d��Z%YnwxYwddl'm(Z(ddl)m*Z*m+Z+m,Z,m-Z-ddl.m/Z/m0Z0ddl1m2Z2m3Z3m4Z4ddl5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=ddl>m?Z?ddl@mAZAmBZBmCZCmDZDmEZEmFZFmGZGmHZHmIZImJZJmKZKmLZLmMZMmNZNmOZOmPZPmQZQmRZRmSZSmTZTmUZUmVZVmWZWddlXmYZYmZZZm[Z[ddl\m]Z]m^Z^m_Z_m`Z`maZambZbddlcmdZdddlemfZfddlgmhZhmiZimjZjmkZkddllmmZmmnZnmoZompZpdd lqmrZrdd!lsmtZtmuZumvZvmwZwdd"lxmyZydd#lzm{Z{m|Z|m}Z}m~Z~mZdd$l�m�Z�dd%l�m�Z�dd&l�m�Z�dd'l�m�Z�m�Z�dd(l�m�Z�m�Z�m�Z�dd)l�m�Z�m�Z�dd*l�m�Z�m�Z�dd+l�m�Z�dd,l�m�Z�m�Z�dd-l�m�Z�m�Z�d.Z�d/d0d1d2d3d4�Z� ej�e���Z�ee�������j�Z�e�d5z Z�deLj�eLj�eLj�d6�Z�Gd7�d8e��Z�d@d9�Z�d:�Z�Gd;�d<ede���Z�e2ej�e�_�d=d>iZ�gd?�Z�dS)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��eZdZdS)rN)�__name__� __module__� __qualname__���Y/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/fpdf/fpdf.pyrr+s������ �rr�)� 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� RenderStyle� TextDirection� TextEmphasis�TextMarkupType�TextMode�WrapMode�XPos�YPos)� 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�stream_content_for_raster_image)� FPDFRecorder)� Signature)�StructureTreeBuilder)�Percent� SVGObject)�DestinationXYZ�PDFArray�PDFDate)�Table�draw_box_borders)�TextRegionMixin� TextColumns)� Transition)� UnicodeScript�get_unicode_script)�get_scale_factor�Paddingz2.8.2)��Q�O�@g33333��@)� ףp=��@rx)gףp= Oz@ry)�di)rzi�)�a3�a4�a5�letter�legal�font)�default�single� continuous�twoc�F�eZdZUeed<eed<eed<eed<dZeed<dS)�ToCPlaceholder�render_function� start_page�y�page_orientationr�pagesN)rrrr �__annotations__�int�strr�rrrr�r��sG������������O�O�O� �F�F�F������E�3�N�N�N�N�Nrr�c�N�t|t��r;|���}|tvr t|St |d����|�t |d���� |d|z|d|zfS#t $r}|�d|��}t d|����|�d}~wwxYw) aOReturn 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)�onerrz, zArguments must be numbers: )� isinstancer��lower� PAGE_FORMATSrJ� Exception)�format�k�e�argss r�get_page_formatr��s���(�&�#���<������� �\� !� !���'� '�%�f�d�;�;�;�;��y�%�f�$�7�7�7�7�S��a�y�1�}�f�Q�i�!�m�+�+�� �S�S�S����A����%�&J�D�&J�&J�K�K�QR�R�����S���s�%A;�; B$�B�B$c�<��t����fd���}|S)z$Decorator to protect drawing methodsc���|js9|�d��s$|�d��std����|g|�Ri|��S)N�dry_run� split_only�/No page open, you need to call add_page() first)�page�getrI)�selfr��kwargs�fns �r�wrapperzcheck_page.<locals>.wrapper�se����y� S�&�*�*�Y�"7�"7� S�6�:�:�l�;S�;S� S�� Q�R�R� R��r�$�(��(�(�(��(�(�(rr)r�r�s` r� check_pager��s5��� �2�Y�Y�)�)�)�)��Y�)� �Nrc� ��eZdZdZdZdZdZdZej dej ��Z dZ dZ ej d ��Zej d ��ZeZ dވfd� Zdejej��dfd�Zd�Zd�Zedefd���Zedefd���Zedefd���Z e j!d���Z ed���Z"ed���Z#ed���Z$d�Z%d�d�Z&d�Z'd �Z(d!�Z)d�d#�Z*ed$���Z+d%�Z,d�d'�Z- d�d(ed)e.d*e/e0e1fd+e0d,e0f d-�Z2ed.���Z3e3j!d/���Z3d0�Z4d1�Z5d2�Z6d3�Z7d4�Z8d5�Z9d6�Z:d7�Z;d�d8�Z<d9�Z=d:�Z>d;�Z?d�d=�Z@ d�d>e/e0eAfd?e0d@eBfdA�ZC d�dCe0dDe0dEedFeDdGeEd>e/e0eAfd?e0d@eBfdH�ZF d�dI�ZGdJ�ZHdK�ZIdL�ZJdM�ZKd�dN�ZLd�dO�ZMd�dP�ZNd�dQ�ZOdR�ZPdS�ZQeReSd�dT�����ZTdU�ZUeRd"d"eVjWdfdV���ZXd�dW�ZYd�dX�ZZdY�Z[eSdZ���Z\eSd�d[���Z]eSd�d\���Z^eSd�d^���Z_eSd�d_���Z`d`�ZaeSd�da���Zbdb�ZceSd�dc���ZdeSd�dd���ZeeSd�de���ZfeS d�df���Zg d�dg�Zhd�dh�Zid�di�Zjd�dj�Zkdk�Zldl�Zmdm�Znd�dn�Zod�dp�Zpd�dq�ZqeSd�dr���Zr d�ds�ZseSd]d]detfdt���ZueSd�du���ZveS d�dv���ZweSdw���ZxeR d�dz���ZyeRd{���ZzeS d�d|���Z{eS d�d}���Z|eSe}d�d~�����Z~eSd�d���ZeSeRd�d������Z�eSeRd�d������Z�eSeRd������Z�eSeRd������Z� d�d��Z�d��Z�ed����Z�eSe}dddBd"de�j�ddBdde�j�e�j�f d������Z�dd"e�j�e�j�ddBddfd�e�d�eDd�e/e0eBfd�e�d�e�d�ed�e0d�ed�e�fd��Z�d��Z�d��Z�d��Z�d�d��Z�d�e0d�ede�e�fd��Z�d��Z�d��Z�d��Z�d��Z�eRd����Z�eSe}ddBd"e�j�dddBdddde�j�e�j�e�j�de�j�dd"fd�e�fd������Z�eSe}ddBdBde�j�fd�eDd�e0d�e0d�ed�e�f d������Z�eSdddd]d�dd�d]ddde�j�df d�e�e0d�e�e0d�ed�eBd�eDd�ed�e/e�e0fd�eDd�eDd�eDd�ed�e�d�efd����Z�eS d�d����Z� d�d�e�fd��Z�d��Z� �dd�e�d�e�fd��Z�d��Z�d�d��Z�eRd����Z�d��Z�eSd�d����Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�dd�dddde�j�e�j�ffd��Z�eSd�d�dddde�j�e�j�ffdÄ��Z�dĄZ�dńZ�dƄZ�d�dDŽZ�dȄZ�eSe}�ddɄ����Z�eSe}�dd̄����Z�eSeRd̈́����Z�eSeRd΄����Z�eSeRdτ����Z�eRdЄ��Z�eRdф��Z�eS �dd�e�d�eBd�efdՄ��Z� �ddքZ�eS�ddׄ��Z�eRd�e�fdل��Z�eRd�e�fdۄ��Z�eSeRd܄����Z�dBdBde�fd݄ZԈxZ�S(�FPDFzPDF Generation classz**�__z--�\z^\[([^][]+)\]\(([^()]+)\)(.*)$NTz /(GS\d+) gsz /I(\d+) Do�portrait�mm�A4� DEPRECATEDc�V��|dkr(tjdtt�����t �����d|_ d|_ i|_i|_ tt��|_ i|_ g|_t��|_tt��|_d|_d|_d|_|���d|_d|_d|_d|_d|_d|_d|_t;��|_d|_g|_ d|_!d|_"d|_#d|_$d|_%i|_&d |_' d d d d �|_(tS|��|_*d|_+d|_,d|_-d|_.d|_/d|_0d|_1|j2|_3|j4|_5|j6|_7d|_8tsddd���|_:d|j*z |_;txj=|_>t||j*��\|_@|_A|�B||j@|jA��|jC|_Dd|j*z }d\|_E|_F|_G|_H|�I||��|jG|jHc|_E|_F|dz |_J|�Kdd|z��|�Ld��d|_Md|_Nd|_Od|_Pt�jRt�jT��|_Ud|_Vg|_Wd|_Xd|_Yt���|_[tt��|_\d|_]tt���|__d|_`dS)ak Args: orientation (str): possible values are "portrait" (can be abbreviated "P") or "landscape" (can be abbreviated "L"). Default to "portrait". unit (str, int, float): possible values are "pt", "mm", "cm", "in", or a number. A point equals 1/72 of an inch, that is to say about 0.35 mm (an inch being 2.54 cm). This is a very common unit in typography; font sizes are expressed in this unit. If given a number, then it will be treated as the number of points per unit. (eg. 72 = 1 in) Default to "mm". format (str): possible values are "a3", "a4", "a5", "letter", "legal" or a tuple (width, height) expressed in the given unit. Default to "a4". font_cache_dir (Path or str): [**DEPRECATED since v2.5.1**] unused r�zV"font_cache_dir" parameter is deprecated since v2.5.1, unused and will soon be removed�� stacklevelFrNT��latin-1� helvetica�courier�times)�arial� couriernew� timesnewroman�� �d��dash�gap�phaseg��/�$�?g��b�X<@)rrrrg$@� fullwidthz1.3)a�warnings�warn�DeprecationWarningr'�super�__init__�single_resources_objectr�r��fontsr�set�fonts_used_per_page_number�links�embedded_filesrT� image_cache�images_used_per_page_number� in_footer�_in_unbreakable�_lasth�alias_nb_pages�_angle� xmp_metadata� page_duration�page_transition�allow_images_transparency�oversized_images�oversized_images_ratiori�struct_builder�toc_placeholder�_outline�in_toc_rendering�_toc_allow_page_insertion�_toc_inserted_pages� _sign_key�title�section_title_styles�core_fonts_encoding� font_aliasesrvr�� font_family� font_style� underline� font_size_pt�font_stretching� char_spacing� current_font�DEFAULT_DRAW_COLOR� draw_color�DEFAULT_FILL_COLOR� fill_color�DEFAULT_TEXT_COLOR� text_color�page_background�dict� dash_pattern� line_widthrE�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�$graphics_style_names_per_page_number�_record_text_quad_points�list�_text_quad_points�buffer)r�� orientation�unitr��font_cache_dir�margin� __class__s �rr�z FPDF.__init__�s����( �\� )� )� �M�6�#�*�,�,�  � � � � ��������',��$� � �� � � *,�� ��� �*5�c�*:�*:��'��� � ���%�<�<���+6�s�+;�+;��(����$����� � �������� � ������#���)-��&� $���&'��#�2�4�4���#���.0�� � %���).��&�#$�� ������ �$&��!�#,�� �+�!�#�$� � ��� "�$�'�'���������������"������ ����1����1����1���#��� �a�Q�a�8�8�8����$�&�.���!����"1����!@�!@��� �D�J� ���k�4�:�t�z�B�B�B�#�3������&��7A�4������ �t�}� �����(�(�(���� �������� �� � � � ��q�6�z�2�2�2� ���k�*�*�*����"&����� � ���%�\�(�,�7�7���!%���"$���*/��'�%)��"�0I�0K�0K��-�4?��4D�4D��1�(-��%�"-�T�!2�!2����� � � rFc�:�t||||||���|_dS)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)r1r )r�rrr� permissionsrs r�set_encryptionzFPDF.set_encryptionzs3��0"9� �)�'�"�/�-� " �" �" ����rc��|j|g|�Ri|��}|���5|�|��ddd��dS#1swxYwYdS)a+ Parse HTML and convert it to PDF. cf. https://py-pdf.github.io/fpdf2/HTML.html Args: text (str): HTML content to render image_map (function): an optional one-argument function that map `<img>` "src" to new image URLs li_tag_indent (int): [**DEPRECATED since v2.7.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 identation. - 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_htmlzFPDF.write_html�s���4(�4�'��>�t�>�>�>�v�>�>�� � � � !� !� � � �M�M�$� � � � � � � � � � � � � � � ���� � � � � � s�A � A �A c�:�t|j|��|_dS�N)�maxr)r��versions r�_set_min_pdf_versionzFPDF._set_min_pdf_version�s���t�/��9�9����r�returnc�V�tj|jr |j�d�n|j��S)z;The current text emphasis: bold, italics and/or underlined.�U)rC�coercer�r��r�s r�emphasisz FPDF.emphasis�s5���"�%)�^� H�t�� !� !� !� !��� � � rc�0�|jo|jjdkS)N�TTF)r��typer2s r� is_ttf_fontzFPDF.is_ttf_font�s��� �D�T�%6�%;�u�%D�Drc��|jSr*)rr2s r� page_modezFPDF.page_mode�s ����rc���tj|��|_|jtjkr|�d��dS|jtjkr|�d��dSdS)N�1.6�1.5)r>r1r�USE_ATTACHMENTSr-�USE_OC)r�r9s rr9zFPDF.page_mode�sn��"�/�)�4�4��� �?�h�6� 6� 6� � %� %�e� ,� ,� ,� ,� ,� �_��� /� /� � %� %�e� ,� ,� ,� ,� ,�0� /rc�0�|j|jz |jz S)zT Effective page width: the page width minus its horizontal margins. )�wr��r_marginr2s r�epwzFPDF.epw���� �v�� �%�� �5�5rc�0�|j|jz |jz S)zT Effective page height: the page height minus its vertical margins. )�hr��b_marginr2s r�ephzFPDF.eph�rCrc�*�t|j��S)z: Returns the total pages of the document. )�lenr�r2s r� pages_countzFPDF.pages_count�s�� �4�:���rc�h�|�||��|�|j|��dS)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)rr�auto_page_break�r�rs r� set_marginzFPDF.set_margin�s9�� �����(�(�(� � � ��!5�v�>�>�>�>�>r�����c��|�|��|j|ks|j|jkr||_||_|dkr|}||_dS)a� Sets the document left, top & optionaly right margins to the same value. By default, they equal 1 cm. Also sets the current FPDF.y on the page to this minimum vertical position. Args: left (float): left margin in the unit specified to FPDF constructor top (float): top margin in the unit specified to FPDF constructor right (float): optional right margin in the unit specified to FPDF constructor rON)�set_left_marginr�r�rA)r��left�top�rights rrzFPDF.set_margins�sX�� ���T�"�"�"� �6�C�<�<�4�6�T�]�2�2��D�F��� � �B�;�;��E��� � � rc�X�|j|ks|j|jkr||_||_dS)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�rMs rrQzFPDF.set_left_margins/�� �6�F�?�?�d�f�� �5�5��D�F��� � � rc��||_dS)z� Sets the document top margin. Args: margin (float): margin in the unit specified to FPDF constructor N)r�rMs r�set_top_marginzFPDF.set_top_margin����� � � rc��||_dS)z� Sets the document right margin. Args: margin (float): margin in the unit specified to FPDF constructor N)rArMs r�set_right_marginzFPDF.set_right_marginrXrrc�J�||_||_|j|jz |_dS)ab Set auto page break mode and triggering bottom margin. By default, the mode is on and the bottom margin is 2 cm. Args: auto (bool): enable or disable this mode margin (float): optional bottom margin (distance from the bottom of the page) in the unit specified to FPDF constructor N)rLrFrE�page_break_trigger)r��autors rrzFPDF.set_auto_page_break#s*�� $����� �"&�&�4�=�"8����rc�d�|jtjkr|j|jfn |j|jfS)zGReturn a pair (width, height) in the unit specified to FPDF constructor)r�r?�PORTRAITr�r�r2s r�default_page_dimensionszFPDF.default_page_dimensions1s7�� �#��'?�?�?��Z��� $� $��*�d�j�)� rc�L�tj|��|_|jtjur||_||_n||_||_|j|jz |_|j|jz |_t|d��r"|� |j |j ��dSdS)NrL) r?r1r�r_�w_pt�h_ptr�r@rE�hasattrrrLrF)r�r� page_width_pt�page_height_pts rr�zFPDF._set_orientation:s���.�5�k�B�B��� � �?�#;� ;� ;�%�D�I�&�D�I�I�&�D�I�%�D�I���T�V�#�����T�V�#��� �4�*� +� +� J� � $� $�T�%9�4�=� I� I� I� I� I� J� Jrr�c���|tvst|t��s||_n|dkrt d|�����t �||��|_dS)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�zIncorrect zoom display mode: N)rbr�r�� zoom_moderI�LAYOUT_ALIASESr�� page_layout)r��zoom�layouts rrzFPDF.set_display_modeHsg��$ �<� � �z�$��'<�'<� �!�D�N�N� �Y� � �� F�� F� F�G�G� G�)�-�-�f�f�=�=����r�use_shaping_engine�features� direction�script�languagec��|s d|_dS ddl}n"#t$r}td��|�d}~wwxYw|r$t |t ��std���|si}d}|rTt |t ��r|nt j|��}|t jt j fvrtd���d||||ddd�|_dS)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" NrziThe 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)rmrnrorprq�fragment_direction�paragraph_direction) � text_shaping� uharfbuzz� ImportErrorrIr�r�rBr1�LTR�RTL) r�rmrnrorprqrv�exc�text_directions r�set_text_shapingzFPDF.set_text_shaping`s6��."� � $�D� � �F� � � � � � ��� � � ��{���� ����� ���� � �J�x��6�6� ��O��� �� ��H��� � ��i��7�7�5� � �"�)�)�4�4� � �m�&7��9J�%K�K�K�#�f���� #'� �'�� �"&�#'� � ����s�� 1�,�1c��|jSr*)� _page_layoutr2s rrjzFPDF.page_layout�s ��� � rc��|rtj|��nd|_|jtjtjfvr|�d��dSdS)Nr<)r=r1r~� TWO_PAGE_LEFT�TWO_PAGE_RIGHTr-)r�rjs rrjzFPDF.page_layout�s[��>I�S�J�-�k�:�:�:�t��� � ��!9�:�;T� U� U� U� � %� %�e� ,� ,� ,� ,� ,� V� Urc��||_dS)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�rs r�set_compressionzFPDF.set_compression�s��!�� � � rc��||_dS)a? Defines the title of the document. Most PDF readers will display it when viewing the document. There is also a related `fpdf.prefs.ViewerPreference` entry: pdf.viewer_preferences = ViewerPreference(display_doc_title=True) Args: title (str): the title N�r�)r�r�s r� set_titlezFPDF.set_title�s���� � � rc�F�||_|r|�d��dSdS)a� A language identifier specifying the natural language for all text in the document except where overridden by language specifications for structure elements or marked content. A language identifier can either be the empty text string, to indicate that the language is unknown, or a Language-Tag as defined in RFC 3066, "Tags for the Identification of Languages". Args: lang (str): the document main language �1.4N)�langr-)r�r�s r�set_langz FPDF.set_lang�s7���� � � -� � %� %�e� ,� ,� ,� ,� ,� -� -rc��||_dS)zz Defines the subject of the document. Args: subject (str): the document main subject N)�subject)r�r�s r� set_subjectzFPDF.set_subject�s���� � � rc��||_dS)zt Defines the author of the document. Args: author(str): the name of the author N)�author)r�r�s r� set_authorzFPDF.set_author�s���� � � rc��||_dS)z� Associate keywords with the document Args: keywords (str): a space-separated list of words N)�keywords)r�r�s r� set_keywordszFPDF.set_keywords�s��!�� � � rc��||_dS)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_creatorzFPDF.set_creator�s���� � � rc��||_dS)zProducer of documentN)�producer)r�r�s r� set_producerzFPDF.set_producer s �� �� � � rc���|jrtd���t|t��st dt |�������|js|���}||_dS)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�rIr�r� TypeErrorr6�tzinfo� astimezoner )r��dates r�set_creation_datezFPDF.set_creation_date sz�� �>� ��T��� ��$��)�)� P��N�$�t�*�*�N�N�O�O� O��{� %��?�?�$�$�D�!����rc�|�d|dd�vrtd���||_|r|�d��dSdS)Nz <?xpacket�2z@fpdf2 already performs XMP metadata wrapping in a <?xpacket> tagr�)� ValueErrorr�r-)r�r�s r�set_xmp_metadatazFPDF.set_xmp_metadatasa�� �,�s��s�+� +� +��R��� �)��� � -� � %� %�e� ,� ,� ,� ,� ,� -� -rc��tjdtt�����|dkrt d|�d����||_dS)a Defines a document option. Args: opt (str): name of the option to set value (str) option value .. deprecated:: 2.4.0 Simply set the `FPDF.core_fonts_encoding` property as a replacement. z�set_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�zUnknown document option "�"N)r�r�r�r'rIr�)r��opt�values r�set_doc_optionzFPDF.set_doc_option"sg�� � �S� �&�(�(� � � � � �'� '� '�� B�C� B� B� B�C�C� C�#(�� � � rc���|tvr-td|�dd�t�������||j_|dkr|�d��dSdS)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�� JPXDecoder<N)rXr��joinr�� image_filterr-)r�r�s r�set_image_filterzFPDF.set_image_filter:s��� �6� 6� 6��I�L�I�I�&(�g�g�.E�&F�&F�I�I��� �)5���%� �;� &� &� � %� %�e� ,� ,� ,� ,� ,� '� &r�{nb}c��||_dS)a Defines an alias for the total number of pages. It will be substituted as the document is closed. This is useful to insert the number of pages of the document at a time when this number is not known by the program. This substitution can be disabled for performances reasons, by calling `alias_nb_pages(None)`. Args: alias (str): the alias. Defaults to "{nb}". Notes ----- When using this feature with the `FPDF.cell` / `FPDF.multi_cell` methods, or the `.underline` attribute of `FPDF` class, the width of the text rendered will take into account the alias length, not the length of the "actual number of pages" string, which can causes slight positioning differences. N)�str_alias_nb_pages)r��aliass rr�zFPDF.alias_nb_pagesMs��,#(����r� label_style� label_prefix� label_startc� �|jdkrdn&|j|jdz ���}d}|s|s|r+|rtj|d���nd}t |||��}|j|j�||��dS)NrT��case_sensitive)r�r��get_page_labelr<r1re�set_page_label)r�r�r�r��current_page_label�new_page_labels rr�zFPDF.set_page_labeles����I��N�N�D�D�� �4�9�q�=�(A�(P�(P�(R�(R� ��� � R�,� R�+� R����%�k�$�G�G�G�G�� � *�+�|�[�Q�Q�N� � �4�9��,�,�-?��P�P�P�P�Prr�rr��same�duration� transitionc � �|jrtd���|j} |jr |j�d�n|j} |j} |j} |j} |j}|j }|j }|j }|j }|j o|jo|j|jjk}|jdkr+|j r|r"d|_|���d|_|jdkrdn#|j|j���}d}|s|s|r+|rt-j|d���nd}t1|||��}|�||||p|j|p|j|��� ���|j|j�||��|jr�t?|jt@��rC|j!|j�|�"dd|j#|j$d � ��|j!|j%�n(|�&|jdd|j#|j$��|�'d ��| |_|�'| |j(zd �d ���| r|�)| | | ��| |_| |j*kr9|�'| �+���,����||_||j-kr9|�'|�+���.����||_ |j r|jr|�/��|j| kr(| |_|�'| |j(zd �d ���| r|�)| | | ��|j| kr@| |_|�'| �+���,����|j|kr@||_|�'|�+���.����||_ |dkr|�0|��|dkr|�1|��|teddd���kr+|�3|d|d|d��dSdS)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()r0rTFNr�)�new_page�F��stylez2 J�.2f� wr�r�r�r�r�)4rrIr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r��footerr�r�r<r1re� _beginpager�r��_has_next_pager�r�r��tuple�set_fill_color�rectr@rE� colors255�image�_outr��set_fontr�� serialize�upperr�r��header�set_stretching�set_char_spacingr��_write_dash_pattern)r�rr�r�r�r�r�r�r��familyr��size�lw�dc�fc�tc� stretchingr�r��in_toc_extra_pager�r�s r�add_pagez FPDF.add_pagexs���V �;� ��U��� ��!��)-��L�4�?�%�%�%�%�T�_��� �� �_�� �_�� �_�� �_���)� ��(� ��(� � � !� <��.� <�� �D�0�;�;� � �9�q�=�=�$�"7�=�;L�=�!�D�N� �K�K�M�M�M�"�D�N��I��N�N�D�D�� �4�9�(=�(L�(L�(N�(N� ��� � R�,� R�+� R����%�k�$�G�G�G�G�� � *�+�|�[�Q�Q�N� ��� � � � � *��*� � .�$�.��,�,�.�.�.� � � � � � �4�9��,�,�-?��P�P�P� � � G��$�.��6�6� G�#��#�T�%9�:�:�� � �!�Q�����c� �:�:�:�#��#�R�\�2�2�2�� � �4�/��A�t�v�t�v�F�F�F� � � �%������� � � �R�$�&�[�(�(�(�(�)�)�)� � /� �M�M�&�%�� .� .� .���� ��(� (� (� �I�I�b�l�l�n�n�*�*�,�,� -� -� -���� ��(� (� (� �I�I�b�l�l�n�n�*�*�,�,� -� -� -�����%� �$�*H� � �K�K�M�M�M� �?�b� � � �D�O� �I�I��d�f��,�,�,�,� -� -� -� � /� �M�M�&�%�� .� .� .� �?�b� � � �D�O� �I�I�b�l�l�n�n�*�*�,�,� -� -� -� �?�b� � � �D�O� �I�I�b�l�l�n�n�*�*�,�,� -� -� -���� �� � � � � � � +� +� +� �1� � � � !� !�,� /� /� /� �4�Q�A�Q�7�7�7� 7� 7� � $� $��V�$�l�5�&9�<��;P� � � � � � 8� 7rc���|xjdz c_|jr5|jr.|xjdz c_t |j��dz|_d}|rKt t��|||j���}||j|j<|r|�d��n|j|j}|j |_ |j |_ d|_ d|_d|_|r|s|rt!d|�d |�d |�����nF|rt#||j��n |j|jf\}} |�|p|j|| ��|�|j|j��dS) NrT)�contentsr�r��indexr<r�r�rzInconsistent parameters: same=z but orientation=z format=)r�r�r�r�rIr�rd� bytearrayr-r�r�r�r�r�r�r�r�r�r�r�r�r�r��set_dimensionsrbrc) r�rr�r�r�r�r�r�rerfs rr�zFPDF._beginpage s��� � � �Q�� � � � � �T�%C� � � $� $�� )� $� $��D�J���!�+�D�I��H� � )��"���!�%��i� ���D� %)�D�J�t�y� !�� 1��)�)�%�0�0�0���:�d�i�(�D������������"������ � �� �f� � �i�T�i�i�K�i�i�ag�i�i���� �4:�W�����/�/�/�� �D�J�?W� *�M�>� � !� !��3�t�3�]�N� � � � ���D�I�t�y�1�1�1�1�1rc��dS)aW Header to be implemented in your own inherited class This is automatically called by `FPDF.add_page()` and should not be called directly by the user application. The default implementation performs nothing: you have to override this method in a subclass to implement your own rendering logic. Nrr2s rr�z FPDF.header3����rc��dS)al Footer to be implemented in your own inherited class. This is automatically called by `FPDF.add_page()` and `FPDF.output()` and should not be called directly by the user application. The default implementation performs nothing: you have to override this method in a subclass to implement your own rendering logic. Nrr2s rr�z FPDF.footer=r�rc��|jS)zGet the current page number�r�r2s r�page_noz FPDF.page_noGs ���y�rc�J�|j|j���Sr*)r�r�� get_labelr2s rr�zFPDF.get_page_labelKs���z�$�)�$�.�.�0�0�0rc���t|||��}||jkrR||_|jdkrB|�|j��������dSdSdS)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) rN)r0r�r�r�r�r�)r��r�g�br�s r�set_draw_colorzFPDF.set_draw_colorN�s��-�Q��1�5�5� � ��� (� (�(�D�O��y�1�}�}�� � �$�/�3�3�5�5�;�;�=�=�>�>�>�>�>� )� (��}rc���t|||��}||jkrR||_|jdkrB|�|j��������dSdSdS)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) rN)r0r�r�r�r�r�)r�r�r�r�r�s rr�zFPDF.set_fill_colorar�rc�2�t|||��|_dS)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)r0r�)r�r�r�r�s r�set_text_colorzFPDF.set_text_colorts��2�!�Q��:�:����rc��|r|n|�|��}d}|�||��D]}||���z }�|S)a& Returns the length of a string in user unit. A font must be selected. The value is calculated with stretching and spacing. Note that the width of a cell has some extra padding added to this width, on the left & right sides, equal to the .c_margin property. Args: s (str): the string whose length is to be computed. normalized (bool): whether normalization needs to be performed on the input string. markdown (bool): indicates if basic markdown support is enabled r)�normalize_text�_preload_bidirectional_text� get_width)r��s� normalized�markdownr@�frags r�get_string_widthzFPDF.get_string_width�s_��� 7�A�A��!4�!4�Q�!7�!7�� ���4�4�Q��A�A� "� "�D� ����!�!� !�A�A��rc��||jkr5||_|jdkr%|�||jzd�d���dSdSdS)aF Defines the line width of all stroking operations (lines, rectangles and cell borders). By default, the value equals 0.2 mm. The method can be called before the first page is created and the value is retained from page to page. Args: width (float): the width in user unit rr�r�N)r�r�r�r�)r��widths r�set_line_widthzFPDF.set_line_width�sZ�� �D�O� #� #�#�D�O��y�1�}�}�� � �U�T�V�^�3�3�3�3�4�4�4�4�4� $� #��}rc ��t|ttjtt t td��f��r,t|t ��r|j|_ dS||_ dStdt|�������)aB Sets a background color or image to be drawn every time `FPDF.add_page()` is called, or removes a previously set background. The method can be called before the first page is created and the value is retained from page to page. Args: background: either a string representing a file path or URL to an image, an io.BytesIO containg an image as bytes, an instance of `PIL.Image.Image`, drawing.DeviceRGB or a RGB tuple representing a color to fill the background with or `None` to remove the background Nzkbackground must be of type str, io.BytesIO, PIL.Image.Image, drawing.DeviceRGB, tuple or None got: ) r�r��io�BytesIOrr)r�r6r�r�r�)r�� backgrounds r�set_page_backgroundzFPDF.set_page_background�s��� � ��b�j�%��E�4��:�:�N� � � ��*�i�0�0� 2�'1�';��$�$�$�'1��$�$�$��#��:���#�#��� rc#�K�|j�td���t��}||_ |V�d|_n #d|_wxYw|���}|jt |j|j��|j|j |f}|r|j g|�|�R�}n |j |�}|j |j �d�|j�|��D����|j|j �d�|j�|��D����|�|��|�d��dS)a� Create a context for drawing paths on the current page. If this context manager is called again inside of an active context, it will raise an exception, as base drawing contexts cannot be nested. Args: debug_stream (TextIO): print a pretty tree of all items to be rendered to the provided stream. To store the output in a string, use `io.StringIO`. Nz9cannot create a drawing context while one is already openc3�@K�|]}|�d��V��dS�rN)�group��.0�matchs r� <genexpr>z'FPDF.drawing_context.<locals>.<genexpr>�sE����D �D �$�E�K�K��N�N�D �D �D �D �D �D rc3�ZK�|]&}t|�d����V��'dSr )r�r r s rrz'FPDF.drawing_context.<locals>.<genexpr>�sE����; �; �$)�C�� � �A��� � �; �; �; �; �; �; rr�)rrIr*�_current_graphic_stylerr.r�r�r�rE� render_debug�renderrr��update� _GS_REGEX�finditerr�� _IMG_REGEXr�r-)r�� debug_stream�context�starting_style� render_args�rendereds r�drawing_contextzFPDF.drawing_context�s����� � %� 1��K��� �!�"�"��%,��"� .��M�M�M�)-�D� &� &���D� &� -� -� -� -��4�4�6�6�� � 1� �$�&�$�&� !� !� �F� �F� �  � � � 4�+�w�+�G�[�G�,�G�G�G�H�H�%�w�~�{�3�H� �1�$�)�<�C�C�D �D �(,��(?�(?��(I�(I�D �D �D � � � � �(���3�:�:�; �; �-1�_�-E�-E�h�-O�-O�; �; �; � � � � � � �(���� �!�!�%�(�(�(�(�(s �;� Ac�L�t��}|j|_|j|_|j|jkr |j|_|j|j kr |j|_|j }|d|df}|ddks |ddkrd}||_ |d|_ |S)Nr�r�rrr�) r,r��allow_transparencyr�� stroke_widthr�r�� stroke_colorr�r�r��stroke_dash_pattern�stroke_dash_phase)r��gs� dash_infor�s rrzFPDF._current_graphic_style�s��� �_�_�� $� >��� �/��� �?�d�5� 5� 5�"�o�B�O� �?�d�5� 5� 5� �O�B�M��%� �!�&�)�9�U�+;�<� � ��O�q� � �l�1�o��&:�&:��L�!-���(��1���� rc#��K�|�|���5}t||���}||j_|V�|�|��ddd��dS#1swxYwYdS)aY Create a path for appending lines and curves to. Args: x (float): Abscissa of the path starting point y (float): Ordinate of the path starting point paint_rule (PathPaintRule): Optional choice of how the path should be painted. The default (AUTO) automatically selects stroke/fill based on the path style settings. debug_stream (TextIO): print a pretty tree of all items to be rendered to the provided stream. To store the output in a string, use `io.StringIO`. �r)r�r�N)rr-r�� paint_rule�add_item)r�r�r�r'r�ctxt�paths r�new_pathz FPDF.new_path s����� � !� !�|� !� <� <� ����a�(�(�(�D�$.�D�J� !��J�J�J� �M�M�$� � � �  � � � � � � � � � � � ���� � � � � � s�7A�A!�$A!c��|�|���5}|�|��ddd��dS#1swxYwYdS)aI Add a pre-constructed path to the document. Args: path (drawing.PaintedPath): the path to be drawn. debug_stream (TextIO): print a pretty tree of all items to be rendered to the provided stream. To store the output in a string, use `io.StringIO`. r&N)rr()r�r*rr)s r� draw_pathzFPDF.draw_path"s���� !� !�|� !� <� <� �� �M�M�$� � � � � � � � � � � � � � � ���� � � � � � s �:�>�>c��t|ttf��r|dkstd���t|ttf��r|dkstd���t|ttf��r|dkstd���t |||���}||jkr ||_|�|||��dSdS)a� Set the current dash pattern for lines and curves. Args: dash (float): The length of the dashes in current units. gap (float): The length of the gaps between dashes in current units. If omitted, the dash length will be used. phase (float): Where in the sequence to start drawing. Omitting 'dash' (= 0) resets the pattern to a solid line. rz.Dash length must be zero or a positive number.z-gap length must be zero or a positive number.z(Phase must be zero or a positive number.r�N)r�r��floatr�r�r�r�)r�r�r�r��patterns r�set_dash_patternzFPDF.set_dash_pattern/s����4�#�u��.�.� O�4�1�9�9��M�N�N� N��3��e� �-�-� N�#��(�(��L�M�M� M��5�3��,�/�/� I�E�Q�J�J��G�H�H� H��D�c��7�7�7�� �d�'� '� '� '�D� � � $� $�T�3�� 6� 6� 6� 6� 6� (� 'rc���|rF|r(d||jzd�d||jzd�d||jzd�d�}nd||jzd�d||jzd�d�}nd}|�|��dS)N�[z.3f� z] z dz[] 0 d)r�r�)r�r�r�r��dstrs rr�zFPDF._write_dash_patternJs��� � �� F�X�4�$�&�=�X�X�X�s�T�V�|�X�X�X�5�$�&�=�X�X�X�X���E�4�$�&�=�E�E�E��t�v� �E�E�E�E����D� � � �$�����rc ��|�||jzd�d|j|z |jzd�d||jzd�d|j|z |jzd�d���dS)a Draw a line between two points. Args: x1 (float): Abscissa of first point y1 (float): Ordinate of first point x2 (float): Abscissa of second point y2 (float): Ordinate of second point r�r4� m � l SN�r�r�rE)r��x1�y1�x2�y2s r�linez FPDF.lineTs��� � � ��D�F�{� R� 0� 0�$�&�2�+���!7� R� 0� 0��T�V� � R� 0� 0���� �t�v�%� /� 0� 0� 0� � � � � rc���|r(tjdtt�����|r|� tj}n;t j|��}|r%|tjkrtd|�d|�����d}|D]G}|� |d|j zd�d |j |d z |j zd�d |����d }�H|r|� d ��|� d |j ����dS) 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=�mrr�r4r�lz h) r�r�r�r'rA�DFr1�Dr�r�r�rE�operator)r�� point_list�fill�polygonr�rD�points r�polylinez FPDF.polylinedsC�� � � �M�:�#�*�,�,�  � � � � � �E�M��N�E�E��&�u�-�-�E�� ����.�.� �O��O�O��O�O������� � �E� �I�I���8�d�f�$�X�X�X�D�F�U�1�X�,=���+G�X�X�X�h�X�X� � � ��H�H� � � �I�I�d�O�O�O� � � �&�e�n�&�&�'�'�'�'�'rc�8�|�||d|���dS)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)rFrGr�N)rI)r�rErFr�s rrGz FPDF.polygon�s$�� � � �j�t�T�� �G�G�G�G�Grrc���tjdtt�����|�||��|�||||��|���dS)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. z�dashed_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'r1r>)r�r:r;r<r=� dash_length� space_lengths r� dashed_linezFPDF.dashed_line�sy�� � �T� �&�(�(� � � � � ���k�<�8�8�8� � � �"�b�"�b�!�!�!� �������rc ��tj|��}|dur|�|||||||��dS|�||jzd�d|j|z |jzd�d||jzd�d| |jzd�d|j�� ��dS)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�r4� re N)rAr1�_draw_rounded_rectr�r�rErD)r�r�r�r@rEr�� round_corners� corner_radiuss rr�z FPDF.rect�s���<�"�5�)�)�� �� %� %� � #� #�A�q�!�Q��}�m� T� T� T� T� T� �I�I��t�v�:�Q�9�9�T�V�a�Z�4�6�$9�Q�9�9��D�F� �Q�9�9��2���;�8�9�9�(-��9�9� � � � � rc ���|}||kr|}|dkr|dz }||dz kr||z}||fx} } ||z|fx} } ||z||zfx} }|||zfx}}|||z|||zg}||||z||zg}|durBtjjtjjtjjtjjf}t d�|D����}tj|vr8|�|d|dd|zdd|���||z|f} |||zf} tj|vrD|�|d d|zz |d d|zdd|���||z|z |f} ||z||zf} tj|vrP|�|d d|zz |d d|zz d|zdd |���||z||z|z f} ||z|z ||zf}tj|vrD|�|d|dd|zz d|zd d|���||z||zf}|||z|z f}|jr |� | | | | |||| | g d ���|j r�|� | d| d | d| d ��|� | d| d | d| d ��|� |d|d |d|d ��|� |d|d | d| d ��dSdS) Nr�r�Tc3�>K�|]}tj|��V��dSr*)r8r1)r �rcs rrz*FPDF._draw_rounded_rect.<locals>.<genexpr>�s,����H�H�B�f�m�B�/�/�H�H�H�H�H�Hr�ir�r��Zr�) r8� TOP_RIGHTr��TOP_LEFT� BOTTOM_RIGHT� BOTTOM_LEFTr��arc�is_fillrI�is_drawr>)r�r�r�r@rEr�rRr��min�point_1�point_8�point_2�point_3�point_4�point_5�point_6�point_7�coor_x�coor_ys rrQzFPDF._draw_rounded_rect�s����� �q�5�5��C� ��6�6��a��A� ��a��<�<� ��H�A���F�"��'���U�A�J�&��'���U�A��E�N�*��'���A��J�&��'��Q��U�A�q�1�u�%���Q��A��q�1�u�%�� �D� � �� �&���%��#�)��"�(� �M� �H�H�-�H�H�H�H�H� � � �}� ,� ,� �H�H�V�A�Y��q� �1�q�5�#�s�%�H� H� H� H��1�u�a�j�G��!�a�%�j�G� �?�m� +� +� �H�H�V�A�Y��Q��&��q� �1�q�5�#�q��H� N� N� N��1�u�q�y�!�n�G��1�u�a�!�e�n�G� � �� .� .� �H�H�V�A�Y��Q��&��q� �A��E�(9�1�q�5�!�R�u�H� U� U� U��1�u�a�!�e�a�i�(�G��1�u�q�y�!�a�%�(�G� � �-� /� /� �H�H�V�A�Y��q� �A��E� 1�1�q�5�"�c��H� O� O� O��1�u�a�!�e�n�G��!�a�%�!�)�n�G� �=� � �M�M���������� �� � � � � �=� F� �I�I�g�a�j�'�!�*�g�a�j�'�!�*� E� E� E� �I�I�g�a�j�'�!�*�g�a�j�'�!�*� E� E� E� �I�I�g�a�j�'�!�*�g�a�j�'�!�*� E� E� E� �I�I�g�a�j�'�!�*�g�a�j�'�!�*� E� E� E� E� E�  F� Frc�j�tj|��}|�|||||j��dS)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)rAr1� _draw_ellipserD)r�r�r�r@rEr�s r�ellipsez FPDF.ellipse(s8��"�"�5�)�)�� ���1�a��A�u�~�6�6�6�6�6rc��||dz z}||dz z}|dz }|dz } dtjd��dz z|z} dtjd��dz z| z} |�||z|jzd�d|j|z |jzd�d||z|jzd�d|j|z | z|jzd�d|| z|jzd�d|j|z | z|jzd�d||jzd�d|j|z | z|jzd�d���|�|| z |jzd�d|j|z | z|jzd�d||z |jzd�d|j|z | z|jzd�d||z |jzd�d|j|z |jzd�d� ��|�||z |jzd�d|j|z | z |jzd�d|| z |jzd�d|j|z | z |jzd�d||jzd�d|j|z | z |jzd�d� ��|�|| z|jzd�d|j|z | z |jzd�d||z|jzd�d|j|z | z |jzd�d||z|jzd�d|j|z |jzd�d|�� ��dS) Nr�gUUUUUU�?rr�r4r7� cz c )�math�sqrtr�r�rE) r�r�r�r@rErD�cx�cy�rx�ry�lx�lys rrnzFPDF._draw_ellipse<s#�� ��Q��Y�� ��Q��Y�� ��U�� ��U�� �d�i��l�l�Q�&� '�"� ,�� �d�i��l�l�Q�&� '�"� ,�� � � ���G�t�v�%�K�I�I�T�V�b�[�D�F�,B�K�I�I���G�t�v�%�N�I�I�-1�V�b�[�2�-=���,G�N�I�I���G�t�v�%�N�I�I�-1�V�b�[�2�-=���,G�N�I�I����;�H�I�I�'+�f�r�k�B�&6�$�&�%@�H�I�I�I� � � � � � ���G�t�v�%�N�K�K�T�V�b�[�2�-=���,G�N�K�K���G�t�v�%�N�K�K�-1�V�b�[�2�-=���,G�N�K�K���G�t�v�%�J�K�K�-1�V�b�[�D�F�,B�J�K�K�K� � � � � � ���G�t�v�%�N�I�I�T�V�b�[�2�-=���,G�N�I�I���G�t�v�%�N�I�I�-1�V�b�[�2�-=���,G�N�I�I����;�H�I�I�&*�f�r�k�B�&6�$�&�%@�H�I�I�I� � � � � � ���G�t�v�%�N�V�V�T�V�b�[�2�-=���,G�N�V�V���G�t�v�%�N�V�V�-1�V�b�[�2�-=���,G�N�V�V���G�t�v�%�U�V�V�-1�V�b�[�D�F�,B�U�V�V�KS�V�V� � � � � rc�P�|�||z ||z d|zd|z|��dS)ad 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)ro)r�r�r��radiusr�s r�circlez FPDF.circlecs4��$ � � �Q��Z��V��Q��Z��V��U�K�K�K�K�Krc ���|dz }||z}||z } g} td|dz��D]�} ||tjtjd|z | z��tj|��z��zz| |tjtjd|z | z��tj|��z��zzf} | �| ����|�| |���dS)a� Outputs a regular polygon with n sides It can be rotated Style can also be applied (fill, border...) Args: x (float): Abscissa of upper-left bounding box. y (float): Ordinate of upper-left bounding box. numSides (int): Number of sides for polygon. polyWidth (float): Width of the polygon. rotateDegrees (float): Optional degree amount to rotate polygon. style (fpdf.enums.RenderStyle, str): Optional style of rendering. Possible values are: * `D` or None: draw border. This is the default value. * `F`: fill * `DF` or `FD`: draw and fill r�r�hr�N)�rangerr�cos�radians�sin�appendrG) r�r�r��numSides� polyWidth� rotateDegreesr�r{�centerX�centerY�points�irHs r�regular_polygonzFPDF.regular_polygonws��&�Q����f�*���f�*�����q�(�Q�,�'�'� !� !�A��f�t�x�� �c�H�n��1�2�2�T�\�-�5P�5P�P�(�(�����$�(�� �c�H�n��1�2�2�T�\�-�5P�5P�P�#�#����E� �M�M�%� � � � � � � �V�5� �)�)�)�)�)rc��tj|��}g} td|dzdz��D]}} || dzdkr|n|tj|��zz} || dzdkr|n|tj|��zz} | �| | f��|tjd|z ��z }�~|�| d|���dS)a� Outputs a regular star with n corners. It can be rotated. It can be drawn (border only), filled (with no border) or both. Args: x (float): Abscissa of star's centre. y (float): Ordinate of star's centre. r_in (float): radius of internal circle. r_out (float): radius of external circle. corners (int): number of star's corners. rotate_degrees (float): Optional degree amount to rotate star clockwise. style (fpdf.enums.RenderStyle, str): Optional style of rendering. Possible values are: * `D`: draw border. This is the default value. * `F`: fill. * `DF` or `FD`: draw and fill. rr�rrXT)rGr�N)rrr�rr�r�r�rI) r�r�r��r_in�r_out�corners�rotate_degreesr��thrEr��corner_x�corner_ys r�starz FPDF.star�s���(�\�.� )� )��� ��q�7�Q�;�!�+�,�,� .� .�A��Q��U�a�Z�Z�E�E�T�T�X�b�\�\�I�I�H��Q��U�a�Z�Z�E�E�T�T�X�b�\�\�I�I�H� � � �x��2� 3� 3� 3� �$�,�s�W�}�-�-� -�B�B� � � �j�$�e� �<�<�<�<�<rc ����� �!�"�#�$�tj| ��} �����dz��dz�|�z�!|�z�"d��#���#fd�} �#|��} tj| ��� tj| ���$��� �!�"�$fd�}��� �$fd�}| |��}| |��}|s||kr|dtjzz }n|r||kr|dtjzz }||��}| rw|��!|jzd�d|j�"z |jzd�d ���|�|d |jzd�d|j|d z |jzd�d ���nA|�|d |jzd�d|j|d z |jzd�d ���d }t|tj t||z ��dtjz|z z ����}||z |z }tj|��tj d dtj |dz ��dzzz��d z zdz }|}||��}||��}t|��D�]%}|}|}||z }||��}||��}|d ||d zz|d ||d zzg}|d ||d zz |d ||d zz g}d}||d z kr | s d| j��}|�|d |jzd�d|j|d z |jzd�d|d |jzd�d|j|d z |jzd�d|d |jzd�d|j|d z |jzd�d� |z����'| r_| r|�d| j����dS|��!|jzd�d|j�"z |jzd�d| j����dSdS)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�&�|tjzdz S)NrX)rr�pi)�degs r� deg_to_radzFPDF.arc.<locals>.deg_to_rad�s�����=�3�&� &rc�����|dz��}tjtj|���z tj|���z ��}|dkr|dtjzz }|S)Nr~rr�)rr�atan2r�r�r�)�angle�eta�ar�r�s ���r�angle_to_paramz FPDF.arc.<locals>.angle_to_param�s_����J�u�s�{�+�+�E��*�T�X�e�_�_�q�0�$�(�5�/�/�A�2E�F�F�C��Q�w�w��q�4�7�{�"���Jrc����tj|��z}�tj|��z}�|�zz|�zz �|�zz|�zzgSr*)rrr�r�) r�� a_cos_eta� b_sin_etar�r�� cos_thetartru� sin_thetas ������r�evaluatezFPDF.arc.<locals>.evaluate�sa����D�H�S�M�M�)�I��D�H�S�M�M�)�I��Y��*�*�Y��-B�B��Y��*�*�Y��-B�B�� rc����tj|��z}�tj|��z}| �z|�zz | �z|�zzgSr*)rrr�r�)r�� a_sin_eta� b_cos_etar�r�r�r�s ����r�derivative_evaluatez%FPDF.arc.<locals>.derivative_evaluates[����D�H�S�M�M�)�I��D�H�S�M�M�)�I�� �Y�&��Y�)>�>�� �Y�&��Y�)>�>�� rr�r4z mrrz l�rYr�rqzh z l )rAr1rrr�r�r�r�r�rErb�ceil�absrs�tanrrD)%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�rtrur�r�s% ` ` @@@@@rr_zFPDF.arc�sf���������D�"�5�)�)�� �9��A� �Q��� �Q��� ��U�� ��U�� '� '� '� � � � � � � �� �;�'�'���H�U�O�O� ��H�U�O�O� � � � � � � � � � � � � � � � � � � �#�N�;�/�/� � �.��+�+��� %�W� �1�1� �q�4�7�{� "�G�G� � %�7�i�/�/� ��T�W�� $�I��h�y�)�)� � � � �I�I��d�f��I�I�I�D�F�R�K�4�6�+A�I�I�I�I� J� J� J� �I�I��q�>�D�F�*�[�[�[�$�&�;�q�>�2I�T�V�1S�[�[�[�[� � � � � �I�I��q�>�D�F�*�[�[�[�$�&�;�q�>�2I�T�V�1S�[�[�[�[� � � � � � � �� �#�g� �&9�":�":�a�$�'�k�J�>V�"W�X�X� � ���9�$��)�������4�9�Q��T�X�e�a�i�5H�5H�A�5M�1M�-M�#N�#N�QR�#R�S�VW�W���� �X�d�^�^��&�&�t�,�,���q��� � �A��B��H� �E�M�D���$���B�*�*�4�0�0�H�!�!�u�u�x��{�':�:�B�q�E�E�H�UV�K�DW�<W�X�O�!�!�u�u�x��{�':�:�B�q�E�E�H�UV�K�DW�<W�X�O��C��A��E�z�z�-�z�*�%�.�*�*�� �I�I�&�q�)�D�F�2�f�N�N�$�&�?�ST�CU�:U�Y]�Y_�9_�f�N�N�&�q�)�D�F�2�f�N�N�:>�&�?�ST�CU�:U�Y]�Y_�9_�f�N�N��!�u�t�v�~�M�N�N�-1�V�b��e�^�t�v�,E�M�N�N�N�PS�T� � � � � � � � �� � �/�u�~�/�/�0�0�0�0�0�� � ��D�F�{�X�X�X�$�&�2�+���)?�X�X�X���X�X������  � rc �D�|�||||||||dd| � � dS)a� Outputs a solid arc. A solid arc combines an arc and a triangle to form a pie slice It can be drawn (border only), filled (with no border) or both. Args: x (float): Abscissa of upper-left bounding box. y (float): Ordinate of upper-left bounding box. a (float): Semi-major axis. b (float): Semi-minor axis, if None, equals to a (default: None). start_angle (float): Start angle of the arc (in degrees). end_angle (float): End angle of the arc (in degrees). inclination (float): Inclination of the arc in respect of the x-axis (default: 0). clockwise (bool): Way of drawing the arc (True: clockwise, False: counterclockwise) (default: False). style (str): Style of rendering. Possible values are: * `D` or None: draw border. This is the default value. * `F`: fill * `DF` or `FD`: draw and fill TN)r_) r�r�r�r�r�r�r�r�r�r�s r� solid_arczFPDF.solid_arcMsE��> ��� � � � � � � � � � � � � � � � rc �`�t|��}|dvrtd���tj|��}|���5}|d}|d|d}}t ||��} |�| ��|d} | d| d} } |d} | d| d}}|dkr|d}|d|d}}t ||��}tj}|j r|j s tj }n|j r|j s tj }||j _||j _|dkr|�| | ||||��n |dkr|�| | | | ||��|�|��ddd��dS#1swxYwYdS) 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 )rYr�zWpoint_list should contain 3 tuples for a quadratic curve or 4 tuples for a cubic curve.rrr�r�rYN)rIr�rAr1rr-r(r@�STROKE_FILL_NONZEROrar`�STROKE� FILL_NONZEROr�r'� auto_close�curve_to)r�rE�closedr�r�r)r�r:r;� dummy_pathr�r<r=�p3�x3�y3�p4�x4�y4r*�rules r�bezierz FPDF.bezierzs��"�Z���� �� � ��2��� ��"�5�)�)�� � !� !� #� #�" �t��A��B���U�B�q�E��B�$�R��,�,�J� �M�M�*� %� %� %��A��B���U�B�q�E��B��A��B���U�B�q�E��B���{�{���]���A���1��B���r�2�&�&�D�!�4�D��}� 2�U�]� 2�$�+����� 2�u�}� 2�$�1��$(�D�J� !�$*�D�J� !���{�{�� � �b�"�b�"�b�"�5�5�5�5��1���� � �b�"�b�"�b�"�5�5�5� �M�M�$� � � �E" �" �" �" �" �" �" �" �" �" �" �" ����" �" �" �" �" �" s� E F#�#F'�*F'c�t�|std���tt|����d���}|dvrtd|�d����|dkr(t jdt t�����d �t|� ������}td �|D����rtd |�����d tfD]=}|s�t|��|z ���rt|��|z }n�>td |�����|�|j}|����|��}||jvs |t$vr(t jd|�d�t�����dSt'||||��|j|<dS)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�c3�K�|]}|dvV�� dS��BINr�r r~s rrz FPDF.add_font.<locals>.<genexpr>�s'����6�6�f�v�T�!�6�6�6�6�6�6rz9Unknown style provided (only B & I letters are allowed): �.zTTF 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�rMrQ) r�r�r��fname�uni�ext�parent�font_file_path�fontkeys r�add_fontz FPDF.add_font�s��� >��<�=�=� =��s�5�z�z�"�"�1�%�+�+�-�-�� �6� 6� 6��[�C�[�[�[��� � �,� � � �M�6�#�*�,�,�  � � � �����u�{�{�}�}�-�-�.�.�� �6�6��6�6�6� 6� 6� ��S�E�S�S��� ��M�*� I� I�F�� ���V� � �u�$�,�,�.�.� �!%�f����!5���� �$�$G��$G�$G�H�H� H� �>�#�(�F��\�\�^�^�,�U�,�,�� �d�j� � �G�z�$9�$9� �M�M�G�M�M�M�*�,�,� � � � � �F�%�d�N�G�U�K�K�� �7���rc�v�|s|j}|���}d�t|�������}t d�|D����rt d|�����d|vrd|_|�dd��}nd|_||j vrT||z|j vrHtj d|�d|j |�d �tt��� ��|j |}n.|d vr*|r(tj d |�d �t��� ��d}|s|j}|j|kr"|j|krt#|j|��rdS||z}||j vr5|t$vrt'd|�d����t)|||��|j |<||_||_||_|j ||_|jdkr]|�d|jj�d|jd�d���|j|j�|jj��dSdS)a Sets the font used to print character strings. It is mandatory to call this method at least once before printing text. Default encoding is not specified, but all text writing methods accept only unicode for external fonts and one byte encoding for standard. Standard fonts use `Latin-1` encoding by default, but Windows encoding `cp1252` (Western Europe) can be used with `self.core_fonts_encoding = encoding`. The font specified is retained from page to page. The method can be called before the first page is created. Args: family (str): name of a font added with `FPDF.add_font`, or name of one of the 14 standard "PostScript" fonts: Courier (fixed-width), Helvetica (sans serif), Times (serif), Symbol (symbolic) or ZapfDingbats (symbolic) If an empty string is provided, the current family is retained. style (str): empty string (by default) or a combination of one or several letters among B (bold), I (italic) and U (underline). Bold and italic styles do not apply to Symbol and ZapfDingbats fonts. size (float): in points. The default value is the current size. r�c3�K�|]}|dvV�� dS)�BIUNrr�s rrz FPDF.set_font.<locals>.<genexpr>s'����7�7�v�v�U�"�7�7�7�7�7�7rz9Unknown style provided (only B/I/U letters are allowed): r0TFzSubstituting font z by core font z< - This is deprecated since v2.7.8, and will soon be removedr�)�symbol� zapfdingbatszBuilt-in font z6 only has a single 'style' and can't be bold or italicNzUndefined font: z3 - Use built-in fonts or FPDF.add_font() beforehandr�BT /Fr4r�� Tf ET)r�r�r�r�r�r�r�r��replacer�r�r�r�r�r'r�r�r rMrIrLr�r�r�r�r��add)r�r�r�r�r�s rr�z FPDF.set_font�s���4� &��%�F�����������u�{�{�}�}�-�-�.�.�� �7�7��7�7�7� 7� 7� ��S�E�S�S��� � �%�<�<�!�D�N��M�M�#�r�*�*�E�E�"�D�N� �T�&� &� &�6�E�>���+K�+K� �M�O�V�O�O�4�;L�V�;T�O�O�O�"�*�,�,�  � � � � �&�v�.�F�F� �1� 1� 1�e� 1� �M�.��.�.�.�*�,�,� � � � � �E�� %��$�D� � �� &� &���5�(�(���)�4�0�0�)� �F��5�.�� �$�*� $� $��j�(�(�#�H�w�H�H�H���� #+�4��%�"@�"@�D�J�w� �"������ ��� �J�w�/��� �9�q�=�=� �I�I�Q�d�/�1�Q�Q�D�4E�Q�Q�Q�Q� R� R� R� � +�D�I� 6� :� :�4�;L�;N� O� O� O� O� O� �=rc�>�t|j|��rdS||_|jdkrs|jst d���|�d|jj�d|jd�d���|j|j�|jj��dSdS)zp Configure the font size in points Args: size (float): font size in points Nrz3Cannot set font size: a font must be selected firstr�r4r�r�) r r�r�r�rIr�r�r�r�)r�r�s r� set_font_sizezFPDF.set_font_sizeTs��� �4�$�d� +� +� � �F� ��� �9�q�=�=��$� �#�I���� �I�I�Q�d�/�1�Q�Q�D�4E�Q�Q�Q�Q� R� R� R� � +�D�I� 6� :� :�4�;L�;N� O� O� O� O� O� �=rc�|�|j|krdS||_|jdkr|�d|d�d���dSdS)a\ Sets horizontal character spacing. A positive value increases the space between characters, a negative value reduces it (which may result in glyph overlap). By default, no spacing is set (which is equivalent to a value of 0). Args: spacing (float): horizontal spacing in document units Nr�BT r�z Tc ET)r�r�r�)r��spacings rr�zFPDF.set_char_spacingfsX�� � �� '� '� �F�#��� �9�q�=�=� �I�I�/�G�/�/�/�/� 0� 0� 0� 0� 0� �=rc�|�|j|krdS||_|jdkr|�d|d�d���dSdS)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. Nrr�r�z Tz ET)r�r�r�)r�r�s rr�zFPDF.set_stretchingvsX�� � �:� -� -� �F�)��� �9�q�=�=� �I�I�2�J�2�2�2�2� 3� 3� 3� 3� 3� �=rc�:�g}|D]z}d}|jD]Y}|�dd���dd��|���kr|�|��d}�Z|st d|�d�����{t |��|_||_dS) 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��ITzUndefined fallback font: z! - Use FPDF.add_font() beforehandN)r�r�r�r�rIr�r r )r��fallback_fonts� exact_match�fallback_font_ids� fallback_font�foundr�s r�set_fallback_fontszFPDF.set_fallback_fonts�s�����+� � �M��E��:� !� !���?�?�3��+�+�3�3�C��<�<� �@S�@S�@U�@U�U�U�%�,�,�W�5�5�5� �E��� �#�`� �`�`�`���� �#(�(9�":�":���*5��'�'�'r�nullc��t|dkr|jn||j||jzz ||jz|���}t |j��dz}||j|<|S)aO Creates a new internal link and returns its identifier. An internal link is a clickable area which directs to another place within the document. The identifier can then be passed to the `FPDF.cell()`, `FPDF.write()`, `FPDF.image()` or `FPDF.link()` methods. Args: y (float): optional ordinate of target position. The default value is 0 (top of page). x (float): optional abscissa of target position. The default value is 0 (top of page). page (int): optional number of target page. -1 indicates the current page, which is the default value. zoom (float): optional new zoom level after following the link. Currently ignored by Sumatra PDF Reader, but observed by Adobe Acrobat reader. rO)rSrRrkr)rlr�rcr�rIr�)r�r�r�r�rk�link� link_indexs r�add_linkz FPDF.add_link�sk��$�����D�I�I��� �A���J�&��T�V���  � � �� ���_�_�q�(� �!%�� �:���rc��|j|}|dkr|jn||_|j||jzz |_||jz|_||_dS)a� Defines the page and position a link points to. Args: link (int): a link identifier returned by `FPDF.add_link()`. y (float): optional ordinate of target position. The default value is 0 (top of page). x (float): optional abscissa of target position. The default value is 0 (top of page). page (int): optional number of target page. -1 indicates the current page, which is the default value. zoom (float): optional new zoom level after following the link. Currently ignored by Sumatra PDF Reader, but observed by Adobe Acrobat reader. rON)r�r�� page_numberrcr�rSrRrk)r�rr�r�r�rks r�set_linkz FPDF.set_link�sR��$�z�$���(,�� � �4�9�9�����9�q�4�6�z�)������J�� ��� � � rc ��d\}} |rxt|t��rt|��}nS||jvs#Jd|�dt |j���d����|j|} | jst d|�d����t d ||jz|j ||jzz ||jz||jz|| d�|��} |j |j j � | ��|�|�d |� ��| S) a� Puts a link annotation on a rectangular area of the page. Text or image links are generally put via `FPDF.cell`, `FPDF.write` or `FPDF.image`, but this method can be useful for instance to define a clickable area inside an image. Args: x (float): horizontal position (from the left) to the left side of the link rectangle y (float): vertical position (from the top) to the bottom side of the link rectangle w (float): width of the link rectangle h (float): height of the link rectangle link: either an URL or an integer returned by `FPDF.add_link`, defining an internal link to a page alt_text (str): optional textual description of the link, for accessibility purposes border_width (int): thickness of an optional black border surrounding the link. Not all PDF readers honor this: Acrobat renders it but not Sumatra. rzLink with an invalid index: z (doc #links=�)zCannot insert link z with no page number assigned�Link)r�r�r�height�action�destNz/Link)� struct_type�alt_text)r )r�r�rr�rIrr�r!r�rcr�r��annotsr��_add_marked_content) r�r�r�r@rErrr�r r� link_annots rrz FPDF.link�sH��$"� ��� � ��$��$�$� �"�4������D�J�&�&�&�W�$�W�W�S���_�_�W�W�W�'�&�&��z�$�'���'��$�Q�d�Q�Q�Q����$� �  ��$�&�j��i�!�d�f�*�$��d�f�*��t�v�:���  �  ��  �  � � � �4�9��$�+�+�J�7�7�7� � � � $� $��8� $� L� L� L��rc ��|r�|rtd���|rtd���t|��}|�d��5}|���}ddd��n #1swxYwY|j}|���}|�+t j|j��� ��}n"|std���|std���td�|j D����}||vrt|�d����td |||d �|��} |j � | ��|�d ��| S) aT Embed a file into the PDF document Args: file_path (str or Path): filesystem path to the existing file to embed bytes (bytes): optional, as an alternative to file_path, bytes content of the file to embed basename (str): optional, required if bytes is provided, file base name creation_date (datetime): date and time when the file was created modification_date (datetime): date and time when the file was last modified desc (str): optional description of the file compress (bool): enabled zlib compression of the file - False by default checksum (bool): insert a MD5 checksum of the file content - False by default Returns: a PDFEmbeddedFile instance, with a .basename string attribute representing the internal file name z+'bytes' cannot be provided with 'file_path'z.'basename' cannot be provided with 'file_path'�rbNz2'bytes' is required if 'file_path' is not providedz5'basename' is required if 'file_path' is not providedc3�>K�|]}|���V��dSr*)�basename)r �files rrz"FPDF.embed_file.<locals>.<genexpr>/ s;����) �) � $�D�M�M�O�O�) �) �) �) �) �) rz' has already been embedded in this file)rr��modification_dater�r)r�r �open�read�name�statr� fromtimestamp�st_mtimer�r�r�r#r�r-) r�� file_path�bytesrrr�� input_file�stats�already_embedded_basenames� embedded_files r� embed_filezFPDF.embed_file s���. � �� P� �!N�O�O�O�� S� �!Q�R�R�R��Y���I�����%�%� *��"���)�)�� *� *� *� *� *� *� *� *� *� *� *���� *� *� *� *� �~�H��N�N�$�$�E� �(�$,�$:�5�>�$J�$J�$U�$U�$W�$W�!��� W� �!U�V�V�V�� � �K����&)�) �) �(,�(;�) �) �) �& �& �"� �1� 1� 1���Q�Q�Q�R�R� R�'� ���/� � ��  � � � ��"�"�=�1�1�1� �!�!�%�(�(�(��s� A*�*A.�1A.c �n�|j|fi|��} | �d��td||jz|j||jzz ||jz||jz| ���|rt j|��nd|���} |j|j j � | ��| S)a5 Puts a file attachment annotation on a rectangular area of the page. Args: file_path (str or Path): filesystem path to the existing file to embed x (float): horizontal position (from the left) to the left side of the link rectangle y (float): vertical position (from the top) to the bottom side of the link rectangle w (float): optional width of the link rectangle h (float): optional height of the link rectangle name (fpdf.enums.FileAttachmentAnnotationName, str): optional icon that shall be used in displaying the annotation flags (Tuple[fpdf.enums.AnnotationFlag], Tuple[str]): optional list of flags defining annotation properties bytes (bytes): optional, as an alternative to file_path, bytes content of the file to embed basename (str): optional, required if bytes is provided, file base name creation_date (datetime): date and time when the file was created modification_date (datetime): date and time when the file was last modified desc (str): optional description of the file compress (bool): enabled zlib compression of the file - False by default checksum (bool): insert a MD5 checksum of the file content - False by default F�FileAttachmentN)� file_specr�flags) r&�set_globally_enclosedr!r�rcr)r:r1r�r�rr�) r�r r�r�r@rErr*r�r%� annotations r�file_attachment_annotationzFPDF.file_attachment_annotation> s���.(��� �<�<�V�<�<� ��+�+�E�2�2�2�#� � ���J� �I��D�F� � "� ���J� ���J�#�-�-�/�/�>B�L�-�4�T�:�:�:���  �  �  � � � �4�9��$�+�+�J�7�7�7��rc ���td||jz|j||jzz ||jz||jzf||rtj|��ndd�|��}|j|jj�|��|S)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�rcr6r1r�r�rr�) r�r�r�r&r@rErr�r,s r�text_annotationzFPDF.text_annotationd s��� $� � ���J� �I��D�F� � "� ���J� ���J�  � �04�>��&�t�,�,�,�$�  �  ��  �  � � � �4�9��$�+�+�J�7�7�7��rc �(�|jstd���|�|j}|�|j}|�|j}|�|�|dd���}t d||jz|j||jzz ||jz||jzf|d|j � ���d|j j �d |j d �d �d �|��}|j|j�|j j ��|j|jj�|��|S) a0 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() beforehandNTF�r�r��FreeText�(z /Fr4r�z Tf))r��default_appearance)r�rIr�r�� font_sizer�r!r�rcr�r�r�r�r�r�r�r�r�rr�)r�r&r�r�r@rEr�r,s r�free_text_annotationzFPDF.free_text_annotation� s=��4�� W�� U�V�V� V� �9���A� �9���A� �9���A� �9��%�%�d�t�e�%�L�L�A�#� � ���J� �I��D�F� � "� ���J� ���J�  � �t�4�?�#<�#<�#>�#>�t�t�4�CT�CV�t�t�Y]�Yj�t�t�t�t�  �  ��  �  � � �'�� �2�6�6�t�7H�7J�K�K�K� � �4�9��$�+�+�J�7�7�7��rc ���td||jz|j||jzz ||jz||jzfd|i|��}|j|jj�|��|S)a� Puts an Action annotation on a rectangular area of the page. Args: action (fpdf.actions.Action): the action to add x (float): horizontal position (from the left) to the left side of the link rectangle y (float): vertical position (from the top) to the bottom side of the link rectangle w (float): width of the link rectangle h (float): height of the link rectangle �Actionr )r!r�rcr�r�rr�)r�r r�r�r@rEr�r,s r� add_actionzFPDF.add_action� s���$� � ���J� �I��D�F� � "� ���J� ���J�  � � �  �� � � � � �4�9��$�+�+�J�7�7�7��r� Highlight�rrrc +��K�|jrtd���d|_dV�|j���D]\}}|j||f||||d�|���t t ��|_d|_dS)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 zhighlight() cannot be nestedTN)� quad_points�modification_timer��colorF)rrIr�items�add_text_markup_annotationrr)r�r&r6rAr@r�r�r?s r� highlightzFPDF.highlight� s�����" � (� @�� >�?�?� ?�(,��%� ����!%�!7�!=�!=�!?�!?� � � �D�+� +�D� +��� �(�"3���  � �� � � � �"-�T�!2�!2���(-��%�%�%rc/�K�tjdtt�����|j|i|��5dV�ddd��dS#1swxYwYdS)Nz:add_highlight() has been renamed to highlight() in v2.5.5.r�)r�r�r�r'rD)r�r�r�s r� add_highlightzFPDF.add_highlight� s������ � H� �&�(�(� � � � � �T�^�T� ,�V� ,� ,� � � �E�E�E� � � � � � � � � � � � ���� � � � � � s�A � A�Ac ���|�d��tj|��j}|�|j}|�|j}t |ddd���}t |ddd���} t|ddd���} t|ddd���} t|f|| | | |z | | z |||d�|��} |j |j � | ��| S)u� Adds a text markup annotation on some quadrilateral areas of the page. Args: type (fpdf.enums.TextMarkupType, str): "Highlight", "Underline", "Squiggly" or "StrikeOut" text (str): text of the annotation quad_points (tuple): array of 8 × n numbers specifying the coordinates of n quadrilaterals in default user space that comprise the region in which the link should be activated. The coordinates for each quadrilateral are given in the order: x1 y1 x2 y2 x3 y3 x4 y4 specifying the four vertices of the quadrilateral in counterclockwise order title (str): the text label that shall be displayed in the title bar of the annotation’s pop-up window when open and active. This entry shall identify the user who added the annotation. color (tuple): a tuple of numbers in the range 0.0 to 1.0, representing a colour used for the title bar of the annotation’s pop-up window. Defaults to yellow. modification_time (datetime): date and time when the annotation was most recently modified page (int): index of the page where this annotation is added r;Nrr�r)r�r�r�rr r@r?rA) r-rDr1r�r r�rbr+r!r�rr�) r�r6r&r?rAr@r�r��x_min�y_min�x_max�y_maxr,s rrCzFPDF.add_text_markup_annotation� s��8 �!�!�%�(�(�(��$�T�*�*�0�� � $� $� 2� � �<��9�D��K���1��%�&�&���K���1��%�&�&���K���1��%�&�&���K���1��%�&�&��#� �  �����%�-��5�=�/�#��  �  ��  �  � � � �4���&�&�z�2�2�2��rc ���t�fd�|D��d��}t|ddd���}t|ddd���}t|ddd���} t|ddd���} t d || | |z | |z ||||d�|��} �j�jj�| ��| S) u� 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. c3�V�K�|]#\}}|�jz�j|z �jzfV��$dSr*)r�rE)r r�r�r�s �rrz&FPDF.ink_annotation.<locals>.<genexpr>= s?�����Q�Q���A��T�V��d�f�q�j�D�F�%:�;�Q�Q�Q�Q�Q�QrrrNr�r�Ink)r�r�rr �ink_listr�� border_widthrA)rN)�sumrbr+r!r�r�rr�) r��coordsr&rArPr�rOrHrIrJrKr,s ` r�ink_annotationzFPDF.ink_annotation- s���� �Q�Q�Q�Q�&�Q�Q�Q�SU�V�V���H�Q�T��T�N�#�#���H�Q�T��T�N�#�#���H�Q�T��T�N�#�#���H�Q�T��T�N�#�#��#� �  ����%�-��5�=���%��  �  ��  �  � � � �4�9��$�+�+�J�7�7�7��rc� �|jstd���|�|��}d||jzd�d|j|z |jzd�d�g}|jt jkr'|�d|j�d|j d�d���|�|j � |���d���|j |j �|j j��|jr|d ks|jr}|�|d d � ��}|jr0|d kr*|�|�|||����|jr'|j}|d |zz}|�||||��g}|j|jkr?|�|j���������|r dg|z|zdgz}|�d�|����dS)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. r2r�r�r4� Td� Tr r�z ETr�TFr3g�������?�q�QN)r�rIr�r�rEr�rEr�r�r�r�� encode_textr�r�r�r�r�rr�� _do_underliner7�_add_quad_pointsr�r�r�r�r�r�)r�r�r�r&�slr@rE�attr_ls rr&z FPDF.textQ s��(�� W�� U�V�V� V��"�"�4�(�(��C�A���J�C�C�C�d�f�q�j�D�F�%:�C�C�C�C� D�� �>�X�]� *� *� �I�I�E�$�.�E�E�d�o�E�E�E�E� F� F� F� � � �T�&�2�2�4�8�8�=�=�=�>�>�>� �'�� �2�6�6�t�7H�7J�K�K�K� �N� 2�t�r�z�z�d�.K�z��%�%�d�t�e�%�L�L�A��~� 7�$�"�*�*�� � �$�,�,�Q��1�5�5�6�6�6��,� 2��N���S�1�W� ���%�%�a��A�q�1�1�1��� �?�d�o� -� -� �M�M�T�_�6�6�8�8�>�>�@�@�B� C� C� C� � -�����"�$��u�,�B� � � �#�(�(�2�,�,�����rc���tjdtt�����|�|j}|�|j}|jdkr|�d��||_|dkr�|tj dz z}tj |��}tj |��}||j z}|j |z |j z}d|d�d |d�d | d�d |d�d |d �d |d �d | d �d | d �d �}|�|��dSdS) zR .. deprecated:: 2.1.0 Use `FPDF.rotation()` instead. z�rotate() 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�NrrXrX�q �.5Fr4�.2F� cm 1 0 0 1 � cm)r�r�r�r'r�r�r�r�rrr�r�r�r�rE�r�r�r�r��cr�rtrus r�rotatez FPDF.rotate| sh�� � �>� �&�(�(� � � � � �9���A� �9���A� �;�!� � � �I�I�c�N�N�N��� � �A�:�:� �T�W�s�]� "�E������A������A��T�V��B��&�1�*���&�B�2�Q�K�2�2�Q�K�2�2�a�R�K�2�2�a�K�2�2�b�K�2�2�r�K�2�2��3�1�2�2�&(�S�1�2�2�2� � �I�I�a�L�L�L�L�L� �:rc#�K�|�|j}|�|j}|tjdz z}tj|��tj|��}}||jz|j|z |jz}}|���5|� |d�d|d�d| d�d|d�d|d�d|d�d| d�d| d�d���dV�ddd��dS#1swxYwYdS)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. NrXr`r4rarbrc) r�r�rrr�r�r�r�rEr$r�rds r�rotationz FPDF.rotation� s�����6 �9���A� �9���A� ���3�����x���������1���T�V��d�f�q�j�D�F�2�B�� � � � !� !� � � �I�I��I�2�2�1�I�2�2�A�2�I�2�2�A�I�2�2�B�I�2�2�R�I�2�2��3�1�2�2�&(�S�1�2�2�2� � � � �E�E�E�  � � � � � � � � � � � ���� � � � � � s�?=C � C �C c#�,K�d}|�|j}|�|j}ttt j|tjdz z��|��| ��}ttt j|tjdz z��|��| ��}||jz|j|z |jz}}|� ��5|� d|d�d|d�d|d�d|d�d |d�d |d�d � ��dV�ddd��dS#1swxYwYdS) a� Method to perform a skew transformation originating from a given center. It must be used as a context-manager using `with`: with skew(ax=15, ay=15, x=x, y=y): pdf.something() The skew transformation affects all elements which are printed inside the indented context (with the exception of clickable areas). Args: ax (float): angle of skew in the horizontal direction in degrees ay (float): angle of skew in the vertical direction in degrees x (float): abscissa of the center of the skew transformation y (float): ordinate of the center of the skew transformation lNrXz1 �.5fr4z 1 r�� cm 1 0 0 1 -� -rc) r�r�r+rbrrr�r�r�rEr$r�)r��ax�ayr�r��lim_valrtrus r�skewz FPDF.skew� s�����&�� �9���A� �9���A� ��T�X�b�D�G�c�M�2�3�3�W�=�=��x� H� H�� ��T�X�b�D�G�c�M�2�3�3�W�=�=��x� H� H���T�V��d�f�q�j�D�F�2�B�� � � � !� !� � � �I�I�2�R�>�2�2�b�>�2�2��>�2�2�"�>�2�2��1�2�2�&(�1�2�2�2� � � � �E�E�E�  � � � � � � � � � � � ���� � � � � � s� 3D � D �D c#�K�|\}} tj|��j}n#t$r|}YnwxYwt jt j|dz����}t jt j|dz����}||jz|j |z |jz} }|� ��5|� |d�d|d�d|d�d|dzd�d|d�d| d�d|d�d| d�d���d V�d d d ��d S#1swxYwYd S) a+ Method to perform a reflection transformation over a given mirror line. It must be used as a context-manager using `with`: with mirror(origin=(15,15), angle="SOUTH"): pdf.something() The mirror transformation affects all elements which are rendered inside the indented context (with the exception of clickable areas). Args: origin (float, Sequence(float, float)): a point on the mirror line angle: (fpdf.enums.Angle): the direction of the mirror line r�rjr4rOr�rkrlrcN) r4r1r�r�rrr�r�r�r�rEr$r�) r��originr�r�r�r�r�r�rtrus r�mirrorz FPDF.mirror� s�����"���1� ��L��'�'�-�E�E��� � � ��E�E�E� ���� �H�T�\�%�!�)�,�,� -� -�� �H�T�\�%�!�)�,�,� -� -���T�V��d�f�q�j�D�F�2�B�� � � � !� !� � � �I�I��K�2�2�1�K�2�2�1�K�2�2�1�R�4�K�2�2�b�K�2�2�r�K�2�2��1�2�2�&(�1�2�2�2� � � � �E�E�E�  � � � � � � � � � � � ���� � � � � � s�#� 2�2�7=D�D�Dc+��K�|jrtd���|���|jdi|��dV�|���|���dS)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 * 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 beggining of this context. z@cannot create a local context inside an unbreakable() code blockNr)r�rI�_push_local_stack�_start_local_context�_end_local_context�_pop_local_stack)r�r�s rr$zFPDF.local_context s�����h � � ��R��� � ��� � � �!��!�+�+�F�+�+�+� ���� ���!�!�!� �������rc  ��d| vr$|�td���| d|jz}| d=d} | ���D]�\} } | dvrtd| �d����| tjvr=| �t��} t | | | ��| dkr|�d���g| d vrt || | ���}td| �����| rY|j�| ��} |j |j � | ��|� d | �d ���n|� d ��|�|�|�,|� |p|j|p|j|p|j��|�|�|��|�|�|��|�|�|��|�|�|��|�|jd i|��dSdS)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. r7Nz0font_size & font_size_pt cannot be both provided)r r"r!rzUnsupported 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_scale�sub_lift� sub_scale�sup_lift� sup_scaler�rur�zq /z gsrWr)r�r�rBr,�MERGE_PROPERTIES�setattrr-r�register_stylerr�r�r�r�r�r�r�rr�r�r�r1)r�r�r�r�r�r�r�r�r�r�r#�keyr��gs_names rrvzFPDF._start_local_contextJ sr�� �&� � � �'� �!S�T�T�T�!�+�.���7�L��{�#� �� �,�,�.�.�# @�# @�J�C������ !�y�C�y�y�y�����m�4�4�4��:�&���B���C��'�'�'��,�&�&��-�-�e�4�4�4������"��c�5�)�)�)�)� �!>��!>�!>�?�?�?� � ��;�J�J�2�N�N�G� � 5�d�i� @� D� D�W� M� M� M� �I�I�(�G�(�(�(� )� )� )� )� �I�I�c�N�N�N� � #��%��'� �M�M��/�t�/��-�d�o��1�� 1� � � � � !� � � � � +� +� +� � !� � � � � +� +� +� � !� � � � � +� +� +� � !� � � � � +� +� +� � #� !�D� !� 1� 1�L� 1� 1� 1� 1� 1� $� #rc�0�|�d��dS)zN This method ends a "q/Q" context in the page content stream. rXN)r�r2s rrwzFPDF._end_local_context� s�� � � �#�����rc��|jS)an Whenever a page break condition is met, this method is called, and the break is issued or not depending on the returned value. The default implementation returns a value according to the mode selected by `FPDF.set_auto_page_break()`. This method is called automatically and should not be called directly by the application. )rLr2s r�accept_page_breakzFPDF.accept_page_break� s ���#�#rc �^�|jstd���t|t��st|t��rt d���t|t ��r(|dvr$t jdt�����d}tj | ��} tj | ��} tj |��}|tj krt d���|dkr�|d krtj} tj} nQ|dkrtj} tj} n2|d krtj} tj} nt d |�d ����t jd |�d| j�d| j�d�t(t�����|�|��}|jr|�|| ��n|�|| ��} |�t5| d d |tj kr tjn|||d���||| | ||| ���S)a� Prints a cell (rectangular area) with optional borders, background color and character string. The upper-left corner of the cell corresponds to the current position. The text can be aligned or centered. After the call, the current position moves to the selected `new_x`/`new_y` position. It is possible to put a link on the text. A cell has an horizontal padding, on the left & right sides, defined by the.c_margin property. If automatic page breaking is enabled and the cell goes beyond the limit, a page break is performed before outputting. Args: w (float): Cell width. Default value: None, meaning to fit text width. If 0, the cell extends up to the right margin. h (float): Cell height. Default value: None, meaning an height equal to the current font size. text (str): String to print. Default value: empty string. border: Indicates if borders must be drawn around the cell. The value can be either a number (`0`: no border ; `1`: frame) or a string containing some or all of the following characters (in any order): `L`: left ; `T`: top ; `R`: right ; `B`: bottom. Default value: 0. new_x (fpdf.enums.XPos, str): New current position in x after the call. Default: RIGHT new_y (fpdf.enums.YPos, str): New current position in y after the call. Default: TOP ln (int): **DEPRECATED since 2.5.1**: Use `new_x` and `new_y` instead. align (fpdf.enums.Align, str): Set text alignment inside the cell. Possible values are: `L` or empty string: left align (default value) ; `C`: center; `X`: center around current x position; `R`: right align fill (bool): Indicates if the cell background must be painted (`True`) or transparent (`False`). Default value: False. link (str): optional link to add on the cell, internal (identifier returned by `FPDF.add_link`) or external URL. center (bool): center the cell horizontally on the page. markdown (bool): enable minimal markdown-like markup to render part of text as bold / italics / underlined. 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 r2�jParameter 'w' and 'h' must be numbers, not strings. You can omit them by passing string content with text=�rr�HInteger values for "border" parameter other than 1 are currently ignoredr�rzGcell() only produces one text line, justified alignment is not possibler�rr��"Invalid value for parameter "ln" (z"), must be an int between 0 and 2.�=The parameter "ln" is deprecated since v2.5.2. Instead of ln=� use new_x=XPos.� , new_y=YPos.r�F�� text_width�number_of_spaces�alignr � max_width� trailing_nl)�new_x�new_yrFr�center)r�rIr�r�r�r�r�r�r'rGr1rHr3�J�RIGHT�TOP�LMARGIN�NEXT�LEFTrr�r�rur��_preload_font_styles�_render_styled_text_liner_�L)r�r@rEr&�border�lnr�rFrr�r�r�r��styled_txt_fragss r�cellz FPDF.cell� s���p�� W�� U�V�V� V� �a�� � � ��A�s�!3�!3� ��J��� � �f�c� "� "� �v�V�';�';� �M�Z�*�,�,� � � � ��F�� �E�"�"��� �E�"�"��� �U�#�#�� �E�G� � ��Y��� � �� � ��Q�w�w�� �������q���� ��� ����q���� ��� ��� �7��7�7�7���� �M�a�&(�a�a�:?�*�a�a�SX�S]�a�a�a�#�*�,�,�  � � � ��"�"�4�(�(��� � ;�D� ,� ,�T�8� <� <� <��*�*�4��:�:� � �,�,� � ��!"�!&�%�'�!1�!1�e�g�g�u���!� � � � � ������!-� � � r� text_linerEr�r�r�rFrr��paddingc ���t|t��r)|dvr%tjdt �����d}n9t|t ��r$t |���d��rd}| �tdddd��} dx} } | j dkr|j } | j dkr|j } |j } | s9t|j��D]$\} }|�| dk���}| |z } �%|j}|�|jst#d ���| | z| z}n|dkr|j|jz |jz }|r|j|j|z d z z|_n(|jt0jkr|xj|d z zc_d}|���}|D]}|j|kr|j}�|�|}|�|��}g}|j}|j| j z |z}|j|z| j z|z}|j|jz | j z|z}|j|j|zz | j!z |z}|r8|dkrd nd }|�"|d �d|d �d||z d �d||z d �d|�� ��n1|dkr+|�"|d �d|d �d||z d �d||z d �d���t|t ��r�d|vr%|�"|d �d|d �d|d �d|d �d���d|vr%|�"|d �d|d �d|d �d|d �d���d|vr%|�"|d �d|d �d|d �d|d �d���d |vr%|�"|d �d|d �d|d �d|d �d���|j#r"|�$|j|j||��|j}dg}}dx}}d} tJj&}!|j'}"|j(}#|j)}$|j*}%|j+}&d}'|j,}(|�r�|jt0j-kr || z | z })n*|jt0j.t0jfvr || z d z })n| })||)z }d}*|jt0j/kr|j0r|| z | z | z |j0z }*|�"d|j|)z|zd �d|j|jz d|zz d|zz |zd �d���t|��D�]Q\} }t|tb��r%|j2|j3�4|��|j5d|(krH|j5d}(|�"|(�6���7����d}'|*r|j*dkr|*dz|j*z }n|*}|%|j*kr%|j*}%|�"|j*d �d���|&|j+kr%|j+}&|�"|j+d �d ���|"|j8ks|#|j(ks |!|j9kr�|!|j9kr|j9}!|#|j(kr|j(}#|j8}"|�"d!|j8j:�d|j(d �d"���|j3dkr*|j;|j3�<|"j:��|j=}+|+| kr|�"|+d �d#���|+} |j)t|j?ks |j)|$kr-|j)}$|�"|j)�d$|j@d �d%���|�A|||*|j|)z|z|jd|zd|zzz|j��},|,r|�"|,��|�| dk���|*|jB�Cd��zz}-|jDr.|�"|j|)z|z|-|j8|jf��|jErE|�E|j|)z|z|jd|zzd|jzz |-|j|jE�&��|jFs|}||-z }��S|�"d'��|D]C\}.}/}0}1|�"|�G|.|jd|zzd|1zz|/|0�����D|r<|�E|j|)z|jd|zzd|jzz | |j|��|r�|dksO| dksI|!tJj&ks9|"|j'ks.|#|j(ks#|$|j)ks|'s|%|j*ks |&|j+krd(d�H|���d)�}2nd�H|��}2|�I|2��|p|j|_J|t�jLkr|xj|z c_n�|t�jMkr||_n�|t�jNkr ||z|_n�|t�jOkr|r||z| z |_ng||_n_|t�jPkr||d*z z|_nA|t�jQkr |j|_n$|t�jRkr|j|jz |_|t�jTkr|xj|z c_|t�jUkr |jV|_|t�jWkr|j|jXz |_|S)+aM Prints a cell (rectangular area) with optional borders, background color and character string. The upper-left corner of the cell corresponds to the current position. The text can be aligned, centered or justified. After the call, the current position moves to the requested new position. It is possible to put a link on the text. If automatic page breaking is enabled and the cell goes beyond the limit, a page break is performed before outputting. Args: text_line (TextLine instance): Contains the (possibly empty) tuple of fragments to render. h (float): Cell height. Default value: None, meaning an height equal to the current font size. border: Indicates if borders must be drawn around the cell. The value can be either a number (`0`: no border ; `1`: frame) or a string containing some or all of the following characters (in any order): `L`: left ; `T`: top ; `R`: right ; `B`: bottom. Default value: 0. new_x (fpdf.enums.XPos): New current position in x after the call. new_y (fpdf.enums.YPos): New current position in y after the call. fill (bool): Indicates if the cell background must be painted (`True`) or transparent (`False`). Default value: False. link (str): optional link to add on the cell, internal (identifier returned by `FPDF.add_link`) or external URL. center (bool): center the cell horizontally on the page. padding (Padding or None): optional padding to apply to the cell content. If padding for left and right is non-zero then c_margin is ignored. Returns: a boolean indicating if page break was triggered r�r�r�r�LTRBNr)� initial_cszA'text_line' must have fragments if 'text_line.text_width' is Noner�r��fr�r4rPz re Sr�r7r8�T�RgFr�g�?g333333�?rUr�Tr�z Tzz Tcz/Fz Tfz TsrVr�)r�r�r@rEr�ETr_z Qg@)Yr�r�r�r�r'r�r�� issupersetrwrRrrTr�� enumerate� fragmentsr�r�r�r@rAr�r�rBr�r3�X�get_ordered_fragmentsr7�_perform_page_break_if_need_ber�rEr�rS�bottomr�rr[r7�LINEr�r�r�r�r�r�r��Cr�r�r`r�r��add_text_substitution�graphics_stater�r�r�r{r�r�r��liftrEr�r��render_pdf_text� characters�countr�rr7rZr�r�r�rGr��START�END�WCONT�CENTERr��RMARGINrHr��TMARGINr��BMARGINrF)3r�r�rEr�r�r�rFrr�r�� l_c_margin� r_c_margin�styled_txt_widthr�r��unscaled_widthr@� max_font_sizer��page_break_triggeredr\r�rRrTrSr��op�s_start�s_width� underlines� current_ws�frag_ws� current_lift�current_char_vposr��current_font_size_pt�current_text_mode�current_font_stretching�current_char_spacing�fill_color_changed�last_used_color�dx� word_spacingr��r_text� frag_width�start_x�ul_w�ul_font� ul_font_sizer�s3 rr�zFPDF._render_styled_text_line4 s� ��X �f�c� "� "� �v�V�';�';� �M�Z�*�,�,� � � � ��F�F� ��� $� $� ��V���)?�)?��)G�)G� ��F� �?��a��A�q�)�)�G�"#�#� �Z� �<�1� � ���J� �=�A� � ���J�$�/��� 3�$�Y�%8�9�9� 3� 3���4�!%���1��6��!B�!B�� �N�2� � � � �� �9��&� � �W����!�:�-� �:�A�A� �!�V�V�����&���/�A� � ��]�d�h��l�a�%7�7�D�F�F� �_��� '� '� �F�F�a�!�e�O�F�F�� ��3�3�5�5� �� /� /�D��~� �-�-� $�� �� �9��A�#�B�B�1�E�E�� �� �F������%��*����!��g�m�+�q�0���v������,��1���&�D�F�Q�J�'�'�.�8�A�=�� � V��!� � ����B� �I�I��W�W�W�C�W�W�W�e�D�j�W�W�W�v�c�z�W�W�W�SU�W�W� X� X� X� X� �q�[�[� �I�I��T�T�T�C�T�T�T�e�D�j�T�T�T�v�c�z�T�T�T�T� U� U� U� �f�c� "� "� U��f�}�}�� � �T�O�O�O��O�O�O�D�O�O�O�v�O�O�O�O�P�P�P��f�}�}�� � �T�M�M�M��M�M�M�E�M�M�M��M�M�M�M�N�N�N��f�}�}�� � �U�Q�Q�Q��Q�Q�Q�U�Q�Q�Q��Q�Q�Q�Q�R�R�R��f�}�}�� � �T�S�S�S��S�S�S�u�S�S�S�6�S�S�S�S�T�T�T� � (� 8� � !� !�$�&�$�&�!�Q� 7� 7� 7��&������"�"� �W�� �$�M���(� �#�0�� �N��"&�"6��#�0��"���/�� �r ���%�'�)�)���^�&6�6�����U�W�e�g�$6�6�6��*�*�a�/����� �r�M�G��L���%�'�)�)�i�.H�)�� �N�Z�/�2B�B��.� /� � �I�I�R�t�v��{�a�'�.�R�R��F�T�V�O�c�A�g�-��m�0C�C�q�H�Q�R�R�R� � � �%�Y�/�/�M &�M &���4��d�$B�C�C�F��J�t�y�)�?�?��E�E�E��&�|�4��G�G�&*�&9�,�&G�O��I�I�o�7�7�9�9�?�?�A�A�B�B�B�)-�&��+�D�$8�C�$?�$?�*�S�0�4�3G�G�G�G�*�G�*�d�.B�B�B�.2�.B�+��I�I��!5�>�>�>�>�?�?�?�'�4�+<�<�<�+/�+<�(��I�I��!2�;�;�;�;�<�<�<� �D�I�-�-�+�t�/@�@�@�(�D�N�:�:�(�D�N�:�:�,0�N�)�+�t�/@�@�@�/3�/@�,�#'�9�L��I�I�K�4�9�;�K�K��1B�K�K�K�K�L�L�L��y�1�}�}��7�� �B�F�F�|�~�V�V�V��y���<�'�'��I�I��.�.�.�.�/�/�/�#'�L��N�h�m�3�3��~�):�:�:�(,��%��I�I���L�L�T�_�L�L�L�L�M�M�M��-�-��� ��F�R�K�'�)��F�c�A�g��m�(;�;�<��F� ����&��I�I�f�%�%�%�!�^�^� �A�v�,��� �4�?�#8�#8��#=�#=�=�>� ��>���%�%� �F�R�K�'�1�&� �I� �N� �����9���I�I��&�2�+��/��&�C�!�G�,��d�n�0D�E�$��.�!�Y� �����'�)�!(�J��:�%��� �I�I�d�O�O�O�8B� � �4���w� �� � ��&�&����#��'�*�c�L�.@�A��� ������� �� � ��F�R�K��F�c�A�g�&�#���*>�?�$��N�� ��� � � �c�!�!��3�&�&�$�� �5�5��4�#4�4�4�'�4�+<�<�<�$���6�6�%�7�*�d�.B�B�B�'�4�+<�<�<�)����"���)�)�)����H�H�R�L�L�� �I�I�a�L�L�L��)�4�>�� � �D�J� � � �F�F�a�K�F�F�F� �d�j� � ��D�F�F� �d�h� � ��w�&�D�F�F� �d�j� � �� !� �7�*�Z�7���� ���� �d�k� !� !��w��}�,�D�F�F� �d�l� "� "��]�D�F�F� �d�l� "� "��V�d�m�+�D�F� �D�I� � � �F�F�a�K�F�F� �D�L� � ��]�D�F� �D�L� � ��V�d�m�+�D�F�#�#rc �8�|j|j�||jz|j|z |jz||z|jz|j|z |jz||jz|j|z |z |jz||z|jz|j|z |z |jzg��dSr*)rr��extendr�rE�r�r�r�r@rEs rr[zFPDF._add_quad_pointsd s��� ��t�y�)�0�0��D�F� ���!��t�v�%��Q��$�&� ���!��t�v�%��D�F� ���!��a��4�6�)��Q��$�&� ���!��a��4�6�)� � � � � � rc�n�|js|�||��S|jdr |jdnt|��}t||���}|���}|j|jd<g}|D](\}}||jd<||�||��z }�)t |��S)zh " Break the text into bidirectional segments and preload font styles for each fragment ro)r&�base_directionrtrs)rur�r%r$�get_bidi_fragmentsr�r�) r�r&r�rt� paragraph�directional_segmentsr�� bidi_text�bidi_directions rr�z FPDF._preload_bidirectional_textr s���� � =��,�,�T�8�<�<� <�� ��-� 2�D� �k� *� *�+�D�1�1� � "�t�<O�P�P�P� �(�;�;�=�=��3<�3K���/�0�� �)=� H� H� %�I�~�6D�D� �2� 3� ��2�2�9�h�G�G� G�I�I��Y���rc��|st��S|j}|jr|dz }t|�||����}|�r |j}d|_t d�|D����r|�d���t d�|D����r|�d���t d�|D����r|�d ���t d �|D����r|�d ���|D]!}|j|j|jz|_ �"|�|���||_|S) aS When Markdown styling is enabled, we require secondary fonts to ender text in bold & italics. This function ensure that those fonts are available. It needs to perform Markdown parsing, so we return the resulting `styled_txt_frags` tuple to avoid repeating this processing later on. r0rc3�,K�|]}|jdkV��dS)r�N�r��r r�s rrz,FPDF._preload_font_styles.<locals>.<genexpr>� �)����G�G�d�4�?�c�)�G�G�G�G�G�Grr�r�c3�,K�|]}|jdkV��dS)r�Nr�r�s rrz,FPDF._preload_font_styles.<locals>.<genexpr>� r�rr�c3�,K�|]}|jdkV��dSr�r�r�s rrz,FPDF._preload_font_styles.<locals>.<genexpr>� s)����H�H�t�4�?�d�*�H�H�H�H�H�Hrr�c3�,K�|]}|jdkV��dS)r�Nr�r�s rrz,FPDF._preload_font_styles.<locals>.<genexpr>� s)����F�F�T�4�?�b�(�F�F�F�F�F�Frr�) r�r�r�� _parse_charsr�r�r�r�r�r�)r�r&r��prev_font_styler�r�r�s rr�zFPDF._preload_font_styles� s���� ��7�7�N��/�� �>� #� �s� "�O� ��!2�!2�4��!B�!B�C�C�� � ��9�D��D�I��G�G�6F�G�G�G�G�G� )�� � �C� �(�(�(��G�G�6F�G�G�G�G�G� )�� � �C� �(�(�(��H�H�7G�H�H�H�H�H� *�� � �D� �)�)�)��F�F�5E�F�F�F�F�F� (�� � �B� �'�'�'�(� K� K�� �J�t�'7�$�/�'I�J�� � � �M�M��M� 0� 0� 0��D�I��rc������tj|�����fd��jD��}|sdSt��fd�|D��d��}|r|S�jrdS|dS)z� Returns which fallback font has the requested glyph. This method can be overriden to provide more control than the `select_mode` parameter of `FPDF.set_fallback_fonts()` provides. c�V��g|]%}t����j|jv�#|��&Sr)�ordr��cmap)r �font_id�charr�s ��r� <listcomp>z*FPDF.get_fallback_font.<locals>.<listcomp>� s>��� � � ���4�y�y�D�J�w�/�4�4�4� �4�4�4rNc3�H�K�|]}�j|j�k�|V��dSr*)r�r3)r r�r3r�s ��rrz)FPDF.get_fallback_font.<locals>.<genexpr>� s7����� W� W�d���D�1A�1J�h�1V�1V�T�1V�1V�1V�1V� W� Wrr)rCr1r �nextr )r�r�r��fonts_with_char�font_with_matching_emphasisr3s`` @r�get_fallback_fontzFPDF.get_fallback_font� s������  �&�u�-�-�� � � � � ��2� � � �� � ��4�&*� W� W� W� W� W�o� W� W� W� �' �' �#� '� /�.� .� � *� ��4��q�!�!rr&r�c#� �������K�|sщjsʉjsÉjr�t|��j����D]f\}}|dkr/t �j�����j��V�|r*t|�����j��V��gdSt|�����j��V�dSgd�j vd�j vt�j ��f\����d�d��������fd�}�j r �j j}ng}d}|�r�|dd��j�j�jfv}|d} t%|d��} | t&jt&j�fvr�r�r |��V�| ��jr�|dt-�j����jkrr�r |��V�����} �rdnd�rdndz| d<�| d <t �j| �j��V�|t-�j��d�}�� |�r�|r��r �d | kr�t-|��d ks |d| kr~|dkr�d|d zdz �n��|dzdkr\�r |��V�|dd��jkr� �|dd��jkr� �|dd��jkr� �|dd�}���|d�jkr|d znd}�j�|��} | r�| ���\} }}�r |��V�����} �j| d <�jr �j| d < t;|��}��|���}n#t>$rYnwxYwttA| ��| �j|���V�����j r�|ddkr�tC|d��|vr��rdnd�rdndz}��"|d|��}|rd|�kr'��#|d��|d d�}��$�r |��V�|���#|d��|d d�}��[�r�r |��V�d���#|d��|d d�}|����r|��V�dSdS)zSplit text into fragmentsrNr�r�c�>������}�rdnd�rdndz|d<�|d<�rXd�d��D����|d<d�d��D����|d<�j�|d <d�d�t�|�j��}g�|S) Nr�r�r�r�r�c3�BK�|]}|����|V��dSr*)�islower�r res rrz2FPDF._parse_chars.<locals>.frag.<locals>.<genexpr>� sC����0�0��� � � � �0��0�0�0�0�0�0rr�c3�BK�|]}|����|V��dSr*)�isupperr s rrz2FPDF._parse_chars.<locals>.frag.<locals>.<genexpr>� sC����/�/��� � � � �/��/�/�/�/�/�/rr�)�_get_current_graphics_stater�r�r]r�) �gstate�fragment�current_fallback_font�current_text_script�in_bold� in_italics� in_underliner��txt_frags �������rr�zFPDF._parse_chars.<locals>.frag� s�����5�5�7�7�F�+2�$:�C�C��!�)���r�$�F�<� �#/�F�;� �$� +�(*���0�0�4�0�0�0�)�)��}�%�(*�w�w�/�/�4�/�/�/�(�(��|�$�*.��4I�)J��~�&�(,�%�&*�#��������H� �H��Orr�r�r�r�rOrYrr�r�)r� )$rur r�r��splitr`r r�r]r��boolr�r7r�r��MARKDOWN_BOLD_MARKER�MARKDOWN_ITALICS_MARKER�MARKDOWN_UNDERLINE_MARKERrurt�COMMON�UNKNOWNrI�MARKDOWN_ESCAPE_CHARACTER�MARKDOWN_LINK_REGEXr �groups�MARKDOWN_LINK_UNDERLINE�MARKDOWN_LINK_COLORr�rr�rr�rr�)r�r&r��seq� fragment_textr�� font_glyphs�num_escape_chars� is_marker� half_marker� text_scriptr �is_link� link_text� link_destr�r�r�rrrrrrs` @@@@@@rr�zFPDF._parse_chars� s������������� �� 1� �$�:Q� ��&� �*3��J�J�t�6�7�7�+�+� � �&�C���Q�w�w�<� �3� �<�<�>�>� �F������ %��&�)�4�+K�+K�+M�+M�t�v����������4��!A�!A�!C�!C�T�V�L�L� L� L� L� �F� � �4�?� "� �4�?� "� ��� � � 7 �3��'�:�|� !%��"�� � � � � � � � � � � �2 � � ��+�0�K�K��K����f ��R�a�R���)��,��.�%��I� �q�'�K�,�T�!�W�5�5�K���$��%�#�#��� �!� 3�!��$�&�&�L�L�L�&1�#��&� ��6�#�d�5�6�6�6�7�4�;R�R�R��%�"�d�f�f� � � �!�=�=�?�?�F�3:�,B�C�C��)�1���r�,�F�<�(�+7�F�;�'�8��/���������  ��D�$;� <� <� >� >�?�D���/ ��!�%�!�)1�"���)D�)D��T���Q���$�q�'�[�*@�*@�,�a�/�/�!�!A�&6��&:�q�%@�#A�!A�B�B�%�� (�!�+�q�0�0�#�)�"&�$�&�&�L�L�L�����8�t�'@�@�@�*1�k�G�����8�t�'C�C�C�-7��J�����8�t�'E�E�E�/;�+;�L�#�A�B�B�x�� ��A�w�$�"@�@�@�%�q�(�(��!� �2�8�8��>�>����18���1A�1A�.�I�y�$��%�"�d�f�f� � � �!�=�=�?�?�F�*.�*F�F�;�'��/�H�/3�/G��|�,��"�9�~�~��$(�M�M�t�M�$<�$<� � ��%����������"��Y������&� ������ ��� �D��G�t�O�O�C��Q��L�L�K�<W�<W� '�/���R�:�4M�C�C�2�N�� $� 6� 6�t�A�w�� F� F� � � �$�(=�=�=� ����Q��0�0�0�#�A�B�B�x�� ��%�"�d�f�f� � � �,9�)��O�O�D��G�,�,�,�����8�D��$� -��!��$�&�&�L�L�L�(,�%� �O�O�D��G� $� $� $�����8�D�M�f �N � ��$�&�&�L�L�L�L�L� � s�2%N� N%�$N%c�F�|j|z|jko|j o|jS)a8 Let you know if adding an element will trigger a page break, based on its height and the current ordinate (`y` position). Args: height (float): height of the section that would be added, e.g. a cell Returns: a boolean indicating if a page break would occur )r�r\r�r�)r�r s r�will_page_breakzFPDF.will_page_breakns2�� �F�V�O�d�5� 5� '��N�"� '��&� rc��|�|��rCt�d|j|j||j��|���dSdS)Nz;Page break on page %d at y=%d for element of height %d > %dTF)r-�LOGGER�debugr�r�r\�_perform_page_break�r�rEs rr�z#FPDF._perform_page_break_if_need_be~sb�� � � �� "� "� � �L�L�M�� �����'�  � � � � $� $� &� &� &��4��urc��|jr|jrdS|j}g}|���rc|�|�����|���|���|����c|���|� d���t|��D]#}|j di|��|����$|���||_dS)NT)r�r) r�r�r��!_is_current_graphics_state_nestedr�r rxrwrur��reversedrv)r�r��gs_stack�prev_gss rr1zFPDF._perform_page_break�s!���%� ��� � �F� �F�����4�4�6�6� &� �O�O�D�<�<�>�>� ?� ?� ?� � !� !� #� #� #� � #� #� %� %� %� �4�4�6�6� &� ��� � � � � � �4� � � � ���)�)� %� %�G� %�D� %� 0� 0�� 0� 0� 0� � "� "� $� $� $� $� ����������rc�"�|j|jkSr*)rJr�r2s rr�zFPDF._has_next_page�s����$�)�+�+rc#��K�t|jtj��sdV�dSd�|_|j|j|j|jf\}}}}t|j |jj ��}|� �� dV�|� ��t|dz|jdz��D] }|j |=� ||_||j |j_ |�||��|`dS#|� ��t|dz|jdz��D] }|j |=� ||_||j |j_ |�||��|`wxYw)Nc��dSr*r)r�r�s r�<lambda>z'FPDF._disable_writing.<locals>.<lambda>�s��D�rr)r�r��types� MethodTyper�rJr�r�rmr�rrurxr�set_xy)r�� prev_page�prev_pages_count�prev_x�prev_yr�ps r�_disable_writingzFPDF._disable_writing�s������$�)�U�%5�6�6� � �E�E�E� �F�0�0�� � �I� � � �F� �F� 7 �3� �#�V�V� �$�*�T�Y�/�6�7�7�� ��� � � � � �E�E�E� � !� !� #� #� #��+�a�/��1A�A�1E�F�F� "� "���J�q�M�M�!�D�I�+1�D�J�t�y� !� (� �K�K��� '� '� '�� � � �� � !� !� #� #� #��+�a�/��1A�A�1E�F�F� "� "���J�q�M�M�!�D�I�+1�D�J�t�y� !� (� �K�K��� '� '� '�� �M�M�M�Ms �C>�>A2E0�wrapmodec�,�tj|��}tj|��}|r(t jdt t�����|s|rb|���5|� |||||||| | | | | ||dd|r tj n|||���cddd��S#1swxYwY|j std���t|t��st|t��rt!d���t#j| ��} t%j|��}| dkr�| d krt"j} t$j}np| d krt"j} t$j}nQ| d krt"j} t$j}n2| d krt"j} t$j}nt!d | �d����t jd| �d| j�d|j�d�t t�����t3j|��}d}|�|j}|d kr|j|jz |jz }|j|j}}||jz |j z x}}g}|j s|�!|j"��|js|�!|j"��|t2j#kr|xj|j z c_|xj|j$z c_|r;|t2j#kr |jd z n|j%|j&|z d z z|_|j}|�'|��}|�(dd��}|j)r|�*|| ��n|�+|| ��}|j,|j-}}d }g}t]||||| |���}|�/��} | �+|�!| ��|�/��} | �+|stadd d |||d���g}| �tc|��d kr|}!nte|| ��}!|p|}"d}tg|��D�]�\}#} |�4||j5z��}$|$r+d}|�6��|xj|j$z c_|"r�|#d ks|$r�|j|j$z}%|j5|j7z}&tq|j9|%z |&z |!z��}'te|'tc|��|#z ��}(tu||#|!zz |(|!z��})|j|t2j#kr|d z nd z }*tw||*|j z |j|j$z |*|z|jz|j|)z|j5z||r|j<nd��|#tc|��d z k}+|�=| |!|+r| n t"j|+r|n t$jd d|td |jd |j �����||!z }|+s|t2j#kr||_���||kr%|t$jkr|xj||z z c_|}|r|t$jkr|j}|d},|,r5|,j>r.|t$j?t$jfvr|�@��|t$jkr||_n%|t$jkr|xj|j5z c_| r8|j,|kr&||_,|jA|j |j,z|_B||_-| t"jkr|xj|jz c_n%| t"jkr|xj|j zc_tj|��}d}-|tjCzr|-|fz }-|tj zr[g}.|D]P} g}/| jDD]}0|/�E|0jF���|.�!d�G|/�����Q|-|.fz }-|tjHzr|-||j$z|j5zfz }-tc|-��d kr|-d S|-S)aB This method allows printing text with line breaks. They can be automatic (breaking at the most recent space or soft-hyphen character) as soon as the text reaches the right border of the cell, or explicit (via the `\n` character). As many cells as necessary are stacked, one below the other. Text can be aligned, centered or justified. The cell block can be framed and the background painted. A cell has an horizontal padding, on the left & right sides, defined by the.c_margin property. Args: w (float): cell width. If 0, they extend up to the right margin of the page. h (float): height of a single line of text. Default value: None, meaning to use the current font size. text (str): string to print. border: Indicates if borders must be drawn around the cell. The value can be either a number (`0`: no border ; `1`: frame) or a string containing some or all of the following characters (in any order): `L`: left ; `T`: top ; `R`: right ; `B`: bottom. Default value: 0. align (fpdf.enums.Align, str): Set text alignment inside the cell. Possible values are: `J`: justify (default value); `L` or empty string: left align; `C`: center; `X`: center around current x position; `R`: right align fill (bool): Indicates if the cell background must be painted (`True`) or transparent (`False`). Default value: False. split_only (bool): **DEPRECATED since 2.7.4**: Use `dry_run=True` and `output=("LINES",)` instead. link (str): optional link to add on the cell, internal (identifier returned by `add_link`) or external URL. new_x (fpdf.enums.XPos, str): New current position in x after the call. Default: RIGHT new_y (fpdf.enums.YPos, str): New current position in y after the call. Default: NEXT ln (int): **DEPRECATED since 2.5.1**: Use `new_x` and `new_y` instead. max_line_height (float): optional maximum height of each sub-cell generated markdown (bool): enable minimal markdown-like markup to render part of text as bold / italics / underlined. 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)r@rEr&r�r�rFrr��max_line_heightr��print_shr�r�rEr�r��outputr�r�Nr2r�r�rrr�rYr�z"), must be an int between 0 and 3.r�r�r�r�� r�)r�rHrEr�T)rEr�r�r�rFrr�rOr)Irw�newrFr1r�r�r�r'rD� multi_cellr;�LINESr�rIr�r�r�rGrHr�r�r�r�r�rr3r7r@rAr�r�rTrRr�rr�rSr�rBr�r�rur�r�r�r�r^�get_liner_rIrbr�r-r�r1rFr�rEr+rpr�r�r��LASTr�r�r�� PAGE_BREAKr�r�r�r��HEIGHT)1r�r@rEr&r�r�rFr�rr�rGr�rHr�r�rEr�rIr�r�r�rArB�maximum_allowed_width�clearance_margins�normalized_string�styled_text_fragmentsr��prev_underline� total_height� text_lines�multi_line_breakr�� line_height� box_required�text_line_index�page_break_required�top_gap� bottom_gap�lines_before_break� num_lines� box_heightr�� is_last_line� last_line� return_value� output_linesr�r�s1 rrLzFPDF.multi_cell�s� ��h�+�g�&�&���?�8�,�,�� � � �M�D�#�*�,�,�  � � � � � �j� ��&�&�(�(� � �������!�����$3�%�%���%�!�$�6@�L�,�2�2�f�!�#�''��� � � � � � � � � � � � ���� � � � �,�� W�� U�V�V� V� �a�� � � ��A�s�!3�!3� ��J��� �� �E�"�"��� �E�"�"�� �� � ��Q�w�w�� ��� ����q���� ��� ����q���� ��� ����q���� ������ �7��7�7�7���� �M�a�&(�a�a�:?�*�a�a�SX�S]�a�a�a�#�*�,�,�  � � � �� �U�#�#��$�� �9���A� ��6�6�����&���/�A������� %&�� �$5�� �$D�D������|� 4� � $� $�T�]� 3� 3� 3��}� 4� � $� $�T�]� 3� 3� 3� �E�G� � � �F�F�g�l� "�F�F� ���'�+���� � �#�u�w�.�.���� � �D�M�T�X�PQ�\�UV�DV�4V� �F��V�F��"�"�4�(�(�� �L�L��r�2�2��� � H�D� ,� ,�->�� I� I� I��*�*�+<�h�G�G� � +/�/�4�>���� �� �)� !� !� ����  � � ��%�-�-�/�/� ��%� � � �i� (� (� (�(�1�1�3�3�I��%�� ��� �%&���� %���� �J� � "�c�*�o�o��&:�&:��K�K��a��1�1�K��~�v� �$��*3�J�*?�*?�* �* � &�O�Y�"&�"6�"6�q�7�>�7I�"J�"J� �"� &�'+�$��(�(�*�*�*����'�+�%���� ��A�!5�!5�9L�!5��&�7�;�.��$�^�d�m�;� �%(�$�&�7�*:�Z�*G�K�)W�%X�%X�"�� 2�C� �O�O�o�4U�V�V� � ���+�5�5�y�;�7N��� ��F�u���'7�'7�a�!�e�e�Q�?�� ���� �$��F�W�[�(���E�G�M�)��F�Z�'�'�.�8��'+�5�D�O�O�����+�c�*�o�o��.A�A�L� � )� )���+�:�e�e���+�:�e�e��������7�=�!�W�\�B�B� *� � � � �K� '�L�� �E�U�W�$4�$4����� �!� � ��� �!�!����!�l�*�*����L� � �E�T�X�$5�$5��V�F��r�N� � � ��.� �5�T�Y�� �<R�3R�3R� �G�G�I�I�I� �D�H� � ��D�F�F� �d�i� � � �F�F�g�n� $�F�F� � ,���/�1�1�"1���$(�J�t�/?�$�/�/Q�$R��!�+�D�N� �D�J� � � �F�F�g�m� #�F�F�F� �d�i� � � �F�F�g�l� "�F�F�"�)�&�1�1��� � �%�0� 0� 4� �1�3� 3�L� �%�+� +� ,��L�'� 9� 9� �� �%�/�7�7�D��%�%�d�o�6�6�6�6��#�#�B�G�G�J�$7�$7�8�8�8�8� �\�O� +�L� �%�,� ,� K� �\�G�K�7�'�.�H�J� J�L� �|� � �� !� !���?� "��s�+6B.�.B2�5B2rHc ���tj|��}|jstd���t |t ��rt d���|�|j}d}|�|��� dd��}|j r|� |d��n|� |d��}g} t|�fd�|j|jf||���} |j|jz |jz } | �| ���} |j|jz |jz } | �| �+| �| ��| ���} | �+| sdSt+| ��D]S\}} |d kr|���|�| |d t0jt4jd|� ��}|p|}�T| jr|���|S) a Prints text from the current position. When the right margin is reached, a line break occurs at the most recent space or soft-hyphen character, and text continues from the left margin. A manual break happens any time the \n character is met, Upon method exit, the current position is left just at the end of the text. Args: h (float): line height. Default value: None, meaning to use the current font size. text (str): text content link (str): optional link to add on the text, internal (identifier returned by `FPDF.add_link`) or external URL. print_sh (bool): Treat a soft-hyphen (\u00ad) as a normal printable character, instead of a line breaking opportunity. Default value: False wrapmode (fpdf.enums.WrapMode): "WORD" for word based line wrapping (default), "CHAR" for character based line wrapping. txt (str): [**DEPRECATED since v2.7.6**] text content r2zbParameter 'h' must be a number, not a string. You can omit it by passing string content with text=NFrJr�c����Sr*r)rEr�s �rr;zFPDF.write.<locals>.<lambda>As���i�r)rHrEr)rEr�r�r�rFr)rFr1r�rIr�r�r�r7r�r�rur�r�r^rr@r�rArNr�r�r�r�r�rGr�rHr�r�)r�rEr&rrHrEr�rTrUrXrY� first_widthr�� full_widthr\r�r�s @r�writez FPDF.writes*���8�?�8�,�,���� W�� U�V�V� V� �a�� � � ��H��� � �9���A�$�� �/�/��5�5�=�=�d�B�G�G��� � E�D� ,� ,�->�� F� F� F��*�*�+<�e�D�D� � � �)� !� � � � � �]�D�M� *���  � � ���f�t�v�o�� �5� �� �$�-�-�/�/� ��V�d�m�+�d�m�;� �� ��%� � � �i� (� (� (�(�1�1�3�3�I��%�� ��5�*3�J�*?�*?� D� D� &�O�Y���"�"���� � � ��4�4�����j��h���5���H�$8�#C�8� � � � � � �G�G�I�I�I�#�#r� r��img�img_fill_width�ncols�gutter�balance� text_alignrZr�rA�skip_leading_spacesc�<�t|||||||||| | | | | ���S)a�Establish a layout with multiple columns to fill with text. Args: text (str, optional): A first piece of text to insert. ncols (int, optional): the number of columns to create. (Default: 1). gutter (float, optional): The distance between the columns. (Default: 10). balance: (bool, optional): Specify whether multiple columns should end at approximately the same height, if they don't fill the page. (Default: False) text_align (Align or str, optional): The alignment of the text within the region. (Default: "LEFT") line_height (float, optional): A multiplier relative to the font size changing the vertical space occupied by a line of text. (Default: 1.0). l_margin (float, optional): Override the current left page margin. r_margin (float, optional): Override the current right page margin. print_sh (bool, optional): Treat a soft-hyphen (\u00ad) as a printable character, instead of a line breaking opportunity. (Default: False) wrapmode (fpdf.enums.WrapMode, optional): "WORD" for word based line wrapping, "CHAR" for character based line wrapping. (Default: "WORD") skip_leading_spaces (bool, optional): On each line, any space characters at the beginning will be skipped if True. (Default: False) ) r&rmrnrorprqrrrZr�rArHrErs)rr)r�r&rmrnrorprqrrrZr�rArHrErss r� text_columnszFPDF.text_columnsesF��J� ���)����!�#����� 3� � � � rc �2�|r(tjdtt�����t |j|| ��\}} } t | t��r|�|| | ||||||| | � � S|� || | ||||||| | | � � S)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�rW� _vector_image� _raster_image)r�rr�r�r@rEr6rr�r�dims�keep_aspect_ratiorm�infos rr�z FPDF.image�s���B � � �M�6�#�*�,�,�  � � � �(��(8�$��E�E���c�4� �d�O� ,� ,� ��%�%��c�4��A�q�!�T�5�(�DU��� ��!�!� � � � � � � � � � � � �  �  � rr{c ��d|vr|�d��|�|||j���\}}|�,|�|��|j}|xj|z c_|�|j}t |t��s|�||||| ��}| r|� ||||��\}}}}|j r.|ddkr"| s |� ||||||j���}t|||||| |j|j ���} | s| rE|�| | ���5|�| ��ddd��n #1swxYwYn|�| ��|r|�|||||��|j|j�|d��t)d i|�||d ���S) N�smaskr�)�scale�usagesr)r~�pdf_height_to_flip�r�rr���rendered_width�rendered_heightr)r-�size_in_document_unitsr�r�r�r�r�r � x_by_align�scale_inside_boxr��_downscale_imagerfrE�_marked_sequencer�rr�r�r�rV)r�rrmr{r�r�r@rErr�rryrz�stream_contents rrxzFPDF._raster_image�sN�� �d�?�?� � %� %�e� ,� ,� ,��*�*�1�a�t�v�*�>�>���1� �9� � /� /�� 2� 2� 2���A� �F�F�a�K�F�F� �9���A��!�V�$�$� B�����1�a��/@�A�A�A� � ;��.�.�q�!�Q��:�:�J�A�q�!�Q� � � N�T�(�^�q�%8�%8��%8��(�(��s�D�!�Q�d�f�(�M�M�D�8� �!�Q��1�/�t�v�RV�RX� � � �� � &�H� &��&�&�U�X�&�F�F� *� *�� � �.�)�)�)� *� *� *� *� *� *� *� *� *� *� *���� *� *� *� *�� �I�I�n� %� %� %� � (� �I�I�a��A�q�$� '� '� '� �(���3�7�7��S� �B�B�B��K�K��K�a��K�K�K�K�Ks�/E�E�Ec�8�|r|�dd||��\}}}}tj|��}|tjkr |j|z dz S|tjkr|j|z |jz S|tjkr|jStd|�����)Nrr�z*Unsupported 'x' value passed to .image(): ) r�r3r1r�r@r�rAr�r�r�)r�r�r@rE�img_inforz�_s rr�zFPDF.x_by_align-s��� � ?�!�2�2�1�a��A�>�>�J�A�q�!�Q� �L��O�O�� ���<�<��F�Q�J�!�#� #� ���<�<��6�A�:�� �-� -� ���<�<��=� ��I�a�I�I�J�J�Jr�svgc �(�|jsE|jr>|jr7tjdt �����dd|j|jf|_|dkr�|dkr�|jrn|jrgt |jt��r|j|jzdz n|j}t |jt��r|j|j zdz n|j}n�|jr |j\} } }}n�t |t��rdn|} t| �d����|dks|dkrW|jr|jr|j|j}}n#|jr |j\} } }}ntd���|dkr ||z|z }n||z|z }|�,|� |��|j }|xj |z c_ |�|j}| r|�||||��\}}}}t |t ��s|�||||| ��}|�d||d � ��\} } }|jt)j||��z|_|j|j }} |�dd��| s| rE|�| | � ��5|�|��ddd��n #1swxYwYn|�|��|�||��n#|�||��wxYw|r|�|||||��t5||� ��S) NzI<svg> has no "viewBox", using its "width" & "height" as default "viewBox"r�rr�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()rT)r~rr �ignore_svg_top_attrsr�r�)�viewboxrr r�r�r'r�rjrBrGr!r�r�r�r�r�r r��transform_to_rect_viewport� transformr/� translationr>r�r-rrW)r�rr�r{r�r�r@rErr�rrzr��svg_id� svg_width� svg_heightr*�old_x�old_ys rrwzFPDF._vector_image9s����{� 6�s�y� 6�S�Z� 6� �M�[�*�,�,� � � � ��Q�� �3�:�5�C�K� ��6�6�a�1�f�f��y� �S�Z� �"�#�)�W�5�5�#�C�I���(�3�.�.����"�#�*�g�6�6�$�C�J���)�C�/�/����� �� � �[� ��1�a���$.�t�U�$;�$;�E����� ��s�s�s�����!�V�V�q�A�v�v��y� �S�Z� �(+� �3�:�:� � ��� �.1�k�+��1�i��� �o�����A�v�v�� �M�J�.���� �N�Y�.�� �9� � /� /�� 2� 2� 2���A� �F�F�a�K�F�F� �9���A� � ;��.�.�q�!�Q��:�:�J�A�q�!�Q��!�V�$�$� B�����1�a��/@�A�A�A��3�3��1�Q�T�4� � � ��1�d���)�*?��1�*E�*E�E����v�t�v�u�� &� �K�K��1� � � �� %�� %��*�*���*�J�J�)�)��N�N�4�(�(�(�)�)�)�)�)�)�)�)�)�)�)����)�)�)�)�����t�$�$�$� �K�K��u� %� %� %� %��D�K�K��u� %� %� %� %���� � (� �I�I�a��A�q�$� '� '� '��a��C�C�C�Cs0�1K �3J� K �J�K �J�K � K%c ��|jj}||z||z} }d|��} |�| ��} |d||jzk�rn|d| |jzk�rYt |d|z |d| z ��|jz } |j����d��r.t� d||d|d|| | ���n�|j���dk�r�t||jz��t| |jz��f} |dxxdzcc<|dd krA|j � ��D]'}|d |vr|� |d ���(| r�| }|d|dz| d | dzkra|�t||pt!|��|jj| ����t�d | |d | ��|dxxdz cc<n�t't||pt!|��|jj| ����}t)|��dz|d <d|d<||| <t�d | | |d ��n3t+d |j�����| r| �|��||=| }|S)Nzlowres-r@rEr�z�OVERSIZED: 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� downscalerrrr�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�rbr�r�� startswithr/�warning�roundr��values�removerrYrZr�r0rVrIr�)r�rrmr{r@rEr~r�� width_in_pt� height_in_pt� lowres_name� lowres_info�factorry� images_useds rr�zFPDF._downscale_image�sJ���!�(��$%��I�q�5�y�\� �&��&�&� ��j�j��-�-� � ��I� �d�&A�A� A� A��S� �L�4�+F�F�F�F��D��I� �+�T�#�Y��-E�F�F��-�.� ��$�*�*�,�,�7�7��?�?�? ����q����I���I�� �� � � � ��&�,�,�.�.�+�=�=��+��(C�C�D�D��,��)D�D�E�E����X����!�#������>�Q�&�&�'+�'G�'N�'N�'P�'P�:�:� ���9� �3�3�'�.�.�t�C�y�9�9�9���$�&�D��C�y�4��9�,�t�A�w��a��/@�@�@�� � �(� $� #� 7�z�$�'7�'7� $� 0� =� $� ������ � �\�'� ��I� � ��� ��N�N�N�a�'�N�N�N�N�*�$� ��3�:�d�#3�#3� �,�9� � ����D�!$�F� � �a��D��I�%&�D��N�*.�F�;�'��L�L�[�#���S� � ����!�]�d�F[�]�]����� � � � �t� $� $� $��t� ��D�� rc�~�tjdtt�����t |j||��S)z� Read an image and load it into memory. .. deprecated:: 2.7.7 Use `fpdf.image_parsing.preload_image` instead. z�FPDF.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�rrys rr[zFPDF.preload_image�sH�� � �B� �&�(�(� � � � ��T�-�t�T�:�:�:rc+�K�|j�|j��}|jdd|d�|��}|j}|�d|�d���|V�|j|krt d���|�d��dS) �� Can receive as named arguments any of the entries described in section 14.7.2 'Structure Hierarchy' of the PDF spec: iD, a, c, r, lang, e, actualText z/Figure)r�mcidz /P <</MCID z>> BDCz,A page jump occured inside a marked sequence�EMCNr)r��next_mcid_for_pager�rr�rI)r�r�r�� struct_elemr�s rr�zFPDF._marked_sequence�s����� �"�5�5�d�i�@�@��.�d�.� �!�� � �06� � � ��Y� � � � �,��,�,�,�-�-�-����� �9� � "� "�� N�O�O� O� � � �%�����rc ��|jjdd|ji|��\}}||j|j_|�d��|S)r�rr�r)r��add_marked_contentr�r��struct_parentsr-)r�r�r��spids rrzFPDF._add_marked_contentse�� C�D�/�B� � �� � �%+� � �� �T�04�� �4�9��,� �!�!�%�(�(�(��rc��|j|_|r|xj|z c_dS|jr|xj|jz c_dS|xj|jz c_dS)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�r7r2s rr�zFPDF.lns^������ � %� �F�F�a�K�F�F�F�F� �[� %� �F�F�d�k� !�F�F�F�F� �F�F�d�n� $�F�F�F�Frc��|jS)z-Returns the abscissa of the current position.)r�r2s r�get_xz FPDF.get_x)s ���v� rc�4�|dkr|n |j|z|_dS)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 rN)r@r�)r�r�s r�set_xz FPDF.set_x-s!���1�f�f���$�&�1�*����rc�<�|jrtd���|jS)z-Returns the ordinate of the current position.z?Using get_y() inside an unbreakable() code block is error-prone)r�rIr�r2s r�get_yz FPDF.get_y7s+�� � � ��Q��� ��v� rc�L�|j|_|dkr|n |j|z|_dS)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 rN)r�r�rEr�)r�r�s r�set_yz FPDF.set_y?s*�������1�f�f���$�&�1�*����rc�Z�|�|��|�|��dS)a, Defines the abscissa and ordinate of the current position. If the values provided are negative, they are relative respectively to the right and bottom of the page. Args: x (float): the new current abscissa y (float): the new current ordinate N)r�r�)r�r�r�s rr>z FPDF.set_xyJs&�� � � �1� � � � � � �1� � � � � rc��|jsw|jrp |�|j���d��S#t$r5}t |j||j|j|jz���|�d}~wwxYw|S)z7Check that text input is in the correct format/encodingr�)� text_index� character� font_nameN) r7r��encode�decode�UnicodeEncodeErrorrK�startr�r�)r�r&�errors rr�zFPDF.normalize_textVs����� �D�$<� � ��{�{�4�#;�<�<�C�C�I�N�N�N��%� � � �2�$�{�"�5�;�/�"�.���@����� ����� ���� � s�,=� A<�0A7�7A<�sha256c ��tstd���t|d��5} tj| ���|��\} } } ddd��n #1swxYwY|�| | | ||||||�� � dS)aE Args: pkcs_filepath (str): file path to a .pfx or .p12 PKCS12, in the binary format described by RFC 7292 password (bytes-like): the password to use to decrypt the data. `None` if the PKCS12 is not encrypted. hashalgo (str): hashing algorithm used, passed to `hashlib.new` contact_info (str): optional information provided by the signer to enable a recipient to contact the signer to verify the signature location (str): optional CPU host name or physical location of the signing signing_time (datetime): optional time of signing reason (str): optional signing reason flags (Tuple[fpdf.enums.AnnotationFlag], Tuple[str]): optional list of flags defining annotation properties �Pendesive.signer not available - PDF cannot be signed - Try: pip install endesiverN) r��cert� extra_certs�hashalgo� contact_info�location� signing_time�reasonr*)r�EnvironmentErrorrr�load_key_and_certificatesr�sign) r�� pkcs_filepath�passwordr�r�r�r�r�r*� pkcs_filer�r�r�s r� sign_pkcs12zFPDF.sign_pkcs12es���2� �"�b��� ��-�� &� &� �)�%+�%E���� � �(�&�&� "�C��{� � � � � � � � � � � ���� � � � � � � ���#��%��%��� � � � � � s�,A�A#�&A#rc �|�tstd���|jrtd���||_||_||_||_|p|j|_tdddddd| dt||t|j��|����� � } |j |j j�| ��d S) a Args: key: certificate private key cert (cryptography.x509.Certificate): certificate extra_certs (list[cryptography.x509.Certificate]): list of additional PKCS12 certificates hashalgo (str): hashing algorithm used, passed to `hashlib.new` contact_info (str): optional information provided by the signer to enable a recipient to contact the signer to verify the signature location (str): optional CPU host name or physical location of the signing signing_time (datetime): optional time of signing reason (str): optional signing reason flags (Tuple[fpdf.enums.AnnotationFlag], Tuple[str]): optional list of flags defining annotation properties r�z).sign* methods should be called only once�Widget�Sigr� signature)r�r�r@r�)� field_typer�r�rr r*r�r�N)rr�r�rI� _sign_cert�_sign_extra_certs�_sign_hashalgor � _sign_timer"rhrnr�r�rr�) r�r�r�r�r�r�r�r�r�r*r,s rr�z FPDF.sign�s���4� �"�b��� � �>� M�� K�L�L� L�������!,���&���&�<�$�*<���"� ���������)�!��$�/�*�*�� ��� � � � � � �4�9��$�+�+�J�7�7�7�7�7rc�,�|j}|j|j}}|j|jc|_|_d|_|�|j|j|j��|� ||j ��d|_|j|j zdz }|j|krA|j s:|j|krdnd}d|�d�}|d|j�d |j �d �z }t|���|jr"d|_|���d|_||c|_|_dS) NTFr�many�fewzKThe rendering function passed to FPDF.insert_toc_placeholder triggered too z page breaks: zToC ended on page z' while it was expected to span exactly z pages)r�r�r�r�r�r�r�r�r�r�r�r�r�rIr�r�r�)r��tocpr?rB�expected_final_page�too� error_msgs r�_insert_table_of_contentszFPDF._insert_table_of_contents�s/���#�� �I�t�v�6� � �O�T�V��� �4�6� $��� ���d�3�T�Z���L�L�L� ���T�4�=�1�1�1� %���"�o�� �:�Q�>�� �9�+� +� +�D�4R� +� �I�(;�;�;�&�&��C�y�fi�y�y�y�I� �r�d�i�r�r�`d�`j�r�r�r� r�I�� �*�*� *� � #� #�!�D�N� �K�K�M�M�M�"�D�N�%�v��� �4�6�6�6rc��dS)aA This method can be overridden in inherited classes in order to define a custom file identifier. Its output must have the format "<hex_string1><hex_string2>". If this method returns a falsy value (None, empty string), no /ID will be inserted in the generated PDF document. rOrr2s r�file_idz FPDF.file_id�s ���rrc�D�tjdd���}|�|��|jr@|�|j�d���d����|������}d|�d|�d�S) N�md5F)�usedforsecurityz %Y%m%d%H%M%S�utf8�<z><�>)�hashlibrKrr �strftimer�� hexdigestr�)r�r�id_hash�hash_hexs r�_default_file_idzFPDF._default_file_id�s����+�e�U�;�;�;�����v���� � � W� �N�N�4�-�6�6�~�F�F�M�M�f�U�U� V� V� V��$�$�&�&�,�,�.�.��*�8�*�*�x�*�*�*�*rc���|�|j}|j}|j}||jzd�d|j|z |dz |jzz|jzd�d||jzd�d| dz |jzd�d�S)zGDraw an horizontal line starting from (x, y) with a length equal to 'w'Nr�r4i�z re f)r��up�utr�rEr7r�)r�r�r�r@r�r�r�s rrZzFPDF._do_underline�s��� � ��,�L� �_�� �_���4�6�z� � J� J���� �R�$�Y���7�7�4�6�A� H� J� J��4�6�z� I� J� J�!#��d� �T�->� >� I� J� J� J� rc�@�|jrtd���t|t��s9t|t��st |��}|�d��}|jstd���|j|jxj|dzz c_dS)NzGContent cannot be added on a finalized document, after calling output()�latin1r�� ) rrIr�r!r�r�r�r�r�)r�r�s rr�z FPDF._outs��� �;� ��Y��� ��!�U�#�#� #��a��%�%� ���F�F������"�"�A��y� S�� Q�R�R� R� � �4�9��&�&�!�e�)�3�&�&�&�&rc �^�|dz }|}dddddddd d d d d d� }|} t| ��dzdkrd| ��} d| ����d�} tdt| ��d��D]�} | | } | | dz} | |vrtd| �d����| |vrtd| �d����d�d�t || || ��D����} t | ��D]6\}}|dkr|n|}|dzdkr|�||||d��||z }�7��dS)z/Barcode I2of5 (numeric), adds a 0 if odd lengthrY�nnwwn�wnnnw�nwnnw�wwnnn�nnwnw�wnwnn�nwwnn�nnnww�wnnwn�nwnwn�nn�wn) �0�1�2�3�4�5�6�7�8�9�A�Zr�rr �AA�ZArzChar "z" invalid for I25:z" invalid for I25: r�c3�(K�|] \}}|�|��V��dSr*r)r �cb�css rrz'FPDF.interleaved2of5.<locals>.<genexpr>@s?������ &��B�2� �r� � ������rr�r�N)rIr�r� RuntimeErrorr��zipr�r�)r�r&r�r�r@rE�narrow�wide�bar_char�coder��char_bar� char_spacer"� bar_indexr�r�s r�interleaved2of5zFPDF.interleaved2of5s����Q�����������������  �  �� �� �t�9�9�q�=�A� � ��t�:�:�D�%�D�J�J�L�L�$�$�$���q�#�d�)�)�Q�'�'� � �A��A�w�H��a�!�e��J��x�'�'�"�#H�H�#H�#H�#H�I�I�I���)�)�"�#K�J�#K�#K�#K�L�L�L��'�'���*-�h�x�.@�(�:�BV�*W�*W������C�$-�S�>�>� � �� �4�'+�s�{�{�V�V�� ��q�=�A�%�%��I�I�a��J��3�7�7�7��Z���� � � r��?rUc ��||dz d�}|�d��r|�d��s"tjdt �����idd�dd �d d �d d �dd�dd�dd�dd�dd�dd�dd�dd�dd�d d!�d"d#�d$d%�d&d'�id(d)�d*d+�d,d-�d.d/�d0d1�d2d3�d4d5�d6d7�d8d9�d:d;�d<d=�d>d?�d@dA�dBdC�dDdE�dFdG�dHdI��dJdKdLdMdNdOdPdQdRdSdT� �}|���D]r}||vrt dU|�dV����t||��D]8\} } | dWzdXkr|�|||| |d$��||| z }�9||dYz }�sdZS)[z Barcode 3of9rY)r@r��*zpCode 39 input must start and end with a '*' character to be valid. This method does not insert it automatically.r�r � nnnwwnwnnr � wnnwnnnnwr � nnwwnnnnwr � wnwwnnnnnr � nnnwwnnnwr� wnnwwnnnnr� nnwwwnnnnr� nnnwnnwnwr� wnnwnnwnnr� nnwwnnwnnr� wnnnnwnnwr�� nnwnnwnnwr�� wnwnnwnnnrC� nnnnwwnnw�E� wnnnwwnnnr�� nnwnwwnnn�G� nnnnnwwnw�H� wnnnnwwnnr�� nnwnnwwnnr�� nnnnwwwnn�K� wnnnnnnwwr�� nnwnnnnww�M� wnwnnnnwn�N� nnnnwnnww�O� wnnnwnnwn�P� nnwnwnnwnrX� nnnnnnwwwr�� wnnnnnwwn�S� nnwnnnwwnr�� nnnnwnwwnr0� wwnnnnnnw�V� nwwnnnnnw�W� wwwnnnnnnr�� nwnnwnnnw� wwnnwnnnn� nwwnwnnnn� nwnnnnwnw� wwnnnnwnn� nwwnnnwnn� nwnnwnwnn� nwnwnwnnn� nwnwnnnwn� nwnnnwnwn� nnnwnwnwn) �Yr�-r�r4r&�$�/�+�%zInvalid char "z " for Code39r�rr�N) r��endswithr�r�r'r�rr�r�) r�r&r�r�r@rE�dim�charsrer��ds r�code39z FPDF.code39Ns����A��E�"�"�����s�#�#� �4�=�=��+=�+=� � �M�E�+�,�,�  � � � �- � ��- � ��- � ��- � �� - � �� - � �� - � ��- � ��- � ��- � ��- � ��- � ��- � ��- � ��- � ��- � ��!- �" ��#- �- �$ ��%- �& ��'- �( ��)- �* ��+- �, ��-- �. ��/- �0 ��1- �2 ��3- �4 ��5- �6 ��7- �8 ��9- �: ��;- �< ��=- �> ��?- �@ ��A- �B ��C- �D ��E- �- �F����������Y- �- �- ��`����� � �A���~�~�"�#C�A�#C�#C�#C�D�D�D�!�%��(�+�+� � ���1��q�5�A�:�:��I�I�a��C��F�A�s�3�3�3��S��V� ��� ��S��M�A�A� � rc #��K�|�d||jzd�d|j|z |z |jzd�d||jzd�d||jzd�d� ��dV�|�d��dS)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�r4z re W nNrXr9r�s r� rect_clipzFPDF.rect_clip�s����� � � �+�Q���Z�W�+�+�t�v��z�A�~���&?�W�+�+�a�$�&�j�W�+�+��t�v�:�*�+�+�+� � � � ���� � � �#�����rc#�K�|�d��|�||||d��dV�|�d��dS)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 rWzW nNrX)r�rnr�s r� elliptic_clipzFPDF.elliptic_clip�sO���� � � �#���� ���1�a��A�u�-�-�-� ���� � � �#�����rc#�tK�|�||||��5dV�ddd��dS#1swxYwYdS)aF Context manager that defines a circular crop zone, useful to render only part of an image. Args: x (float): abscissa of the clipping region top left corner y (float): ordinate of the clipping region top left corner r (float): radius of the clipping region N)rl)r�r�r�r�s r� round_clipzFPDF.round_clip�s������ � ��1�a�� +� +� � � �E�E�E� � � � � � � � � � � � ���� � � � � � s �-�1�1c#�K�|j|j}}t|d���}d|_d|_t �d��|V�|j|z |j|z |jzz}||z|jks |j|krbt �d��|� ��|j � ��|� ��d|_d|_t �d��dS)aL Ensures that all rendering performed in this context appear on a single page by performing page break beforehand if need be. Notes ----- Using this method means to duplicate the FPDF `bytearray` buffer: when generating large PDFs, doubling memory usage may be troublesome. F�r�TzStarting unbreakable blockz.Performing page jump due to unbreakable heightzEnding unbreakable blockN) r�r�rgr�r�r/r0rGr\�rewind�pdfr1�replay�r�r?rB�recorder�y_scrolls r� unbreakablezFPDF.unbreakable�s����!�I�t�v�6� ����>�>�>��(-��%�#���� � �1�2�2�2������:��&�(�-�)�*C�t�x�)O�O�� �H� �t�6� 6� 6�(�-�)�:S�:S� �L�L�I� J� J� J� �O�O� � � � �L� ,� ,� .� .� .� �O�O� � � �,0�H� )�$���� � �/�0�0�0�0�0rc#�K�|j|j}}t|d���}d|_|V�|j|z |j|z |jzz}||z|jks |j|krd|_|���dS)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". FrpTN)r�r�rgr�rGr\rqrts r�offset_renderingzFPDF.offset_rendering�s�����!�I�t�v�6� ����>�>�>��(-��%������:��&�(�-�)�*C�t�x�)O�O�� �H� �t�6� 6� 6�(�-�)�:S�:S�,0�H� )��������r�render_toc_functionr��allow_extra_pagesc�P�t|��stdt|�������|jrt d|jj�����t ||j|j|j |��|_||_ t|��D]}|� ���dS)a� Configure Table Of Contents rendering at the end of the document generation, and reserve some vertical space right now in order to insert it. Args: render_toc_function (function): a function that will be invoked to render the ToC. This function will receive 2 parameters: `pdf`, an instance of FPDF, and `outline`, a list of `fpdf.outline.OutlineSection`. pages (int): the number of pages that the Table of Contents will span, including the current one that will. As many page breaks as the value of this argument will occur immediately after calling this method. 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. z,The first argument must be a callable, got: zIA placeholder for the table of contents has already been defined on page N) �callabler�r6r�rIr�r�r�r�r�r�rr1)r�rzr�r{r�s r�insert_toc_placeholderzFPDF.insert_toc_placeholder�s���.�+�,�,� ��Z�t�DW�?X�?X�Z�Z��� � � � ��>� �0�;�>�>��� � .� ���D�F�D�4H�%� � ���*;��&��u��� '� '�A� � $� $� &� &� &� &� '� 'rc��|||||||fD]8}|r4t|t��stdt|��������9|||||||d�|_dS)a� 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: )rrr�rYr�rU�N)r�rOr�r6r�) r��level0�level1�level2�level3�level4�level5�level6�levels r�set_section_title_styleszFPDF.set_section_title_styles s���.�f�f�f�f�f�f�M� � �E�� �Z��y�9�9� ��T�t�E�{�{�T�T������������% �% ��!�!�!rc��|dkrtd���|rF|jr?||jdjdzkr&td|�d|jdj�d����t|j|j|j|jzz ���}d }|j�r�|j|}|j �|j }|j |_ tj }t|jttf��rtj|j��}|�|j|j|t(jt,jd t0j|t5|jpdt|jt8t:f��r|jnd|jpd� ��� � � } |j �||_ | r|���|� |� ��5} | }|�!|��5|�|j|j||t(jt,j|jtj"k���d d d ��n #1swxYwYd d d ��n #1swxYwY|j�#tI|||j||����d S)a, Start a section in the document outline. If section_title_styles have been configured, render the section name visually as a title. Args: name (str): section name level (int): section level in the document outline. 0 means top-level. rz)"level" mut be equal or greater than zerorOrz+Incoherent hierarchy: cannot start a level z section after a level z one)rSNT)rSrRr�) r@rEr&r�r�r�rIr�r�r�)r@rEr&r�r�r�r�)%r�r�r�rlr�rcr�r�r��size_ptr�r3r�r�r�r�r1rLrBr7rGr�rHr�r;rPrwr�r�r/rFr�r��use_text_styler�r�ra) r�rr��strictr�outline_struct_elem� text_style�prev_font_size_ptr�r�r�s r� start_sectionzFPDF.start_sectionFs�� �1�9�9��H�I�I� I� � �d�m� ��� �b�0A�0G�!�0K�(K�(K��y�e�y�y�\`�\i�jl�\m�\s�y�y�y��� ��d�i�T�Y���$�&��-H�I�I�I��"�� � $�- ��2�5�9�J��!�-�$(�$5�!�$.�$6��!��G�E��*�-��s�|�<�<� :�� �Z�%8�9�9��#'�?�?��(��.���l��i��(�3���"�+�0�q�&�j�&9�C��<�H�H�� �+�+��%�.�3�!����$3�$�$� �&�!�-�$5��!�#� �� � �����&�&�T�&�2�2� �k�&1�#��(�(��4�4� � ��O�O��(��.�!�#�"�l�"�i�)�2�e�g�=�$���� � � � � � � � � � � ���� � � � � � � � � � � � � � � ���� � � � � � ��� �4��� �4�9L� M� M� � � � � s7�I�AH8�, I�8H< �<I�?H< �I�I�Ir�c#��K�d}|r�|jr|�|j��|jrat|jtt f��r |j}|j|_|j|_n t�d|j��|� |��5dV�ddd��n #1swxYwY|r!|j r|�|j ��|�||_|j|_dSdS)Nz@Unsupported '%s' value provided as l_margin to .use_text_style()) r�r�r�r�r/r�r�r/r0� use_font_facerF)r�r�� prev_l_margins rr�zFPDF.use_text_style�sO����� � � ��"� -���� �+�,�,�,��"� ��j�1�E�3�<�@�@��$(�M�M�$.�$7�D�M�!�]�D�F�F��L�L�Z�"�+����� � � � +� +� � � �E�E�E� � � � � � � � � � � ���� � � � � � )�*�-� )� �G�G�J�'� (� (� (� � $�)�D�M��]�D�F�F�F� %� $s�%B6�6B:�=B:� font_facec#��K�|sdV�dS|j|j|jf}|�|jp|j|j� |jjn|j|jp|j��|j}|j �*|j |jkr|� |j ��|j }|j �|� |j ��dV�|j �|� |��||_|j|�dS)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(). N) r�r�r�r�r�r3r�r�r�rAr�r�r�)r�r�� prev_font�prev_text_color�prev_fill_colors rr�zFPDF.use_font_face�s ����� � �E�E�E� �F��%�t���8I�J� � � � � � � 0�� 0��%�1��"�(�(��_� � � 2��!2� � � ��/�� �?� &�9�?�d�o�+M�+M� � � � �� 0� 0� 0��/�� � � +� � � � � 4� 5� 5� 5� ���� � � +� � � �� 0� 0� 0�)����� �y�!�!�!�!rc/�ZK�t|g|�Ri|��}|V�|���dS)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.AlignV): optional, default to CENTER. Control vertical alignment of cells content. width (number): optional. Sets the table width. wrapmode (fpdf.enums.WrapMode): "WORD" for word based line wrapping (default), "CHAR" for character based line wrapping. padding (number, tuple, Padding): optional. Sets the cell padding. Can be a single number or a sequence of numbers, default:0 If padding for left or right ends up being non-zero then the respective c_margin is ignored. outer_border_width (number): optional. The outer_border_width will trigger rendering of the outer border of the table with the given width regardless of any other defined border styles. num_heading_rows (number): optional. Sets the number of heading rows, default value is 1. If this value is not 1, first_row_as_headings needs to be True if num_heading_rows>1 and False if num_heading_rows=0. For backwards compatibility, first_row_as_headings is used in case num_heading_rows is 1. repeat_headings (fpdf.enums.TableHeadingsDisplay): optional, indicates whether to print table headings on every page, default to 1. N)ror)r�r�r��tables rr�z FPDF.table�s@����R�d�,�T�,�,�,�V�,�,��� � � � � � �����rc �:�|r(tjdtt�����t j��|j�s@|jdkr|���d|_ |� ��d|_ |j r|� ��|j r�|j���D]�}|���D]}|j�|����d��|�t-|j�����d����|_����|rt0}||��}|���|_|r�t5|t6j��r|�|j��nWt5|t,��r(t=|���|j��n|�|j��dS|jS)ao Output PDF to some destination. The method first calls [close](close.md) if necessary to terminate the document. After calling this method, content cannot be added to the document anymore. By default the bytearray buffer is returned. If a `name` is given, the PDF is written to a new file. Args: name (str): optional File object or file path where to save the PDF under dest (str): [**DEPRECATED since 2.3.0**] unused, will be removed in a later version output_producer_class (class): use a custom class for PDF file generation zL"dest" parameter is deprecated since v2.2.0, unused and will soon be removedr�rTFr�N) r�r�r�r'ru� cache_clearrr�r�r�r�r�r�r�r�r��get_text_substitutionsr�r��get_placeholder_stringr��render_text_substitutionr�rJr\� bufferizer��os�PathLike� write_bytesr rk)r�rr� linearize�output_producer_classr��substitution_item�output_producers rrIz FPDF.output�s�� � � �M�6�#�*�,�,�  � � � � �&�(�(�(��{� 6��y�A�~�~�� � ����!�D�N� �K�K�M�M�M�"�D�N��#� 1��.�.�0�0�0��&� � �J�-�-�/�/� � �D�-1�-H�-H�-J�-J���)�(,� �(=�(=�-�D�D�F�F�M�M� )���.�F�F� #�D�$4� 5� 5���$�f�Y�/�/� )�)�� � ��� A�(@�%�3�3�D�9�9�O�)�3�3�5�5�D�K� � ��$�� �,�,� (�� � ���-�-�-�-��D�#�&�&� (��T� � �&�&�t�{�3�3�3�3�� � �4�;�'�'�'��4��{�r)r�r�r�r�)rO)r)r�)TNNNNr*)r�)NNN)r�r�FrNNNN)T)rOrO)FF)rrr)FFN)FN)rr)NFr)rN)NrFFFN)NrFN)Nr�Nr�)Nr�r)rrrOr)NNNN)rrN)r<r=N)r=NN)r�r=r)r�r)rrNN)NNNNNNNN) NNrrr�r�NNNF) NNrrr�NNNF)NNrrr�NNF)rrl)r$rU)rF)NNNNNN)rT)�rrr�__doc__rrrr�re�compile�DOTALLrr!r rrrSr#r�r9�RC4r2�allr!r(r-�propertyrCr3rr7r>r9�setterrBrGrJrNrrQrWrZrr`r�rr�rr�rBr|rjr�r�r�r�r�r�r�r�r�r�r�r�r�r<r�r�r/rsr�r�r�r�r�r�r�r�r�r�rrrr�rrr@�AUTOr+r-r1r�r>rIrGrNr�rQrornr|r�r�r_r�r�r�r�r�r�r�rrrrr&r r-r0r8r;rDrFrCrSr(r&rfrhrprsr$rvrwr�r3r�rGr�rHr�r�r_rwr�r[r�r�rrr]r�r-r�r1r�rDr�r�rF�WORDr;rPrLrkrrur�rVrxr�rkrWrwr�r[r�rr�r�r�r�r�r>r�r5�PRINT�LOCKEDr�r�r�r�r�rZr�r#rhrjrlrnrwryr r~r�r�rOr�rNr�r�rcrI� __classcell__)rs@rr�r��s������������"�� $�� $��$�"�*�%F�� �R�R����"���� �>�*�*�I����M�*�*�J��O�� ��#� N�N�N�N�N�N�f�*�.�(�$�(�*�*��  � � � �B � � �<:�:�:�� �,� � � ��X� � �E�T�E�E�E��X�E���8�����X����-�-���-��6�6��X�6� �6�6��X�6� ����X�� ?�?�?�����& � � ������� 9� 9� 9� 9�� � ��X� � J� J� J�>�>�>�>�4$(��/3��� M �M � �M ��M ���m�+�,� M � � M � � M �M �M �M �^�!�!��X�!���-�-���-� !� !� !� � � � -� -� -�������!�!�!����!�!�!� "� "� "� "�-�-�-�)�)�)�0-�-�-�&(�(�(�(�437� �� Q�Q��3��.�/�Q��Q�� Q�Q�Q�Q�*����!%�26� ��P�P��P��P�� P� � P� � P��3��.�/�P��P��P�P�P�P�hIM�&2�&2�&2�&2�P � � � � � ����1�1�1�?�?�?�?�&?�?�?�?�& ;� ;� ;� ;�����( 5� 5� 5����0��3)�3)�3)��Z��^�3)�j���0��a�M�,>�T� � � ��^� �*  �  �  �  �7�7�7�7�6����  �  ��Z�  ��((�((�((��Z�((�T� H� H� H��Z� H�� � � ��Z� �8�$�$�$��Z�$�LCF�CF�CF�J�7�7�7��Z�7�&% �% �% �N�L�L�L��Z�L�&� *� *� *��Z� *�F�=�=�=��Z�=�<� ������P�P�P��Z�P�r ����+ �+ �+ �+ �Z> �> �> �> �@@L�@L�@L�@L�DVP�VP�VP�VP�pP�P�P�$1�1�1� 4� 4� 4�6�6�6�6�8����8����0�.�.�.��Z�.�d���� 7�7�7�7�r�!"�a�d�:M�#�#�#��Z�#�J�����Z��8� � � � � 0�0�0��Z�0�d����Z��.�IM�.�.�.��^�.�B����^��� �� �2�2�2��Z�2�h�=>�!�!�!��Z�!�F��' �' �' � ���Z�' �R� � � ��Z� �D��%�%�%��^��Z�%�N������^��Z��@�����^��Z��@��: �: ��^��Z�: �|��������Y2�Y2�Y2�Y2�v��� �$�$��X�$��� � � �� ��g� � ����j��h�z �z �z � ���Z�z �~�"#��j��h�����n$�n$��n$� �n$��c�3�h�� n$� � n$� � n$��n$��n$��n$��n$�n$�n$�n$�`  �  �  � � � �,% �% �% �N"�"�"�"�0e��e��e��(�9K�e�e�e�e�N � � � � � ����0,�,�,�����^��8�� � ���g� �� � �����j��i�%�]�� �+���)H�H� �!H�H�H� ���Z�H�T ������%�]� R$�R$� �R$��R$�� R$� � R$� � R$�R$�R$� ���Z�R$�h�#�!�$����(.�����%�]�$)�3 �3 ��s�m�3 ��c�]�3 �� 3 � � 3 � � 3 ��3 ��%��*�%�3 ��3 ��3 ��3 ��3 ��3 �"�3 �3 �3 ��Z�3 �j� � � � � � ��� ��\ �\ �\ ��Z�\ �F � � � � ��� ��1L�1L�� 1L�1L�1L�1L�f K� K� K�" � � � � ����VD�VD��VD�� VD�VD�VD�VD�pR�R�R�h;�;�;�;�$����^�� � � ��%�%�%��Z�%�(���-�-�-���� -� -� -� � � � � � �$�������#�^�%:�;�+ �+ �+ �+ �Z� �������#�^�%:�;�68�68�68��Z�68�p.�.�.�.���+�+�+�  �  �  �  � 4� 4� 4���5 �5 �5 � ���Z�5 �n��B�B�B� ���Z�B�H�����^��Z��(�����^��Z�� �� � ��^��Z� ��1�1��^�1�:� � ��^� ���"'� $'�$'�%�$'��$'� � $'�$'�$'��Z�$'�R������$ �$ �$ �$ �L�B �B �B ��Z�B �H�#��#�#�#��^�#�.�#"�x�#"�#"�#"��^�#"�J��)�)��^��Z�)�X�B�%�~�=�=�=�=�=�=�=�=rr�zFPDF.add_highlightF) r�rGrHr�rUrVrWrErPr�r*)�r�r�loggingrrr�r��sysr<r�� collectionsr� contextlibrrr� functoolsrr �numbersr �os.pathr �pathlibr �typingr rrrrr�,cryptography.hazmat.primitives.serializationr�endesiverrw� PIL.Imagerr��actionsr� annotationsr r!r"r#�bidir$r%� deprecationr&r'r(�drawingr)r*r+r,r-r.r/r0� encryptionr1�enumsr2r3r4r5r6r7r8r9r:r;r<r=r>r?r@rArBrCrDrErFrGrH�errorsrIrJrKr�rLrMrNrOrPrQr�rR�htmlrS�image_datastructuresrTrUrVrW� image_parsingrXrYrZr[� linearizationr\� line_breakr]r^r_r`�outlinerarIrbrcrdrerfrurgr�rh�structure_treerir�rjrk�syntaxrlrmrnr�rorp� text_regionrqrr� transitionsrs�unicode_scriptrtru�utilrvrw� FPDF_VERSIONr�� getLoggerrr/�__file__�resolver��HEREr�� SINGLE_PAGE� ONE_COLUMN�TWO_COLUMN_LEFTrir�r�r�r��modulesr�__pdoc__�__all__rrr�<module>r�s������� � � � ����� � � � � � � � � � � � � � � � � � � � �����#�#�#�#�#�#�%�%�%�%�%�%�'�'�'�'�'�'�'�'�������������������������������H�H�H�H�H�H�H�H�H�H�H�H�H�H�H�H� �C�C�C�C�C�C���������� � � ��N�F�F�F�F� ����  ���������� � � ��H�M�P���� � � � � � � � � � �  ���������������������� <�;�;�;�;�;�;�;����������� � � � � � � � � � � � � � � � � � � � �0�/�/�/�/�/���������������������������������������������������2Y�X�X�X�X�X�X�X�X�X�Q�Q�Q�Q�Q�Q�Q�Q�Q�Q�Q�Q�Q�Q�Q�Q�.�.�.�.�.�.������������������� ������������ 4�3�3�3�3�3������������� $�#�#�#�#�#���������������#�"�"�"�"�"�������0�0�0�0�0�0�#�#�#�#�#�#�#�#�5�5�5�5�5�5�5�5�5�5�*�*�*�*�*�*�*�*�5�5�5�5�5�5�5�5�#�#�#�#�#�#�=�=�=�=�=�=�=�=�+�+�+�+�+�+�+�+�� � � � �� � �� �+� �� �8� $� $�� �t�H�~�~�����&���v� � ���$��'� � %� ��������Z����!S�!S�!S�!S�H � � �WQ�WQ�WQ�WQ�WQ� ��WQ�WQ�WQ�zb#C�� �H��� !�%� (�� � � ���s$�( A5�5 B�B�B � "B2�1B2
Memory