o
    >e:                     @   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 de
ded fddZ1	dde
dede2ee2 ee3e2f f ded fddZ4	ddee2e5f dede2ee2 ee3e2f f deeef f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streamreturn)r   r   c                 C   s   t ddd t| S )z,Deprecated, use read_hex_string_from_stream.readHexStringFromStreamr'   4.0.0)r	   r'   )r*    r.   W/var/www/html/humari/django-venv/lib/python3.10/site-packages/pypdf/generic/__init__.pyr,   I   s   r,   Nforced_encodingc                 C      t ddd t| |S )z(Deprecated, use read_string_from_stream.readStringFromStreamr(   r-   )r	   r(   )r*   r0   r.   r.   r/   r2   S   s   
r2   stringc                 C   r1   )z%Deprecated, use create_string_object.createStringObjectr$   r-   )r	   r$   )r3   r0   r.   r.   r/   r4   ^   s   
r4   c                   @   s  e Zd ZdZddlmZ e		d=deeee	e	e	e	f f de
ded	ed
ef
d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e
 dee
 d
efddZedddddeeee	e	e	e	f f d	edee ded
ef
d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e
 d
efd#d$Zed%eee	e	f  d
efd&d'Ze	d@deeee	e	e	e	f f d(ee
 d
efd)d*Zed+d,deeee	e	e	e	f f d-ed.e
d
efd/d0Ze	d@deeee	e	e	e	f f d(ee
 d
efd1d2Zed%eee	e	f  d
efd3d4Zd5d6lmZ edddefdeeee	e	e	e	f f d7ee d8ee
 d9ee d:ed
efd;d<ZdS )AAnnotationBuilderz
    The AnnotationBuilder is deprecated.

    Instead, use the annotation classes in pypdf.annotations.

    See `adding PDF annotations <../user/adding-pdf-annotations.html>`_ for
    it's 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)r6   r7   r8   r9   )r	   annotationsr;   )r6   r7   r8   r9   r;   r.   r.   r/   r7   v   s
   r:   	Helvetica14pt000000fffffffontbolditalic	font_size
font_colorborder_colorbackground_colorc	           
      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)	r7   r6   rA   rB   rC   rD   rE   rG   rF   )r	   r<   rI   )
r7   r6   rA   rB   rC   rD   rE   rF   rG   rI   r.   r.   r/   	free_text   s    rH   N)r9   parentr8   rK   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)r6   r8   rK   )r	   r<   rM   r9   )r6   r9   rK   r8   rM   popupr.   r.   r/   rN      s   rL    p1p2	title_barc                 C   *   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)rP   rQ   r6   r7   rR   )r	   r<   rU   )rP   rQ   r6   r7   rR   rU   r.   r.   r/   line   s
   rT   verticesc                 C   "   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rW   )r	   r<   rZ   )rW   rZ   r.   r.   r/   polyline  s
   
rY   interiour_colorc                 C   $   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r6   r]   )r	   r<   r`   )r6   r]   r`   r.   r.   r/   	rectangle  
   r_   ff0000)highlight_colorquad_pointsre   c                 C   s&   t ddd ddlm} || ||dS )a  
        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 hightlight

        Returns:
            A dictionary object representing the annotation.
        AnnotationBuilder.highlightzpypdf.annotations.Highlightr-   r   )	Highlight)r6   rf   re   )r	   r<   rh   )r6   rf   re   rh   r.   r.   r/   	highlight2  s   rg   c                 C   r^   )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.
        AnnotationBuilder.ellipsezpypdf.annotations.Ellipser-   r   )Ellipsera   )r	   r<   rk   )r6   r]   rk   r.   r.   r/   ellipseO  rc   rj   c                 C   rX   )NAnnotationBuilder.polygonzpypdf.annotations.Polygonr-   r   )Polygonr[   )r	   r<   rn   )rW   rn   r.   r.   r/   polygoni  s
   
rm   r   )DEFAULT_FITborderurltarget_page_indexfitc                 C   rS   )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)r6   rq   rr   rs   rt   )r	   r<   rv   )r6   rq   rr   rs   rt   rv   r.   r.   r/   linkt  s   "ru   )Fr   )r=   FFr>   r?   r?   r@   )rO   NN)__name__
__module____qualname____doc__generic._rectangler#   staticmethodr   r   floatstrboolintr   r7   r   rJ   rN   rV   r   r\   rb   r   ri   rl   ro   _fitrp   r    rw   r.   r.   r.   r/   r5   j   s
   		
0#

 r5   ) r   r   r   r   r   r   r   r   r   r5   r    PAGE_FITr   r   r   r   r   r   r   r#   r   r   r)   r!   r
   r   r$   r   r%   r&   r'   r(   rx   );r|   
__author____author_email__typingr   r   r   r   r   _utilsr   r	   	constantsr
   _baser   r   r   r   r   r   r   r   r   r   _data_structuresr   r   r   r   r   r   r   r   r   r   r   r    _outliner!   
_rectangler#   r$   r%   r&   r'   r(   _viewerprefr)   r,   r   r   r2   bytesr4   rt   r   r5   __all__r.   r.   r.   r/   <module>   sN   00




	  <