§
    ¥”j@!  ã                   ó  — d dl Z d dlmZ d dlmZ d dlmZmZ d dlm	Z	 d dl
mZ d dl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 ddlmZ ddlmZ dej        fd„Z ed¬¦  «         G d„ de	¦  «        ¦   «         Z G d„ de¦  «        ZdS )é    N)Úhexlify)Ú	dataclass)ÚOptionalÚTuple)ÚConfigurableMixin)ÚConfigurationError)ÚcontentÚgenericÚlayout)Úpdf_name)Úrd)ÚBasePdfFileWriteré   )ÚAppearanceContenté   )ÚCoordinateSystem)ÚSTAMP_ART_CONTENTÚreturnc                 ó  — t          | t          ¦  «        st          d¦  «        ‚| dk    rt          S |                      d¦  «        rt          j        | ¦  «        S ddlm} ddl	m
} |                     | ¦  «        } ||d ¬¦  «        S )Nz)Background specification must be a stringÚ	__stamp__z.pdfr   )ÚImage)ÚPdfImage)Úwriter)Ú
isinstanceÚstrr   r   Úendswithr	   ÚImportedPdfPageÚPILr   Úpyhanko.pdf_utils.imagesr   Úopen)Úbg_specr   r   Úimgs       úa/var/www/finuniver-perm.ru/html/portfolio/venv/lib/python3.11/site-packages/pyhanko/stamp/base.pyÚ_get_background_contentr$      s¨   € Ý�g�sÑ#Ô#ð NÝ Ð!LÑMÔMÐMð �+ÒÐÝ Ð Ø	×	Ò	˜&Ñ	!Ô	!ð 	*åÔ& wÑ/Ô/Ð/àÐÐÐÐÐØ5Ð5Ð5Ð5Ð5Ð5à�jŠj˜Ñ!Ô!ˆàˆx˜ DÐ)Ñ)Ô)Ð)ó    T)Úfrozenc            	       ój  ‡ — e Zd ZU dZdZeed<   	 dZee	e
e
e
f                  ed<   	 dZeej                 ed<   	  ej        ej        j        ej        j        ej                             d¦  «        ¬¦  «        Zej        ed	<   	 d
Ze
ed<   	 eˆ fd„¦   «         Zdedej        deded         fd„Zˆ xZS )ÚBaseStampStylez&
    Base class for stamp styles.
    é   Úborder_widthNÚborder_colorÚ
backgroundé   )Úx_alignÚy_alignÚmarginsÚbackground_layoutg333333ã?Úbackground_opacityc                 ó®   •— t          ¦   «                              |¦  «         d}	 |d         }n# t          $ r Y nw xY w|�t          |¦  «        |d<   dS dS )a‰  
        This implementation of :meth:`process_entries` processes the
        :attr:`background` configuration value.
        This can either be a path to an image file, in which case it will
        be turned into an instance of :class:`~.pdf_utils.images.PdfImage`,
        or the special value ``__stamp__``, which is an alias for
        :const:`~pyhanko.stamp.STAMP_ART_CONTENT`.
        Nr,   )ÚsuperÚprocess_entriesÚKeyErrorr$   )ÚclsÚconfig_dictr!   Ú	__class__s      €r#   r5   zBaseStampStyle.process_entriesQ   sy   ø€ õ 	‰Œ×Ò Ñ,Ô,Ð,Øˆð	Ø! ,Ô/ˆGˆGøÝð 	ð 	ð 	ØˆDð	øøøàÐÝ(?ÀÑ(HÔ(HˆK˜Ñ%Ð%Ð%ð Ðs   ¦/ ¯
<»<r   ÚboxÚtext_paramsr   Ú	BaseStampc                 ó   — t           ‚©N©ÚNotImplementedError)Úselfr   r:   r;   s       r#   Úcreate_stampzBaseStampStyle.create_stampe   s
   € õ "Ð!r%   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r*   ÚintÚ__annotations__r+   r   r   Úfloatr,   r	   Ú
PdfContentr   ÚSimpleBoxLayoutRuleÚAxisAlignmentÚ	ALIGN_MIDÚMarginsÚuniformr1   r2   Úclassmethodr5   r   ÚBoxConstraintsÚdictrB   Ú__classcell__©r9   s   @r#   r(   r(   %   sh  ø€ € € € € € ðð ð €L�#ÐÐÑðð :>€L�(˜5 ¨¨uÐ!4Ô5Ô6Ð=Ð=Ñ=ðð 04€J�˜Ô+Ô,Ð3Ð3Ñ3ðð
 5O°FÔ4NØÔ$Ô.ØÔ$Ô.Ø”×&Ò& qÑ)Ô)ð5ñ 5ô 5Ð�vÔ1ð ð ñ ð
ð !$Ð˜Ð#Ð#Ñ#ðð
 ðIð Ið Ið Iñ „[ðIð&"à!ð"ð Ô"ð"ð ð	"ð
 
�+Ô	ð"ð "ð "ð "ð "ð "ð "ð "r%   r(   c            	       ó|   ‡ — e Zd Z	 ddedeej                 fˆ fd„Zd„ Zd„ Z	d„ Z
ej        dœd	ed
ededefd„Zˆ xZS )r<   Nr   r:   c                 ój   •— t          ¦   «                              ||¬¦  «         || _        d| _        d S )N)r:   r   F)r4   Ú__init__ÚstyleÚ_resources_ready)rA   r   rX   r:   r9   s       €r#   rW   zBaseStamp.__init__o   s7   ø€ õ 	‰Œ×Ò˜S¨ÐÑ0Ô0Ð0ØˆŒ
Ø %ˆÔÐÐr%   c                 óÖ  — | j         j        }|                     | j        ¦  «         |                     ¦   «         }|j        }|j        r8|j        r1| j         j         	                    | j        |j
        |j        ¦  «        }n3| j         j        j        }t          j        dd|j        |j        ¬¦  «        }t#          j        | j         j        ¦  «        }|                      t*          j        j        t1          d¦  «        t#          j        t1          d¦  «        |t1          d¦  «        |i¦  «        ¬¦  «         d|                     ¦   «         |fz  }|                      |j        ¦  «         |S )Nr   )Úx_scaleÚy_scaleÚx_posÚy_posz/BackgroundGSz/CAz/ca)ÚcategoryÚnameÚvalues   q /BackgroundGS gs %s %s Q)rX   r,   Ú
set_writerr   Úrenderr:   Úwidth_definedÚheight_definedr1   ÚfitÚwidthÚheightr0   r   ÚPositioningÚleftÚbottomr
   ÚFloatObjectr2   Úset_resourcer	   ÚResourceTypeÚEXT_G_STATEr   ÚDictionaryObjectÚas_cmÚimport_resourcesÚ	resources)rA   ÚbgÚ
bg_contentÚbg_boxÚpositioningr0   ÚopacityÚcommands           r#   Ú_render_backgroundzBaseStamp._render_backgroundy   sU  € ØŒZÔ"ˆØ
�Š�d”kÑ"Ô"Ð"Ø—Y’Y‘[”[ˆ
à”ˆØÔð 	 FÔ$9ð 	àœ*Ô6×:Ò:Ø”˜&œ,¨¬ñô ˆKˆKð ”jÔ2Ô:ˆGÝ Ô,Ø 1¨G¬LÀÄðñ ô ˆKõ
 Ô% d¤jÔ&CÑDÔDˆØ×ÒÝÔ)Ô5Ý˜/Ñ*Ô*ÝÔ*Ý˜%‘” '­8°E©?¬?¸GÐDñô ð 	ñ 	
ô 	
ð 	
ð 0Ø×ÒÑÔØð3
ñ 
ˆð 	×Ò˜bœlÑ+Ô+Ð+Øˆr%   c                 ó   — t           ‚r>   r?   )rA   s    r#   Ú_render_inner_contentzBaseStamp._render_inner_content    s   € Ý!Ð!r%   c                 óØ  — dg}|                       ¦   «         }| j        j        r'|                     |                      ¦   «         ¦  «         |r|                     |¦  «         | j        }| j        j        }| j        j        }|r?|r|                     d|z  ¦  «         |                     d||j	        |j
        fz  ¦  «         |                     d¦  «         d                     |¦  «        S )Nó   qs   %g %g %g RGs   %g w 0 0 %g %g re Só   Qó    )r|   rX   r,   Úappendrz   Úextendr:   r*   r+   rg   rh   Újoin)rA   Úcommand_streamÚinner_contentÚbboxr*   r+   s         r#   rc   zBaseStamp.render£   s  € Ø˜ˆà×2Ò2Ñ4Ô4ˆð
 Œ:Ô ð 	=Ø×!Ò! $×"9Ò"9Ñ";Ô";Ñ<Ô<Ð<ð ð 	1Ø×!Ò! -Ñ0Ô0Ð0ð ŒxˆØ”zÔ.ˆØ”zÔ.ˆØð 	Øð EØ×%Ò% n°|Ñ&CÑDÔDÐDà×!Ò!Ø&Ø ¤¨T¬[Ð9ñ:ñô ð ð
 	×Ò˜dÑ#Ô#Ð#Ø�yŠy˜Ñ(Ô(Ð(r%   )ÚcoordsÚ	dest_pageÚxÚyr‡   c          
      óL  — |                       ¦   «         }dt          t          j        ¦   «         j        ¦  «        z   }dt          |¦  «        t          |¦  «        |fz  }t          j        |¬¦  «        }t          j        t          d¦  «        t          j        t          | 
                    d¦  «        ¦  «        |i¦  «        i¦  «        }	| j        }
|
€J ‚|t          j        k    rz|
                     ||
                     t          j        d¬¦  «        ¦  «        d¬	¦  «         |
                     ||
                     t          j        d
¬¦  «        ¦  «        ¦  «         |
                     ||
                     |¦  «        |	¦  «        }| j        j        | j        j        f}||fS )a   
        Apply a stamp to a particular page in the PDF writer attached to this
        :class:`.BaseStamp` instance.

        :param dest_page:
            Index of the page to which the stamp is to be applied
            (starting at `0`).
        :param x:
            Horizontal position of the stamp's lower left corner on the page.
        :param y:
            Vertical position of the stamp's lower left corner on the page.
        :param coords:
            The coordinate convention to use.
        :return:
            A reference to the affected page object, together with
            a ``(width, height)`` tuple describing the dimensions of the stamp.
        s   /Stamps   q 1 0 0 1 %g %g cm %s Do Q)Ústream_dataz/XObjectÚasciiNr~   T)Úprependr   )Úregisterr   ÚuuidÚuuid4Úbytesr   r
   ÚStreamObjectrp   r   Údecoder   r   ÚPAGE_DEFAULTÚadd_stream_to_pageÚ
add_objectr:   rg   rh   )rA   rˆ   r‰   rŠ   r‡   Ú	stamp_refÚresource_nameÚstamp_paintÚstamp_wrapper_streamrs   ÚwrÚpage_refÚdimss                r#   ÚapplyzBaseStamp.applyÂ   s¥  € ð2 —M’M‘O”Oˆ	Ø!¥G­D¬J©L¬LÔ,>Ñ$?Ô$?Ñ?ˆØ3Ýˆq‰EŒEÝˆq‰EŒEØð7
ñ 
ˆõ
  'Ô3ÀÐLÑLÔLÐÝÔ,å˜Ñ$Ô$¥gÔ&>Ý˜m×2Ò2°7Ñ;Ô;Ñ<Ô<¸iÐHñ'ô 'ðñ
ô 
ˆ	ð Œ[ˆØˆ~ˆ~ˆ~ØÕ%Ô2Ò2Ð2à×!Ò!ØØ—’ÝÔ(°TÐ:Ñ:Ô:ñô ð ð "ñ ô ð ð ×!Ò!ØØ—’ÝÔ(°TÐ:Ñ:Ô:ñô ñô ð ð ×(Ò(Ø�r—}’}Ð%9Ñ:Ô:¸Iñ
ô 
ˆð ”” ¤¤Ð0ˆØ˜ˆ~Ðr%   r>   )rC   rD   rE   r   r   r   rQ   rW   rz   r|   rc   r   r•   rG   rŸ   rS   rT   s   @r#   r<   r<   n   sÜ   ø€ € € € € ð
 04ð	&ð &à!ð&ð �fÔ+Ô,ð	&ð &ð &ð &ð &ð &ð%ð %ð %ðN"ð "ð "ð)ð )ð )ðJ $4Ô#@ð=ð =ð =àð=ð ð=ð ð	=ð !ð=ð =ð =ð =ð =ð =ð =ð =r%   r<   ) r�   Úbinasciir   Údataclassesr   Útypingr   r   Úpyhanko.config.apir   Úpyhanko.config.errorsr   Úpyhanko.pdf_utilsr	   r
   r   Úpyhanko.pdf_utils.genericr   Úpyhanko.pdf_utils.miscr   Úpyhanko.pdf_utils.writerr   Úpdf_utils.contentr   Úappearancesr   Úartr   rJ   r$   r(   r<   © r%   r#   ú<module>r­      s£  ðØ €€€Ø Ð Ð Ð Ð Ð Ø !Ð !Ð !Ð !Ð !Ð !Ø "Ð "Ð "Ð "Ð "Ð "Ð "Ð "à 0Ð 0Ð 0Ð 0Ð 0Ð 0Ø 4Ð 4Ð 4Ð 4Ð 4Ð 4Ø 6Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6Ø .Ð .Ð .Ð .Ð .Ð .Ø %Ð %Ð %Ð %Ð %Ð %Ø 6Ð 6Ð 6Ð 6Ð 6Ð 6à 1Ð 1Ð 1Ð 1Ð 1Ð 1Ø )Ð )Ð )Ð )Ð )Ð )Ø "Ð "Ð "Ð "Ð "Ð "ð*¨Ô(:ð *ð *ð *ð *ð& €�$ÐÑÔðE"ð E"ð E"ð E"ð E"Ð&ñ E"ô E"ñ ÔðE"ðPQð Qð Qð Qð QÐ!ñ Qô Qð Qð Qð Qr%   