§
    ;]¥eó1  ã                   óŒ   — d dl mZmZmZmZ ddlmZmZmZm	Z	m
Z
 ddlmZmZ ddlmZmZ ddlmZ ddlmZ  G d„ d	¦  «        Zd
S )é    )ÚListÚOptionalÚTupleÚUnioné   )ÚBooleanObjectÚFloatObjectÚ
NameObjectÚNumberObjectÚTextStringObject)ÚArrayObjectÚDictionaryObject)ÚDEFAULT_FITÚFit)ÚRectangleObject)Ú
hex_to_rgbc                   óÔ  — e Zd ZdZddlmZmZ e	 	 d(dee	e
eeeef         f         deded	ed
ef
d„¦   «         Ze	 	 	 	 	 	 	 d)dedee	e
eeeef         f         dededededededed
efd„¦   «         Ze	 	 d*de
eef         de
eef         dee	e
eeeef         f         deded
efd„¦   «         Ze	 d+dee	e
eeeef         f         dee         d
efd„¦   «         Ze	 d+dee	e
eeeef         f         dee         d
efd „¦   «         Zed!ee
eef                  d
efd"„¦   «         Zedddefdee	e
eeeef         f         d#ee         d$ee         d%ee         d&ed
efd'„¦   «         ZdS ),ÚAnnotationBuildera>  
    The AnnotationBuilder creates dictionaries representing PDF annotations.

    Those dictionaries can be modified before they are added to a PdfWriter
    instance via `writer.add_annotation`.

    See `adding PDF annotations <../user/adding-pdf-annotations.html>`_ for
    it's usage combined with PdfWriter.
    é   )ÚFitTypeÚZoomArgTypeFr   ÚrectÚtextÚopenÚflagsÚreturnc                 ót  — t          t          d¦  «        t          d¦  «        t          d¦  «        t          d¦  «        t          d¦  «        t          | ¦  «        t          d¦  «        t          |¦  «        t          d¦  «        t	          |¦  «        t          d¦  «        t          |¦  «        i¦  «        }|S )	a^  
        Add text annotation.

        Args:
            rect: array of four integers ``[xLL, yLL, xUR, yUR]``
                specifying the clickable rectangular area
            text: The text that is added to the document
            open:
            flags:

        Returns:
            A dictionary object representing the annotation.
        ú/Typeú/Annotú/Subtypez/Textú/Rectú	/Contentsz/Openz/Flags)r   r
   r   r   r   r   )r   r   r   r   Útext_objs        ú</usr/lib/python3/dist-packages/pypdf/generic/_annotations.pyr   zAnnotationBuilder.text   sž   € õ* $å˜7Ñ#Ô#¥Z°Ñ%9Ô%9Ý˜:Ñ&Ô&­
°7Ñ(;Ô(;Ý˜7Ñ#Ô#¥_°TÑ%:Ô%:Ý˜;Ñ'Ô'Õ)9¸$Ñ)?Ô)?Ý˜7Ñ#Ô#¥]°4Ñ%8Ô%8Ý˜8Ñ$Ô$¥l°5Ñ&9Ô&9ðñ	
ô 	
ˆð ˆó    Ú	HelveticaÚ14ptÚ000000ÚffffffÚfontÚboldÚitalicÚ	font_sizeÚ
font_colorÚborder_colorÚbackground_colorc	                 óŠ  — d}	|du r|	› d�}	|du r|	› d�}	|	› |› d|› �}	|	› d|› �}	d}
t          |¦  «        D ]	}|
› |› d�}
Œ
|
› d�}
t          ¦   «         }|                     t          d	¦  «        t          d
¦  «        t          d¦  «        t          d¦  «        t          d¦  «        t	          |¦  «        t          d¦  «        t          | ¦  «        t          d¦  «        t          |	¦  «        t          d¦  «        t          |
¦  «        t          d¦  «        t          d„ t          |¦  «        D ¦   «         ¦  «        i¦  «         |S )aé  
        Add text in a rectangle to a page.

        Args:
            text: Text to be added
            rect: array of four integers ``[xLL, yLL, xUR, yUR]``
                specifying the clickable rectangular area
            font: Name of the Font, e.g. 'Helvetica'
            bold: Print the text in bold
            italic: Print the text in italic
            font_size: How big the text will be, e.g. '14pt'
            font_color: Hex-string for the color, e.g. cdcdcd
            border_color: Hex-string for the border color, e.g. cdcdcd
            background_color: Hex-string for the background of the annotation,
                e.g. cdcdcd

        Returns:
            A dictionary object representing the annotation.
        zfont: Tzbold zitalic ú z;text-align:left;color:#Ú Úrgr   r   r    z	/FreeTextr!   r"   z/DSz/DAz/Cc                 ó,   — g | ]}t          |¦  «        ‘ŒS © ©r	   ©Ú.0Úns     r$   ú
<listcomp>z/AnnotationBuilder.free_text.<locals>.<listcomp>w   s   € ÐJÐJÐJ¨•[ ‘^”^ÐJÐJÐJr%   )r   r   Úupdater
   r   r   r   )r   r   r*   r+   r,   r-   r.   r/   r0   Úfont_strÚbg_color_strÚstÚ	free_texts                r$   r@   zAnnotationBuilder.free_text>   sƒ  € ð> ˆØ�4ˆ<ˆ<Ø"Ð)Ð)Ð)ˆHØ�Tˆ>ˆ>Ø"Ð+Ð+Ð+ˆHØÐ2 Ð2Ð2 yÐ2Ð2ˆØÐDÐD¸
ÐDÐDˆàˆÝ˜\Ñ*Ô*ð 	2ð 	2ˆBØ*Ð1¨BÐ1Ð1Ð1ˆLˆLØ&Ð*Ð*Ð*ˆå$Ñ&Ô&ˆ	Ø×Òå˜7Ñ#Ô#¥Z°Ñ%9Ô%9Ý˜:Ñ&Ô&­
°;Ñ(?Ô(?Ý˜7Ñ#Ô#¥_°TÑ%:Ô%:Ý˜;Ñ'Ô'Õ)9¸$Ñ)?Ô)?å˜5Ñ!Ô!Õ#3°HÑ#=Ô#=å˜5Ñ!Ô!Õ#3°LÑ#AÔ#Aå˜4Ñ Ô ¥+ØJÐJ­ZÐ8HÑ-IÔ-IÐJÑJÔJñ#ô #ðñ	
ô 	
ð 	
ð  Ðr%   r3   Úp1Úp2Ú	title_barc                 ó  — t          t          d¦  «        t          d¦  «        t          d¦  «        t          d¦  «        t          d¦  «        t          |¦  «        t          d¦  «        t          |¦  «        t          d¦  «        t	          t          | d         ¦  «        t          | d	         ¦  «        t          |d         ¦  «        t          |d	         ¦  «        g¦  «        t          d
¦  «        t	          t          d¦  «        t          d¦  «        g¦  «        t          d¦  «        t	          t          d¦  «        t          d¦  «        t          d¦  «        g¦  «        t          d¦  «        t          |¦  «        i¦  «        }|S )a  
        Draw a line on the PDF.

        Args:
            p1: First point
            p2: Second point
            rect: array of four integers ``[xLL, yLL, xUR, yUR]``
                specifying the clickable rectangular area
            text: Text to be displayed as the line annotation
            title_bar: Text to be displayed in the title bar of the
                annotation; by convention this is the name of the author

        Returns:
            A dictionary object representing the annotation.
        r   r   r    z/Liner!   z/Tz/Lr   r   z/LENú/ICg      à?r"   )r   r
   r   r   r   r	   )rA   rB   r   r   rC   Úline_objs         r$   ÚlinezAnnotationBuilder.line}   sW  € õ. $å˜7Ñ#Ô#¥Z°Ñ%9Ô%9Ý˜:Ñ&Ô&­
°7Ñ(;Ô(;Ý˜7Ñ#Ô#¥_°TÑ%:Ô%:Ý˜4Ñ Ô Õ"2°9Ñ"=Ô"=Ý˜4Ñ Ô ¥+å# B q¤EÑ*Ô*Ý# B q¤EÑ*Ô*Ý# B q¤EÑ*Ô*Ý# B q¤EÑ*Ô*ð	ñ#ô #õ ˜5Ñ!Ô!¥;å" 4Ñ(Ô(Ý" 4Ñ(Ô(ðñ$ô $õ ˜5Ñ!Ô!¥;å# CÑ(Ô(Ý# CÑ(Ô(Ý# CÑ(Ô(ðñ$ô $õ ˜;Ñ'Ô'Õ)9¸$Ñ)?Ô)?ð5ñ
ô 
ˆð< ˆr%   NÚinteriour_colorc           
      ó<  — t          t          d¦  «        t          d¦  «        t          d¦  «        t          d¦  «        t          d¦  «        t          | ¦  «        i¦  «        }|r6t          d„ t	          |¦  «        D ¦   «         ¦  «        |t          d¦  «        <   |S )aÛ  
        Draw a rectangle on the PDF.

        This method uses the /Square annotation type of the PDF format.

        Args:
            rect: array of four integers ``[xLL, yLL, xUR, yUR]``
                specifying the clickable rectangular area
            interiour_color: None or hex-string for the color, e.g. cdcdcd
                If None is used, the interiour is transparent.

        Returns:
            A dictionary object representing the annotation.
        r   r   r    z/Squarer!   c                 ó,   — g | ]}t          |¦  «        ‘ŒS r6   r7   r8   s     r$   r;   z/AnnotationBuilder.rectangle.<locals>.<listcomp>Ñ   ó   € ÐEÐEÐE A•˜Q‘”ÐEÐEÐEr%   rE   ©r   r
   r   r   r   )r   rH   Ú
square_objs      r$   Ú	rectanglezAnnotationBuilder.rectangle´   sž   € õ& &å˜7Ñ#Ô#¥Z°Ñ%9Ô%9Ý˜:Ñ&Ô&­
°9Ñ(=Ô(=Ý˜7Ñ#Ô#¥_°TÑ%:Ô%:ðñ
ô 
ˆ
ð ð 	Ý,7ØEÐE­°OÑ)DÔ)DÐEÑEÔEñ-ô -ˆJ•z %Ñ(Ô(Ñ)ð Ðr%   c           
      ó<  — t          t          d¦  «        t          d¦  «        t          d¦  «        t          d¦  «        t          d¦  «        t          | ¦  «        i¦  «        }|r6t          d„ t	          |¦  «        D ¦   «         ¦  «        |t          d¦  «        <   |S )aÜ  
        Draw a rectangle on the PDF.

        This method uses the /Circle annotation type of the PDF format.

        Args:
            rect: array of four integers ``[xLL, yLL, xUR, yUR]`` specifying
                the bounding box of the ellipse
            interiour_color: None or hex-string for the color, e.g. cdcdcd
                If None is used, the interiour is transparent.

        Returns:
            A dictionary object representing the annotation.
        r   r   r    z/Circler!   c                 ó,   — g | ]}t          |¦  «        ‘ŒS r6   r7   r8   s     r$   r;   z-AnnotationBuilder.ellipse.<locals>.<listcomp>ó   rK   r%   rE   rL   )r   rH   Úellipse_objs      r$   ÚellipsezAnnotationBuilder.ellipseÖ   sž   € õ& 'å˜7Ñ#Ô#¥Z°Ñ%9Ô%9Ý˜:Ñ&Ô&­
°9Ñ(=Ô(=Ý˜7Ñ#Ô#¥_°TÑ%:Ô%:ðñ
ô 
ˆð ð 	Ý-8ØEÐE­°OÑ)DÔ)DÐEÑEÔEñ.ô .ˆK�
 5Ñ)Ô)Ñ*ð Ðr%   Úverticesc                 óB  — t          | ¦  «        dk    rt          d¦  «        ‚| d         d         | d         d         }}| d         d         | d         d         }}| D ]E\  }}t          ||¦  «        }t          ||¦  «        }t          ||¦  «        }t          ||¦  «        }ŒFt          ||||f¦  «        }g }| D ]I\  }}|                     t          |¦  «        ¦  «         |                     t          |¦  «        ¦  «         ŒJt          t          d¦  «        t          d¦  «        t          d¦  «        t          d¦  «        t          d¦  «        t          |¦  «        t          d	¦  «        t          d
¦  «        t          d¦  «        t          |¦  «        i¦  «        }	|	S )Nr   z6A polygon needs at least 1 vertex with two coordinatesr   r   r   r    z/Polygonz	/Verticesz/ITÚPolygonCloudr!   )	ÚlenÚ
ValueErrorÚminr   Úappendr   r   r
   r   )
rS   Úx_minÚy_minÚx_maxÚy_maxÚxÚyr   Ú
coord_listÚobjs
             r$   ÚpolygonzAnnotationBuilder.polygonø   s†  € åˆx‰=Œ=˜AÒÐÝÐUÑVÔVÐVØ ”{ 1”~ x°¤{°1¤~ˆuˆØ ”{ 1”~ x°¤{°1¤~ˆuˆØð 	"ð 	"‰DˆAˆqÝ˜˜q‘M”MˆEÝ˜˜q‘M”MˆEÝ˜˜q‘M”MˆEÝ˜˜q‘M”MˆEˆEÝ  u¨e°UÐ;Ñ<Ô<ˆØˆ
Øð 	/ð 	/‰DˆAˆqØ×Ò�l¨1™oœoÑ.Ô.Ð.Ø×Ò�l¨1™oœoÑ.Ô.Ð.Ð.Ýå˜7Ñ#Ô#¥Z°Ñ%9Ô%9Ý˜:Ñ&Ô&­
°:Ñ(>Ô(>Ý˜;Ñ'Ô'­°ZÑ)@Ô)@Ý˜5Ñ!Ô!¥:¨nÑ#=Ô#=Ý˜7Ñ#Ô#¥_°TÑ%:Ô%:ðñ
ô 
ˆð ˆ
r%   ÚborderÚurlÚtarget_page_indexÚfitc                 óÚ  — ddl m} |du}|du}|s|st          d¦  «        ‚|r|rt          d|› d|› �¦  «        ‚|�\d„ |dd…         D ¦   «         }t          |¦  «        d	k    r4t	          d
„ |d         D ¦   «         ¦  «        }	|                     |	¦  «         nt          d¦  «        gdz  }t          t          d¦  «        t          d¦  «        t          d¦  «        t          d¦  «        t          d¦  «        t          | ¦  «        t          d¦  «        t	          |¦  «        i¦  «        }
|rst          t          d¦  «        t          d¦  «        t          d¦  «        t          d¦  «        t          d¦  «        t          |¦  «        i¦  «        |
t          d¦  «        <   |rIt          t          |¦  «        t          |j        ¦  «        |j        dœ¦  «        }||
t          d¦  «        <   |
S )a(  
        Add a link to the document.

        The link can either be an external link or an internal link.

        An external link requires the URL parameter.
        An internal link requires the target_page_index, fit, and fit args.

        Args:
            rect: array of four integers ``[xLL, yLL, xUR, yUR]``
                specifying the clickable rectangular area
            border: if provided, an array describing border-drawing
                properties. See the PDF spec for details. No border will be
                drawn if this argument is omitted.
                - horizontal corner radius,
                - vertical corner radius, and
                - border width
                - Optionally: Dash
            url: Link to a website (if you want to make an external link)
            target_page_index: index of the page to which the link should go
                (if you want to make an internal link)
            fit: Page fit or 'zoom' option.

        Returns:
            A dictionary object representing the annotation.
        r   )ÚBorderArrayTypeNzHEither 'url' or 'target_page_index' have to be provided. Both were None.z=Either 'url' or 'target_page_index' have to be provided. url=z, target_page_index=c                 ó,   — g | ]}t          |¦  «        ‘ŒS r6   ©r
   r8   s     r$   r;   z*AnnotationBuilder.link.<locals>.<listcomp>E  s   € Ð<Ð<Ð<¨A�* Q™-œ-Ð<Ð<Ð<r%   é   é   c                 ó,   — g | ]}t          |¦  «        ‘ŒS r6   rj   r8   s     r$   r;   z*AnnotationBuilder.link.<locals>.<listcomp>G  s   € Ð+MÐ+MÐ+M¸a­J°q©M¬MÐ+MÐ+MÐ+Mr%   r   r   r   r    z/Linkr!   z/Borderz/Sz/URIz/Actionz/A)re   rf   Úfit_argsz/Dest)Útypesrh   rW   rV   r   rY   r   r   r
   r   r   Úfit_typern   )r   rc   rd   re   rf   rh   Úis_externalÚis_internalÚ
border_arrÚdash_patternÚlink_objÚdest_deferreds               r$   ÚlinkzAnnotationBuilder.link  s>  € ðD 	,Ð+Ð+Ð+Ð+Ð+à �oˆØ'¨tÐ3ˆØð 	 ;ð 	ÝØZñô ð ð ð 	˜;ð 	ÝðDØðDð DØ0AðDð Dñô ð ð ÐØ<Ð<°¸¸¸´Ð<Ñ<Ô<ˆJÝ�6‰{Œ{˜aÒÐÝ*Ð+MÐ+MÀ6È!Ä9Ð+MÑ+MÔ+MÑNÔN�Ø×!Ò! ,Ñ/Ô/Ð/øå& q™/œ/Ð*¨QÑ.ˆJå#å˜7Ñ#Ô#¥Z°Ñ%9Ô%9Ý˜:Ñ&Ô&­
°7Ñ(;Ô(;Ý˜7Ñ#Ô#¥_°TÑ%:Ô%:Ý˜9Ñ%Ô%¥{°:Ñ'>Ô'>ð	ñ
ô 
ˆð ð 	Ý)9å˜tÑ$Ô$¥j°Ñ&8Ô&8Ý˜wÑ'Ô'­°IÑ)>Ô)>Ý˜vÑ&Ô&Õ(8¸Ñ(=Ô(=ðñ*ô *ˆH•Z Ñ%Ô%Ñ&ð ð 		:å,å)5Ð6GÑ)HÔ)HÝ% c¤lÑ3Ô3Ø #¤ðð ñô ˆMð -:ˆH•Z Ñ(Ô(Ñ)Øˆr%   )Fr   )r&   FFr'   r(   r(   r)   )r3   r3   )N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ro   r   r   Ústaticmethodr   r   r   ÚfloatÚstrÚboolÚintr   r   r@   rG   r   rN   rR   r   rb   r   r   r   rw   r6   r%   r$   r   r      s‹  € € € € € ðð ð -Ð,Ð,Ð,Ð,Ð,Ð,Ð,àð Øð	ð Ø�O U¨5°%¸ÀÐ+EÔ%FÐFÔGðàðð ðð ð	ð
 
ðð ð ñ „\ðð@ ð  ØØØØ"Ø$Ø (ð<ð <Øð<à�O U¨5°%¸ÀÐ+EÔ%FÐFÔGð<ð ð<ð ð	<ð
 ð<ð ð<ð ð<ð ð<ð ð<ð 
ð<ð <ð <ñ „\ð<ð| ð
 Øð4ð 4Ø�%˜�,Ôð4à�%˜�,Ôð4ð �O U¨5°%¸ÀÐ+EÔ%FÐFÔGð4ð ð	4ð
 ð4ð 
ð4ð 4ð 4ñ „\ð4ðl ð *.ðð Ø�O U¨5°%¸ÀÐ+EÔ%FÐFÔGðà! #œðð 
ðð ð ñ „\ððB ð *.ðð Ø�O U¨5°%¸ÀÐ+EÔ%FÐFÔGðà! #œðð 
ðð ð ñ „\ððB ð˜$˜u U¨E \Ô2Ô3ð Ð8Hð ð ð ñ „\ðð4 ð )-Ø!Ø+/ØðRð RØ�O U¨5°%¸ÀÐ+EÔ%FÐFÔGðRà˜Ô%ðRð �cŒ]ðRð $ Cœ=ð	Rð
 ðRð 
ðRð Rð Rñ „\ðRð Rð Rr%   r   N)Útypingr   r   r   r   Ú_baser   r	   r
   r   r   Ú_data_structuresr   r   Ú_fitr   r   Ú
_rectangler   Ú_utilsr   r   r6   r%   r$   ú<module>r‡      s  ðØ /Ð /Ð /Ð /Ð /Ð /Ð /Ð /Ð /Ð /Ð /Ð /ðð ð ð ð ð ð ð ð ð ð ð ð ð ð <Ð ;Ð ;Ð ;Ð ;Ð ;Ð ;Ð ;Ø "Ð "Ð "Ð "Ð "Ð "Ð "Ð "Ø 'Ð 'Ð 'Ð 'Ð 'Ð 'Ø Ð Ð Ð Ð Ð ðVð Vð Vð Vð Vñ Vô Vð Vð Vð Vr%   