a
    còf˜;  ã                	   @   s’  d Z dZd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 dd	lmZmZmZmZmZmZmZmZmZmZ dd
lmZmZmZmZmZmZm Z m!Z!m"Z"m#Z# ddl$m%Z% ddl&m'Z' ddl(m)Z) ddl	m*Z*m+Z+m,Z,m-Z-m.Z. ddl/m0Z0 e
ed dœdd„Z1de
ede2ee2 ee3e2f f ed dœdd„Z4dee2e5f ede2ee2 ee3e2f f eeef dœdd„Z6e% 7¡ Z8G dd„ dƒZ9g d¢Z:dS ) zHImplementation of generic PDF objects (dictionary, number, string, ...).zMathieu Fenniakzbiziqe@mathieu.fenniak.neté    )ÚDictÚListÚOptionalÚTupleÚUnioné   )Ú
StreamTypeÚdeprecate_with_replacement)ÚOutlineFontFlagé   )
ÚBooleanObjectÚByteStringObjectÚFloatObjectÚIndirectObjectÚ
NameObjectÚ
NullObjectÚNumberObjectÚ	PdfObjectÚTextStringObjectÚencode_pdfdocencoding)
ÚArrayObjectÚContentStreamÚDecodedStreamObjectÚDestinationÚDictionaryObjectÚEncodedStreamObjectÚFieldÚStreamObjectÚ
TreeObjectÚread_object)ÚFit)ÚOutlineItem©ÚRectangleObject)Úcreate_string_objectÚdecode_pdfdocencodingÚ
hex_to_rgbÚread_hex_string_from_streamÚread_string_from_stream)ÚViewerPreferences)r   r   )ÚstreamÚreturnc                 C   s   t dddƒ t| ƒS )z,Deprecated, use read_hex_string_from_stream.ÚreadHexStringFromStreamr'   ú4.0.0)r	   r'   )r*   © r.   úS/home/httpd/docs/test/DocsMgr/lib/python3.9/site-packages/pypdf/generic/__init__.pyr,   I   s    ÿr,   N)r*   Úforced_encodingr+   c                 C   s   t dddƒ t| |ƒS )z(Deprecated, use read_string_from_stream.ÚreadStringFromStreamr(   r-   )r	   r(   )r*   r0   r.   r.   r/   r1   S   s    ÿr1   )Ústringr0   r+   c                 C   s   t dddƒ t| |ƒS )z%Deprecated, use create_string_object.ÚcreateStringObjectr$   r-   )r	   r$   )r2   r0   r.   r.   r/   r3   ^   s    r3   c                   @   s8  e Zd ZdZddlmZ ed-eeee	e	e	e	f f e
eeedœdd„ƒZed.e
eeee	e	e	e	f f e
eee
e
ee
 ee
 edœ
dd„ƒZeddddœeeee	e	e	e	f f eee eedœdd„ƒZed/ee	e	f ee	e	f eeee	e	e	e	f f e
ee
 edœdd„ƒZeeee	e	f  edœdd„ƒZed0eeee	e	e	e	f f ee
 edœdd„ƒZeddd œeeee	e	e	e	f f ee
eed!œd"d#„ƒZed1eeee	e	e	e	f f ee
 edœd$d%„ƒZeeee	e	f  edœd&d'„ƒZd(d)lmZ edddefeeee	e	e	e	f f ee ee
 ee eed*œd+d,„ƒZdS )2ÚAnnotationBuilderzá
    The AnnotationBuilder is deprecated.

    Instead, use the annotation classes in pypdf.annotations.

    See `adding PDF annotations <../user/adding-pdf-annotations.html>`_ for
    its usage combined with PdfWriter.
    r   r"   Fr   )ÚrectÚtextÚopenÚflagsr+   c                 C   s(   t dddƒ ddlm} || |||d�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.
        úAnnotationBuilder.textzpypdf.annotations.Textr-   r   )ÚText)r5   r6   r7   r8   )r	   Úannotationsr:   )r5   r6   r7   r8   r:   r.   r.   r/   r6   v   s
    ÿr9   Ú	HelveticaÚ14ptÚ000000Úffffff)
r6   r5   ÚfontÚboldÚitalicÚ	font_sizeÚ
font_colorÚborder_colorÚbackground_colorr+   c	           
      C   s2   t dddƒ ddlm}	 |	| ||||||||d�	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.
                Use ``None`` for no border.
            background_color: Hex-string for the background of the annotation,
                e.g. cdcdcd. Use ``None`` for transparent background.

        Returns:
            A dictionary object representing the annotation.
        úAnnotationBuilder.free_textzpypdf.annotations.FreeTextr-   r   )ÚFreeText)	r6   r5   r@   rA   rB   rC   rD   rF   rE   )r	   r;   rH   )
r6   r5   r@   rA   rB   rC   rD   rE   rF   rH   r.   r.   r/   Ú	free_text‘   s     ÿ÷rG   N)r8   Úparentr7   )r5   r8   rJ   r7   r+   c                 C   s0   t dddƒ ddlm} || ||d�}||_|S )aŽ  
        Add a popup to the document.

        Args:
            rect:
                Specifies the clickable rectangular area as `[xLL, yLL, xUR, yUR]`
            flags:
                1 - invisible, 2 - hidden, 3 - print, 4 - no zoom,
                5 - no rotate, 6 - no view, 7 - read only, 8 - locked,
                9 - toggle no view, 10 - locked contents
            open:
                Whether the popup should be shown directly (default is False).
            parent:
                The contents of the popup. Create this via the AnnotationBuilder.

        Returns:
            A dictionary object representing the annotation.
        úAnnotationBuilder.popupzpypdf.annotations.Popupr-   r   )ÚPopup)r5   r7   rJ   )r	   r;   rL   r8   )r5   r8   rJ   r7   rL   Úpopupr.   r.   r/   rM   Â   s    ÿrK   Ú )Úp1Úp2r5   r6   Ú	title_barr+   c                 C   s*   t dddƒ ddlm} || ||||d�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.
        úAnnotationBuilder.linezpypdf.annotations.Liner-   r   )ÚLine)rO   rP   r5   r6   rQ   )r	   r;   rS   )rO   rP   r5   r6   rQ   rS   r.   r.   r/   Úlineæ   s
    ÿrR   )Úverticesr+   c                 C   s"   t dddƒ ddlm} || d�S )zä
        Draw a polyline on the PDF.

        Args:
            vertices: Array specifying the vertices (x, y) coordinates of the poly-line.

        Returns:
            A dictionary object representing the annotation.
        úAnnotationBuilder.polylinezpypdf.annotations.PolyLiner-   r   )ÚPolyLine©rU   )r	   r;   rW   )rU   rW   r.   r.   r/   Úpolyline  s
    ÿrV   )r5   Úinteriour_colorr+   c                 C   s$   t dddƒ ddlm} || |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.
        úAnnotationBuilder.rectanglezpypdf.annotations.Rectangler-   r   )Ú	Rectangle©r5   rZ   )r	   r;   r\   )r5   rZ   r\   r.   r.   r/   Ú	rectangle  s
    ÿr[   Úff0000)Úhighlight_colorÚprinting)r5   Úquad_pointsr`   ra   r+   c                 C   s(   t dddƒ ddlm} || |||d�S )aR  
        Add a highlight annotation to the document.

        Args:
            rect: Array of four integers ``[xLL, yLL, xUR, yUR]``
                specifying the highlighted area
            quad_points: An ArrayObject of 8 FloatObjects. Must match a word or
                a group of words, otherwise no highlight will be shown.
            highlight_color: The color used for the highlight.
            printing: Whether to print out the highlight annotation when the page
                is printed.

        Returns:
            A dictionary object representing the annotation.
        úAnnotationBuilder.highlightzpypdf.annotations.Highlightr-   r   )Ú	Highlight)r5   rb   r`   ra   )r	   r;   rd   )r5   rb   r`   ra   rd   r.   r.   r/   Ú	highlight2  s    ÿÿrc   c                 C   s$   t dddƒ ddlm} || |d�S )aÛ  
        Draw an ellipse 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.
        úAnnotationBuilder.ellipsezpypdf.annotations.Ellipser-   r   )ÚEllipser]   )r	   r;   rg   )r5   rZ   rg   r.   r.   r/   ÚellipseR  s
    ÿrf   c                 C   s"   t dddƒ ddlm} || d�S )NúAnnotationBuilder.polygonzpypdf.annotations.Polygonr-   r   )ÚPolygonrX   )r	   r;   rj   )rU   rj   r.   r.   r/   Úpolygonl  s
    ÿri   r   )ÚDEFAULT_FIT)r5   ÚborderÚurlÚtarget_page_indexÚfitr+   c                 C   s*   t dddƒ ddlm} || ||||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.
        úAnnotationBuilder.linkzpypdf.annotations.Linkr-   r   )ÚLink)r5   rm   rn   ro   rp   )r	   r;   rr   )r5   rm   rn   ro   rp   rr   r.   r.   r/   Úlinkw  s    "ÿûrq   )Fr   )r<   FFr=   r>   r>   r?   )rN   N)N)N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Zgeneric._rectangler#   Ústaticmethodr   r   ÚfloatÚstrÚboolÚintr   r6   r   rI   rM   rT   r   rY   r^   r   re   rh   rk   Ú_fitrl   r    rs   r.   r.   r.   r/   r4   j   sÄ   	  üû       ÷ö0ûú#  û

úþ þýûú þýûúr4   ) r   r   r   r   r   r   r   r   r   r4   r    ÚPAGE_FITr   r   r   r   r   r   r   r#   r   r   r)   r!   r
   r   r$   r   r%   r&   r'   r(   )N)N);rw   Ú
__author__Ú__author_email__Útypingr   r   r   r   r   Ú_utilsr   r	   Ú	constantsr
   Ú_baser   r   r   r   r   r   r   r   r   r   Z_data_structuresr   r   r   r   r   r   r   r   r   r   r}   r    Z_outliner!   Z
_rectangler#   r$   r%   r&   r'   r(   Z_viewerprefr)   r,   rz   r|   r1   Úbytesr3   rp   r~   r4   Ú__all__r.   r.   r.   r/   Ú<module>   s@   00þ þý þ

ý	  ?