Ë
    ˜…j‘[  ã                   ó   — d Z ddlZddlZddlZddlZddlmZ ddlm	Z
 ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ej*                  Z ej,                  e«      Z G d„ d	e
j2                  «      Zd
„ Z	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd„Z G d„ d«      Zy))ÚPdfPageÚPdfColorSchemeé    N)ÚPdfiumError)Ú	PdfBitmap)ÚPdfTextPage)Ú	PdfObject)ÚPDFIUM_INFOc                   ó  ‡ — e Zd ZdZˆ fd„Zed„ «       Zed„ «       Zd„ Z	d„ Z
d„ Zd„ Zd	„ Zd
„ Zd#d„Zd„ Zd#d„Zd„ Zd#d„Zd„ Zd#d„Zd„ Zd#d„Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd$d„Zej@                  fd„Z!ddd de"jF                  dd!fd"„Z$ˆ xZ%S )%r   ah  
    Page helper class.
    
    Attributes:
        raw (FPDF_PAGE):
            The underlying PDFium page handle.
        pdf (PdfDocument):
            Reference to the document this page belongs to.
        formenv (PdfFormEnv | None):
            Formenv handle, if the parent pdf had an active formenv at the time of page retrieval. None otherwise.
    c                 ó€   •— || _         || _        || _        t        ‰| �  t
        j                  | j                  «       y ©N)ÚrawÚpdfÚformenvÚsuperÚ__init__r   Ú_close_impl)Úselfr   r   r   Ú	__class__s       €úX/root/aria/tools/markitdown-venv/lib/python3.12/site-packages/pypdfium2/_helpers/page.pyr   zPdfPage.__init__#   s1   ø€ ØˆŒØˆŒØˆŒÜ‰Ñœ×,Ñ,¨d¯l©lÕ;ó    c                 ó^   — |rt        j                  | |«       t        j                  | «       y r   )Úpdfium_cÚFORM_OnBeforeClosePageÚFPDF_ClosePage)r   r   s     r   r   zPdfPage._close_impl*   s#   € áÜ×+Ñ+¨C°Ô9Ü×Ñ Õ$r   c                 óJ   — | j                   €| j                  S | j                   S r   )r   r   ©r   s    r   ÚparentzPdfPage.parent1   s    € ð  Ÿ<™<Ð/ˆt�x‰xÐA°T·\±\ÐAr   c                 ó,   — t        j                  | «      S )z`
        Returns:
            float: Page width (horizontal size), in PDF canvas units.
        )r   ÚFPDF_GetPageWidthFr   s    r   Ú	get_widthzPdfPage.get_width7   s   € ô
 ×*Ñ*¨4Ó0Ð0r   c                 ó,   — t        j                  | «      S )z_
        Returns:
            float: Page height (vertical size), in PDF canvas units.
        )r   ÚFPDF_GetPageHeightFr   s    r   Ú
get_heightzPdfPage.get_height>   s   € ô
 ×+Ñ+¨DÓ1Ð1r   c                 óB   — | j                  «       | j                  «       fS )zb
        Returns:
            (float, float): Page width and height, in PDF canvas units.
        )r    r#   r   s    r   Úget_sizezPdfPage.get_sizeE   s   € ð
 —‘Ó  $§/¡/Ó"3Ð4Ð4r   c                 ór   — t        j                  | «      }|dk(  rt        d«      ‚t        j                  |   S )zO
        Returns:
            int: Clockwise page rotation in degrees.
        éÿÿÿÿzFailed to get page rotation.)r   ÚFPDFPage_GetRotationr   Úpdfium_iÚRotationToDegrees)r   Úraw_rotations     r   Úget_rotationzPdfPage.get_rotationO   s9   € ô
  ×4Ñ4°TÓ:ˆØ˜2ÒÜÐ<Ó=Ð=Ü×)Ñ)¨,Ñ7Ð7r   c                 óR   — t        j                  | t        j                  |   «       y)z\
        Define the absolute, clockwise page rotation (0, 90, 180, or 270 degrees).
        N)r   ÚFPDFPage_SetRotationr)   ÚRotationToConst)r   Úrotations     r   Úset_rotationzPdfPage.set_rotationY   s   € ô 	×%Ñ% d¬H×,DÑ,DÀXÑ,NÕOr   c                 óæ   — t        «       t        «       t        «       t        «       f\  }}}} || ||||«      }|s|r |«       S d S |j                  |j                  |j                  |j                  fS r   )Úc_floatÚvalue)	r   Úbox_funcÚfallback_funcÚfallback_okÚleftÚbottomÚrightÚtopÚoks	            r   Ú_get_boxzPdfPage._get_box`   sd   € Ü#*£9¬g«i¼»ÄGÃIÐ#MÑ ˆˆf�e˜SÙ�d˜D &¨%°Ó5ˆÙÙ'2‘M“OÐ=¸Ð=Ø—
‘
˜FŸL™L¨%¯+©+°s·y±yÐAÐAr   Tc                 óF   — | j                  t        j                  d„ |«      S )aø  
        Returns:
            (float, float, float, float) | None:
            The page MediaBox in PDF canvas units, consisting of four coordinates (usually x0, y0, x1, y1).
            If MediaBox is not defined, returns ANSI A (0, 0, 612, 792) if ``fallback_ok=True``, None otherwise.
        
        .. admonition:: Known issue

            Due to quirks in PDFium, all ``get_*box()`` functions except :meth:`.get_bbox` do not inherit from parent nodes in the page tree (as of PDFium 5418).
        c                   ó   — y)N)r   r   id  i  © r@   r   r   ú<lambda>z&PdfPage.get_mediabox.<locals>.<lambda>t   ó   � r   )r=   r   ÚFPDFPage_GetMediaBox©r   r7   s     r   Úget_mediaboxzPdfPage.get_mediaboxi   s   € ð �}‰}œX×:Ñ:Ñ<TÐVaÓbÐbr   c                 ó6   — t        j                  | ||||«       y)zn
        Set the page's MediaBox by passing four :class:`float` coordinates (usually x0, y0, x1, y1).
        N)r   ÚFPDFPage_SetMediaBox©r   ÚlÚbÚrÚts        r   Úset_mediaboxzPdfPage.set_mediaboxv   ó   € ô 	×%Ñ% d¨A¨q°!°QÕ7r   c                 óX   — | j                  t        j                  | j                  |«      S )zc
        Returns:
            The page's CropBox (If not defined, falls back to MediaBox).
        )r=   r   ÚFPDFPage_GetCropBoxrE   rD   s     r   Úget_cropboxzPdfPage.get_cropbox|   s#   € ð
 �}‰}œX×9Ñ9¸4×;LÑ;LÈkÓZÐZr   c                 ó6   — t        j                  | ||||«       y)z)
        Set the page's CropBox.
        N)r   ÚFPDFPage_SetCropBoxrH   s        r   Úset_cropboxzPdfPage.set_cropboxƒ   ó   € ô 	×$Ñ$ T¨1¨a°°AÕ6r   c                 óX   — | j                  t        j                  | j                  |«      S )zc
        Returns:
            The page's BleedBox (If not defined, falls back to CropBox).
        )r=   r   ÚFPDFPage_GetBleedBoxrQ   rD   s     r   Úget_bleedboxzPdfPage.get_bleedbox‰   s#   € ð
 �}‰}œX×:Ñ:¸D×<LÑ<LÈkÓZÐZr   c                 ó6   — t        j                  | ||||«       y)z*
        Set the page's BleedBox.
        N)r   ÚFPDFPage_SetBleedBoxrH   s        r   Úset_bleedboxzPdfPage.set_bleedbox�   rN   r   c                 óX   — | j                  t        j                  | j                  |«      S )zb
        Returns:
            The page's TrimBox (If not defined, falls back to CropBox).
        )r=   r   ÚFPDFPage_GetTrimBoxrQ   rD   s     r   Úget_trimboxzPdfPage.get_trimbox–   s#   € ð
 �}‰}œX×9Ñ9¸4×;KÑ;KÈ[ÓYÐYr   c                 ó6   — t        j                  | ||||«       y)z)
        Set the page's TrimBox.
        N)r   ÚFPDFPage_SetTrimBoxrH   s        r   Úset_trimboxzPdfPage.set_trimbox�   rU   r   c                 óX   — | j                  t        j                  | j                  |«      S )za
        Returns:
            The page's ArtBox (If not defined, falls back to CropBox).
        )r=   r   ÚFPDFPage_GetArtBoxrQ   rD   s     r   Ú
get_artboxzPdfPage.get_artbox£   s#   € ð
 �}‰}œX×8Ñ8¸$×:JÑ:JÈKÓXÐXr   c                 ó6   — t        j                  | ||||«       y)z(
        Set the page's ArtBox.
        N)r   ÚFPDFPage_SetArtBoxrH   s        r   Ú
set_artboxzPdfPage.set_artboxª   s   € ô 	×#Ñ# D¨!¨Q°°1Õ5r   c                 óÌ   — t        j                  «       }t        j                  | |«      }|st        d«      ‚|j                  |j
                  |j                  |j                  fS )zz
        Returns:
            The bounding box of the page (the intersection between its media box and crop box).
        z Failed to get page bounding box.)r   ÚFS_RECTFÚFPDF_GetPageBoundingBoxr   r8   r9   r:   r;   )r   Úrectr<   s      r   Úget_bboxzPdfPage.get_bbox±   sR   € ô
 × Ñ Ó"ˆÜ×-Ñ-¨d°DÓ9ˆÙÜÐ@ÓAÐAØ—	‘	˜4Ÿ;™;¨¯
©
°D·H±HÐ=Ð=r   c                 ó„   — t        j                  | «      }|st        d«      ‚t        || «      }| j	                  |«       |S )zY
        Returns:
            PdfTextPage: A new text page handle for this page.
        zFailed to load text page.)r   ÚFPDFText_LoadPager   r   Ú_add_kid)r   Úraw_textpageÚtextpages      r   Úget_textpagezPdfPage.get_textpageÀ   s@   € ô
  ×1Ñ1°$Ó7ˆÙÜÐ9Ó:Ð:Ü˜|¨TÓ2ˆØ�‰�hÔØˆr   c                 óL  — |j                   rt        d«      ‚|j                  r#|j                  | j                  urt        d«      ‚t        j                  | |«      }|st
        j                  dk\  rt        d«      ‚|j                  «        | |_         | j                  |_        y)a¾  
        Insert a pageobject into the page.
        
        The pageobject must not belong to a page yet. If it belongs to a PDF, the target page must be part of that PDF.
        
        Position and form are defined by the object's matrix.
        If it is the identity matrix, the object will appear as-is on the bottom left corner of the page.
        
        Parameters:
            pageobj (PdfObject): The pageobject to insert.
        zAThe pageobject you attempted to insert already belongs to a page.zBThe pageobject you attempted to insert belongs to a different PDF.i�  zFailed to insert object.N)	ÚpageÚ
ValueErrorr   r   ÚFPDFPage_InsertObjectr	   Úbuildr   Ú_detach_finalizer©r   Úpageobjr<   s      r   Ú
insert_objzPdfPage.insert_objÍ   s…   € ð �<Š<ÜÐ`ÓaÐaØ�;Š;˜GŸK™K¨t¯x©xÑ7ÜÐaÓbÐbä×+Ñ+¨D°'Ó:ˆÙ”k×'Ñ'¨4Ò/ÜÐ8Ó9Ð9Ø×!Ñ!Ô#ØˆŒØ—h‘hˆ�r   c                 ó`  — |j                   | urt        d«      ‚|j                  dkD  r>|j                  €J ‚t	        j
                  |j                  |«      }d\  |_        |_        n$|j                  �J ‚t	        j                  | |«      }|st        d«      ‚d|_         |j                  «        y)a#  
        Remove a pageobject from the page.
        As of PDFium 5692, detached pageobjects may be only re-inserted into existing pages of the same document.
        If the pageobject is not re-inserted into a page, its ``close()`` method may be called.
        
        Note:
            If the object's :attr:`~.PdfObject.type` is :data:`FPDF_PAGEOBJ_TEXT`, any :class:`.PdfTextPage` handles to the page should be closed before removing the object.
        
        Parameters:
            pageobj (PdfObject): The pageobject to remove.
        z@The pageobject you attempted to remove is not part of this page.r   N)r   NzFailed to remove pageobject.)	rt   ru   ÚlevelÚ	containerr   ÚFPDFFormObj_RemoveObjectÚFPDFPage_RemoveObjectr   Ú_attach_finalizerry   s      r   Ú
remove_objzPdfPage.remove_objç   s§   € ð �<‰<˜tÑ#ÜÐ_Ó`Ð`à�=‰=˜1ÒØ×$Ñ$Ð0Ð0Ð0Ü×2Ñ2°7×3DÑ3DÀgÓNˆBØ/6Ñ,ˆGŒM˜7Õ,à×$Ñ$Ð,Ð,Ð,Ü×/Ñ/°°gÓ>ˆBáÜÐ<Ó=Ð=àˆŒØ×!Ñ!Õ#r   c                 óH   — t        j                  | «      }|st        d«      ‚y)zê
        Generate page content to apply additions, removals or modifications of pageobjects.
        
        If page content was changed, this function should be called once before saving the document or re-loading the page.
        z Failed to generate page content.N)r   ÚFPDFPage_GenerateContentr   )r   r<   s     r   Úgen_contentzPdfPage.gen_content  s(   € ô ×.Ñ.¨tÓ4ˆÙÜÐ@ÓAÐAð r   Nr   c           	   #   ó>  K  — |r#t         j                  }t         j                  }|}n=t         j                  }t         j                  }| }|r|j
                  | urt        d«      ‚ ||«      }	|	dk  rt        d«      ‚t        |	«      D ]�  }
 |||
«      }|st        d«      ‚t        || | j                  |||¬«      }|r|j                  |v r|–— |j                  t         j                  k(  sŒf||dz
  k  sŒo| j                  ||||dz   |¬«      E d{  –—†  Œ‘ y7 Œ­w)	a¸  
        Iterate through the pageobjects on this page.
        
        Parameters:
            filter (list[int] | None):
                An optional list of pageobject types to filter (:attr:`FPDF_PAGEOBJ_*`).
                Any objects whose type is not contained will be skipped.
                If None or empty, all objects will be provided, regardless of their type.
            max_depth (int):
                Maximum recursion depth to consider when descending into Form XObjects.
            textpage (PdfTextPage | None):
                Text page to pass through to any :class:`.PdfTextObj` instances.
        
        Yields:
            :class:`.PdfObject`: A pageobject.
        z0The given textpage does not belong to this page.r   z$Failed to get number of pageobjects.zFailed to get pageobject.)rt   r   r~   r}   rq   é   )ÚfilterÚ	max_depthÚformr}   rq   N)r   ÚFPDFFormObj_CountObjectsÚFPDFFormObj_GetObjectÚFPDFPage_CountObjectsÚFPDFPage_GetObjectrt   ru   r   Úranger   r   ÚtypeÚFPDF_PAGEOBJ_FORMÚget_objects)r   rˆ   r‰   rŠ   r}   rq   Úcount_objectsÚ
get_objectr   Ú	n_objectsÚiÚraw_objÚ
helper_objs                r   r’   zPdfPage.get_objects  s*  è ø€ ñ$ Ü$×=Ñ=ˆMÜ!×7Ñ7ˆJØ‰Fä$×:Ñ:ˆMÜ!×4Ñ4ˆJØˆFÙ˜HŸM™M°Ñ5Ü Ð!SÓTÐTá! &Ó)ˆ	Ø�qŠ=ÜÐDÓEÐEä�yÓ!ò 	ˆAá  ¨Ó+ˆGÙÜ!Ð"=Ó>Ð>ô # 7°¸4¿8¹8ÈtÐ[`ÐksÔtˆJÙ˜ZŸ_™_°Ñ6Ø Ò à�‰¤(×"<Ñ"<Ó<ÀÈÐSTÉÓATØ×+Ñ+Ø#Ø )Ø%Ø! A™IØ'ð ,ó ÷ ñ ñ	ðús   ‚C+DÃ.DÃ7DÄDÄDc                 óœ   — | j                   st        d«      ‚t        j                  | |«      }|t        j                  k(  rt        d«      ‚|S )aƒ  
        Flatten form fields and annotations into page contents.
        
        Attention:
            * :meth:`~.PdfDocument.init_forms` must have been called on the parent pdf, before the page was retrieved, for this method to work. In other words, :attr:`.PdfPage.formenv` must be non-null.
            * Flattening may invalidate existing handles to the page, so you'll want to re-initialize these afterwards.
        
        Parameters:
            flag (int): PDFium flattening target (:attr:`FLAT_*`)
        Returns:
            int: PDFium flattening status (:attr:`FLATTEN_*`). :attr:`FLATTEN_FAIL` is handled internally.
        zFpage.flatten() requires prior pdf.init_forms(), before page retrieval.z,Failed to flatten annotations / form fields.)r   ÚRuntimeErrorr   ÚFPDFPage_FlattenÚFLATTEN_FAILr   )r   ÚflagÚrcs      r   ÚflattenzPdfPage.flattenI  sH   € ð �|Š|ÜÐgÓhÐhÜ×&Ñ& t¨TÓ2ˆØ”×&Ñ&Ò&ÜÐLÓMÐMØˆ	r   r‡   )r   r   r   r   Fc                 ó  — t        j                  | j                  «       |z  «      }	t        j                  | j                  «       |z  «      }
|dv r|
|	}
}	|D �cg c]  }t        j                  ||z  «      ‘Œ }}|	|d   z
  |d   z
  }|
|d   z
  |d   z
  }t	        d„ ||fD «       «      rt        d«      ‚t        | fi |¤Ž\  }}}}|�|r|t        j                  z  } |||||¬«      }|j                  |dd||«       |d    |d    |	|
t        j                  |   f}|| g|¢|‘­}|€t        j                  |Ž  n‚t        j                  d¬	«      }t        j                  |d
d„ «       |j                  |«      }t        j                   g |¢|‘|‘­Ž }|t        j"                  k(  sJ ‚t        j$                  | «       |r,| j&                  r t        j(                  | j&                  g|¢­Ž  t+        j,                  | «      |f|_        |S c c}w )að  
        Rasterize the page to a :class:`.PdfBitmap`.
        
        Parameters:
            
            scale (float):
                A factor scaling the number of pixels per PDF canvas unit. This defines the resolution of the image.
                To convert a DPI value to a scale factor, multiply it by the size of 1 canvas unit in inches (usually 1/72in). [#user_unit]_
            
            rotation (int):
                Additional rotation in degrees (0, 90, 180, or 270).
            
            crop (tuple[float, float, float, float]):
                Amount in PDF canvas units to cut off from page borders (left, bottom, right, top). Crop is applied after rotation.
            
            may_draw_forms (bool):
                If True, render form fields (provided the document has forms and :meth:`~.PdfDocument.init_forms` was called).
            
            bitmap_maker (typing.Callable):
                Callback function used to create the :class:`.PdfBitmap`.
            
            fill_color (tuple[int, int, int, int]):
                Color the bitmap will be filled with before rendering. This uses RGBA syntax regardless of the pixel format used, with values from 0 to 255.
                If the fill color is not opaque (i.e. has transparency), ``{BGR,RGB}A`` will be used.
            
            grayscale (bool):
                If True, render in grayscale mode.
            
            optimize_mode (None | str):
                Page rendering optimization mode (None, "lcd", "print").
            
            draw_annots (bool):
                If True, render page annotations.
            
            no_smoothtext (bool):
                If True, disable text anti-aliasing. Overrides ``optimize_mode="lcd"``.
            
            no_smoothimage (bool):
                If True, disable image anti-aliasing.
            
            no_smoothpath (bool):
                If True, disable path anti-aliasing.
            
            force_halftone (bool):
                If True, always use halftone for image stretching.
            
            limit_image_cache (bool):
                If True, limit image cache size.
            
            rev_byteorder (bool):
                If True, render with reverse byte order, leading to ``RGB{A/x}`` output rather than ``BGR{A/x}``.
                Other pixel formats are not affected.
            
            prefer_bgrx (bool):
                If True, use 4-byte ``{BGR/RGB}x`` rather than 3-byte ``{BGR/RGB}`` (i.e. add an unused byte).
                Other pixel formats are not affected.
            
            maybe_alpha (bool):
                If True, use a pixel format with alpha channel (i.e. ``{BGR/RGB}A``) if page content has transparency.
                This is recommended for performance in these cases, but as page-dependent format selection can be unexpected, it is not enabled by default.
            
            force_bitmap_format (int | None):
                If given, override automatic pixel format selection and enforce use of the given format (one of the :attr:`FPDFBitmap_*` constants). In this case, you should not pass any other format selection options, except potentially *rev_byteorder*.
            
            extra_flags (int):
                Additional PDFium rendering flags. May be combined with bitwise OR (``|`` operator).
            
            color_scheme (PdfColorScheme | None):
                A custom pdfium color scheme. Note that this may flatten different colors into one, so the usability of this is limited.
            
            fill_to_stroke (bool):
                If a *color_scheme* is given, whether to only draw borders around fill areas using the `path_stroke` color, instead of filling with the `path_fill` color.
        
        Returns:
            PdfBitmap: Bitmap of the rendered page.
        
        .. admonition:: Format selection
            
            This is the format selection hierarchy used by :meth:`.render`, from lowest to highest priority:
            
            * default: ``BGR``
            * ``prefer_bgrx=True``: ``BGRx``
            * ``grayscale=True``: ``L``
            * ``maybe_alpha=True``: ``BGRA`` if the page has transparency, else the format selected otherwise
            * ``fill_color[3] < 255``: ``BGRA`` (background color with transparency)
            * ``force_bitmap_format=...`` -> any supported by pdfium
            
            Additionally, ``rev_byteorder=True`` will swap ``BGR{A/x}`` to ``RGB{A/x}`` if applicable.
        
        .. [#user_unit] Since PDF 1.6, pages may define an additional user unit factor. In this case, 1 canvas unit is equivalent to ``user_unit * (1/72)`` inches. PDFium does not currently provide an API to get the user unit, so this is not taken into account.
        )éZ   i  r   é   r‡   é   c              3   ó&   K  — | ]	  }|d k  –— Œ y­w)r‡   Nr@   )Ú.0Úds     r   ú	<genexpr>z!PdfPage.render.<locals>.<genexpr>Ò  s   è ø€ Ò.˜ˆq�1�uÑ.ùs   ‚zCrop exceeds page dimensions)ÚformatÚrev_byteorder)ÚversionÚNeedToPauseNowc                  ó   — y)NFr@   )Ú_s    r   rA   z PdfPage.render.<locals>.<lambda>ã  rB   r   )ÚmathÚceilr    r#   Úanyru   Ú_parse_renderoptsr   ÚFPDF_CONVERT_FILL_TO_STROKEÚ	fill_rectr)   r/   ÚFPDF_RenderPageBitmapÚIFSDK_PAUSEÚset_callbackÚconvertÚ*FPDF_RenderPageBitmapWithColorScheme_StartÚFPDF_RENDER_DONEÚFPDF_RenderPage_Closer   ÚFPDF_FFLDrawÚweakrefÚrefÚ_render_args)r   Úscaler0   ÚcropÚmay_draw_formsÚbitmap_makerÚcolor_schemeÚfill_to_strokeÚkwargsÚ	src_widthÚ
src_heightÚcÚwidthÚheightÚ	cl_formatr©   Ú
fill_colorÚflagsÚbitmapÚpos_argsÚrender_argsÚpauseÚfpdf_csÚstatuss                           r   ÚrenderzPdfPage.renderc  s  € ôN —Y‘Y˜tŸ~™~Ó/°5Ñ8Ó9ˆ	Ü—Y‘Y˜tŸ™Ó0°5Ñ8Ó9ˆ
Ø�yÑ Ø$.°	�zˆIà,0Ö1 q”—	‘	˜!˜E™'Õ"Ð1ˆÐ1Ø˜d 1™gÑ%¨¨Q©Ñ/ˆØ˜d 1™gÑ%¨¨Q©Ñ/ˆÜÑ.˜u f˜oÔ.Ô.ÜÐ;Ó<Ð<ä6GÈÑ6WÐPVÑ6WÑ3ˆ	�= *¨eØÐ$©.Ø”X×9Ñ9Ñ9ˆEá˜e V°IÈ]Ô[ˆØ×Ñ˜ Q¨¨5°&Ô9à˜!‘W�H˜t A™w˜h¨	°:¼x×?WÑ?WÐX`Ñ?aÐbˆØ˜tÐ6 hÐ6°Ñ6ˆàÐÜ×*Ñ*¨KÒ8ä×(Ñ(°Ô3ˆEÜ×!Ñ! %Ð)9¹?ÔKØ"×*Ñ*¨=Ó9ˆGÜ×HÑHÐfÈ+ÐfÐW^ÐfÐ`eÒfˆFØœX×6Ñ6Ò6Ð6Ð6Ü×*Ñ*¨4Ô0á˜dŸlšlÜ×!Ñ! $§,¡,Ð=°Ó=ä&Ÿ{™{¨4Ó0°(Ð;ˆÔØˆùò= 2s   ÁH
)T)Né   Nr   N)&Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Ústaticmethodr   Úpropertyr   r    r#   r%   r,   r1   r=   rE   rM   rQ   rT   rX   r[   r^   ra   rd   rg   rl   rr   r{   r‚   r…   r’   r   ÚFLAT_NORMALDISPLAYrŸ   r   Ú
new_nativerÔ   Ú__classcell__)r   s   @r   r   r      sâ   ø„ ñ
ô<ð ñ%ó ð%ð ñBó ðBò
1ò2ò5ò8òPòBócò8ó[ò7ó[ò8óZò7óYò6ò	>ò
òò4$òBBó3ðl $×6Ñ6ó ð8 ØØØ!Ø$×/Ñ/ØØ"÷Jr   r   c                 óÈ   — |d   dk  s|r%t        j                  | «      rt         j                  S |rt         j                  S |rt         j                  S t         j
                  S )Nr£   éÿ   )r   ÚFPDFPage_HasTransparencyÚFPDFBitmap_BGRAÚFPDFBitmap_GrayÚFPDFBitmap_BGRxÚFPDFBitmap_BGR)rt   rÌ   Ú	grayscaleÚprefer_bgrxÚmaybe_alphas        r   Ú_auto_bitmap_formatré   ð  sV   € ð �!�}�sÒ™{¬x×/PÑ/PÐQUÔ/VÜ×'Ñ'Ð'Ù	Ü×'Ñ'Ð'Ù	Ü×'Ñ'Ð'ä×&Ñ&Ð&r   c                 óX  — |€t        | ||||«      }n|}|t        j                  k(  rd}
|}|r|t        j                  z  }|r|t        j                  z  }|r|t        j
                  z  }|r|t        j                  z  }|r|t        j                  z  }|r|t        j                  z  }|	r|t        j                  z  }|
r|t        j                  z  }|rP|j                  «       }|dk(  r|t        j                  z  }n'|dk(  r|t        j                  z  }nt        d|› �«      ‚||
||fS )NFÚlcdÚprintzInvalid optimize_mode )ré   r   rã   ÚFPDF_GRAYSCALEÚ
FPDF_ANNOTÚFPDF_RENDER_NO_SMOOTHTEXTÚFPDF_RENDER_NO_SMOOTHIMAGEÚFPDF_RENDER_NO_SMOOTHPATHÚFPDF_RENDER_FORCEHALFTONEÚFPDF_RENDER_LIMITEDIMAGECACHEÚFPDF_REVERSE_BYTE_ORDERÚlowerÚFPDF_LCD_TEXTÚFPDF_PRINTINGru   )rt   rÌ   ræ   Úoptimize_modeÚdraw_annotsÚno_smoothtextÚno_smoothimageÚno_smoothpathÚforce_halftoneÚlimit_image_cacher©   rç   rè   Úforce_bitmap_formatÚextra_flagsrË   rÍ   s                    r   r±   r±   ý  s7  € ð$ Ð"Ü'¨¨j¸)À[ÐR]Ó^‰	à'ˆ	à”H×,Ñ,Ò,Øˆà€EÙØ”×(Ñ(Ñ(ˆÙØ”×$Ñ$Ñ$ˆÙØ”×3Ñ3Ñ3ˆÙØ”×4Ñ4Ñ4ˆÙØ”×3Ñ3Ñ3ˆÙØ”×3Ñ3Ñ3ˆÙØ”×7Ñ7Ñ7ˆÙØ”×1Ñ1Ñ1ˆáØ%×+Ñ+Ó-ˆØ˜EÒ!Ø”X×+Ñ+Ñ+‰EØ˜gÒ%Ø”X×+Ñ+Ñ+‰EäÐ5°m°_ÐEÓFÐFð �m Z°Ð6Ð6r   c                   ó"   — e Zd ZdZd„ Zd„ Zd„ Zy)r   z�
    Rendering color scheme.
    Each color shall be provided as a list of values for red, green, blue and alpha, ranging from 0 to 255.
    c                 ó,   — t        ||||¬«      | _        y )N)Úpath_fill_colorÚpath_stroke_colorÚtext_fill_colorÚtext_stroke_color)ÚdictÚcolors)r   Ú	path_fillÚpath_strokeÚ	text_fillÚtext_strokes        r   r   zPdfColorScheme.__init__<  s   € ÜØ%¸Ø%¸ô
ˆ�r   c                 óL   — t        | «      j                  › d| j                  › d�S )Nz(**ú))r�   rÖ   r  r   s    r   Ú__repr__zPdfColorScheme.__repr__B  s$   € Ü�t“*×%Ñ%Ð& c¨$¯+©+¨°aÐ8Ð8r   c           	      ó´   — t        j                  «       }| j                  j                  «       D ]&  \  }}t	        ||t        j                  ||«      «       Œ( |S )z\
        Returns:
            The color scheme as :class:`FPDF_COLORSCHEME` object.
        )r   ÚFPDF_COLORSCHEMEr  ÚitemsÚsetattrr)   Úcolor_tohex)r   r©   rÒ   Úkeyr4   s        r   r·   zPdfColorScheme.convertE  sR   € ô
 ×+Ñ+Ó-ˆØŸ+™+×+Ñ+Ó-ò 	N‰JˆC�Ü�G˜S¤(×"6Ñ"6°u¸mÓ"LÕMð	Nàˆr   N)rÖ   r×   rØ   rÙ   r   r  r·   r@   r   r   r   r   6  s   „ ñò

ò9ór   r   ))rà   rà   rà   rà   FNTFFFFFFFFNr   )Ú__all__r®   ÚctypesÚloggingr¼   Úpypdfium2.rawr   r   Úpypdfium2.internalÚinternalr)   Úpypdfium2._helpers.miscr   Úpypdfium2._helpers.bitmapr   Úpypdfium2._helpers.textpager   Úpypdfium2._helpers.pageobjectsr   Úpypdfium2.versionr	   r3   Ú	getLoggerrÖ   ÚloggerÚAutoCloseabler   ré   r±   r   r@   r   r   ú<module>r$     sž   ðð (€ã Û Û Û Ý  Ý %Ý /Ý /Ý 3Ý 4Ý )à
�.‰.€Ø	ˆ×	Ñ	˜8Ó	$€ôWˆx×%Ñ%ô Wòt
'ð *ØØØØØØØØ!ØØØØ"Øó67÷rò r   