
    WwgLz                     @   d 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	m
Z
mZ ddlZddl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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" ddl#m$Z$m%Z%m&Z& ddl'm(Z(m)Z) g dZ* G d d      Z+dejX                  fdZ- ed       G d de             Z. ed       G d de.             Z/ ed       G d de.             Z0 G d dejb                        Z2d Z3	  ed       G d! d"e0             Z4 G d# d$ejX                        Z5 G d% d&e5      Z6 G d' d(e5      Z7 G d) d*e7      Z8d+e9d,e9d-e0d.e:d/e:d0e:fd1Z;	 d9d+e9d,e9d-e0d.e:d/e:d0e:fd2Z<	 d9d+e9d,e9d-e4d.e:d/e:d0e:d3e9fd4Z= ej|                   ej~                  d5d56      d78      Z@y):a  
Utilities for stamping PDF files.

Here 'stamping' loosely refers to adding small overlays (QR codes, text boxes,
etc.) on top of already existing content in PDF files.

The code in this module is also used by the :mod:`.sign` module to render
signature appearances.
    N)hexlify)	dataclass)datetime)ListOptionalTuple)ConfigurableMixin)ConfigurationError)contentgenericlayout)IndirectObjectpdf_name
pdf_string)IncrementalPdfFileWriter)LayoutError)rd)PdfFancyQRImagePdfStreamQRImage)DEFAULT_BOX_LAYOUTTextBoxTextBoxStyle)BasePdfFileWriterinit_xobject_dictionary)AnnotAppearancesBaseStampStyleTextStampStyleQRStampStyleStaticStampStyle
QRPosition	BaseStamp	TextStampQRStampStaticContentStamptext_stamp_fileqr_stamp_fileSTAMP_ART_CONTENTc                       e Zd ZdZ	 	 d	dej
                  deej
                     deej
                     fdZdej                  fdZ	y)
r   up  
    Convenience abstraction to set up an appearance dictionary for a PDF
    annotation.

    Annotations can have three appearance streams, which can be roughly
    characterised as follows:

    * *normal*: the only required one, and the default one;
    * *rollover*: used when mousing over the annotation;
    * *down*: used when clicking the annotation.

    These are given as references to form XObjects.

    .. note::
        This class only covers the simple case of an appearance dictionary
        for an annotation with only one appearance state.

    See § 12.5.5 in ISO 32000-1 for further information.
    Nnormalrolloverdownc                 .    || _         || _        || _        y N)r)   r*   r+   )selfr)   r*   r+   s       D/var/www/horilla/myenv/lib/python3.12/site-packages/pyhanko/stamp.py__init__zAnnotAppearances.__init__F   s      	    returnc                     t        j                  t        d      | j                  i      }| j                  | j                  |t        d      <   | j
                  | j
                  |t        d      <   |S )a  
        Convert the :class:`.AnnotationAppearances` instance to a PDF
        dictionary.

        :return:
            A :class:`~.pdf_utils.generic.DictionaryObject` that can be plugged
            into the ``/AP`` entry of an annotation dictionary.
        z/Nz/Rz/D)r   DictionaryObjectr   r)   r*   r+   )r.   ress     r/   as_pdf_objectzAnnotAppearances.as_pdf_objectP   s^     &&'DE==$"&--C99 "&))C
r1   NN)
__name__
__module____qualname____doc__r   r   r   r0   r4   r6    r1   r/   r   r   1   s^    . 6:15	&& 7112 w--.	w77 r1   r   r2   c                     t        | t              st        d      | dk(  rt        S | j	                  d      rt        j                  |       S ddlm} ddl	m
} |j                  |       } ||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       r/   _get_background_contentrK   b   sh    gs# !LMM +  			&	!&&w//5jj!D))r1   T)frozenc                   p    e Zd ZU dZdZeed<   	 dZee	j                     ed<   	  ej                  ej                  j                  ej                  j                  ej                  j!                  d            Zej                  ed<   	 d	Zeed
<   	 e fd       Zdedej.                  deddfdZ xZS )r   z&
    Base class for stamp styles.
       border_widthN
background   )x_aligny_alignmarginsbackground_layoutg333333?background_opacityc                 t    t         |   |       d}	 |d   }|t        |      |d<   yy# t        $ r Y w xY w)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`.
        NrP   )superprocess_entriesKeyErrorrK   )clsconfig_dictrI   	__class__s      r/   rY   zBaseStampStyle.process_entries   sV     	,	!,/G (?(HK%   		s   + 	77rA   boxtext_paramsr2   r!   c                     t         r-   NotImplementedErrorr.   rA   r^   r_   s       r/   create_stampzBaseStampStyle.create_stamp   s
     "!r1   )r8   r9   r:   r;   rO   int__annotations__rP   r   r   
PdfContentr   SimpleBoxLayoutRuleAxisAlignment	ALIGN_MIDMarginsuniformrU   rV   floatclassmethodrY   r   BoxConstraintsdictrd   __classcell__r]   s   @r/   r   r   v   s     L# 04J++,3
 5OF4N4N$$..$$..&&q)5v11 
 !$#
 I I&"!" """ 	"
 
"r1   r   c                   f    e Zd ZU dZdZeed<   	 e	 d	 dd       Zde	de
j                  dedd	fd
Zy)r   za
    Stamp style that does not include any custom parts; it only renders
    the background.
    g      ?rV   r2   c                 F    t        ddt        j                  ||      i|S )a  
        Create a :class:`StaticStampStyle` from a page from an external PDF
        document. This is a convenience wrapper around
        :class:`~content.ImportedPdfContent`.

        The remaining keyword arguments are passed to
        :class:`StaticStampStyle`'s init method.

        :param file_name:
            File name of the external PDF document.
        :param page_ix:
            Page index to import. The default is ``0``, i.e. the first page.
        rP   )page_ixr<   )r   r   rE   )r[   	file_nameru   kwargss       r/   from_pdf_filezStaticStampStyle.from_pdf_file   s.    "   
..y'J

 	
r1   rA   r^   r_   r$   c                     t        || |      S )N)rA   styler^   )r$   rc   s       r/   rd   zStaticStampStyle.create_stamp   s     "tEEr1   N)r   )r2   r   )r8   r9   r:   r;   rV   rm   rf   rn   rx   r   r   ro   rp   rd   r<   r1   r/   r   r      sn    
 !$#
  !
	
 
*F!F ""F 	F
 
Fr1   r   c                       e Zd ZU dZ e       Zeed<   	 dZee	j                     ed<   	 dZeed<   	 dZeed<   	 d	ed
e	j                  deddfdZy)r   z
    Style for text-based stamps.

    Roughly speaking, this stamp type renders some predefined (but parametrised)
    piece of text inside a text box, and possibly applies a background to it.
    text_box_styleNinner_content_layoutz%(ts)s
stamp_textz%Y-%m-%d %H:%M:%S %Ztimestamp_formatrA   r^   r_   r2   r"   c                      t        || ||      S )N)rA   rz   r^   r_   )r"   rc   s       r/   rd   zTextStampStyle.create_stamp
  s     3K
 	
r1   )r8   r9   r:   r;   r   r|   rf   r}   r   r   rh   r~   rC   r   r   ro   rp   rd   r<   r1   r/   r   r      s     $0>NL1 BF(6#=#=>E J 3c2
!
 ""
 	

 

r1   r   c                      e Zd ZdZ ej
                  ej                  j                  ej                  j                        Z	 ej
                  ej                  j                  ej                  j                        Z ej
                  ej                  j                  ej                  j                        Z ej
                  ej                  j                  ej                  j                        Zed        Zedd       Zy)r    z[
    QR positioning constants, with the corresponding default content layout
    rule.
    )rR   rS   )rS   rR   c                 F    | t         j                  t         j                  fv S r-   )r    LEFT_OF_TEXTRIGHT_OF_TEXTr.   s    r/   horizontal_flowzQRPosition.horizontal_flow,  s    
//1I1IJJJr1   c                     	 t         j                  t         j                  t         j                  t         j                  d|j                            S # t        $ r t        d| d      w xY w)a  
        Convert from a configuration string.

        :param config_str:
            A string: 'left', 'right', 'top', 'bottom'
        :return:
            An :class:`.QRPosition` value.
        :raise ConfigurationError: on unexpected string inputs.
        leftrighttopbottom'zW' is not a valid QR position setting; valid values are 'left', 'right', 'top', 'bottom')r    r   r   
ABOVE_TEXT
BELOW_TEXTlowerrZ   r
   )r[   
config_strs     r/   from_configzQRPosition.from_config0  sw    	"//#11!,,$//	
  " "  	$J<  > ? 	s   AA A+N)r2   r    )r8   r9   r:   r;   r   rh   ri   	ALIGN_MINrj   r   	ALIGN_MAXr   r   r   propertyr   rn   r   r<   r1   r/   r    r      s    
 .6--$$..$$..L /F..$$..$$..M ,++$$..$$..J ,++$$..$$..J
 K K  r1   r    g?c                        e Zd ZU dZdZeed<   	 dZeed<   	 dZ	e
e   ed<   	 ej                  Zeed<   	 dZe
ej                      ed	<   	 e fd
       Zdedej*                  deddfdZ xZS )r   z
    Style for text-based stamps together with a QR code.

    This is exactly the same as a text stamp, except that the text box
    is rendered with a QR code to the left of it.
    rN   innsepz@Digital version available at
this url: %(url)s
Timestamp: %(ts)sr~   Nqr_inner_sizeqr_positionqr_inner_contentc                 ~    t         |   |       	 |d   }t        j                  |      |d<   y # t        $ r Y y w xY w)Nr   )rX   rY   r    r   rZ   )r[   r\   qr_posr]   s      r/   rY   zQRStampStyle.process_entries  sF    ,	 /F)3)?)?)GK& 		s   0 	<<rA   r^   r_   r2   r#   c                     	 |j                  d      }t	        || |||      S # t        $ r t        j                  d      w xY w)Nurlz7Using a QR stamp style requires a 'url' text parameter.)rz   r   r_   r^   )poprZ   r   r   r#   )r.   rA   r^   r_   r   s        r/   rd   zQRStampStyle.create_stamp  sV    	//%(C
 $C[c
 	
	  	$$I 	s	   # A)r8   r9   r:   r;   r   re   rf   r~   rC   r   r   r    r   r   r   r   rg   rn   rY   r   r   ro   rp   rd   rq   rr   s   @r/   r   r   R  s     FCO
	  
 $(M8C=' )55K5 6:hw1129  
!
 ""
 	

 

r1   r   c                        e Zd Z	 ddedeej                     f fdZd Zd Z	d Z
dej                  fdZd	ed
edefdZdefdZ xZS )r!   rA   r^   c                 R    t         |   ||       || _        d| _        d | _        y )N)r^   rA   F)rX   r0   rz   _resources_ready
_stamp_refr.   rA   rz   r^   r]   s       r/   r0   zBaseStamp.__init__  s-     	S0
 %48r1   c                 d   | j                   j                  }|j                  | j                         |j	                         }|j
                  }|j                  rR|j                  rF| j                   j                  j                  | j
                  |j                  |j                        }nM| j                   j                  j                  }t        j                  dd|j                  |j                         }t#        j$                  | j                   j&                        }| j)                  t*        j,                  j.                  t1        d      t#        j2                  t1        d      |t1        d      |i             d|j5                         |fz  }| j7                  |j8                         |S )N   )x_scaley_scalex_posy_posz/BackgroundGSz/CAz/cacategorynamevalues   q /BackgroundGS gs %s %s Q)rz   rP   
set_writerrA   renderr^   width_definedheight_definedrU   fitwidthheightrT   r   Positioningr   r   r   FloatObjectrV   set_resourcer   ResourceTypeEXT_G_STATEr   r4   as_cmimport_resources	resources)r.   bg
bg_contentbg_boxpositioningrT   opacitycommands           r/   _render_backgroundzBaseStamp._render_background  sL   ZZ""
dkk"YY[
F$9$9**66::&,,K jj22::G ,,1GLLK
 %%djj&C&CD))55/***%'8E?GD 	 	
 03
 
 	bll+r1   c                     t         r-   ra   r   s    r/   _render_inner_contentzBaseStamp._render_inner_content  s    !!r1   c                    dg}| j                         }| j                  j                  r|j                  | j	                                |r|j                  |       | j                  }| j                  j                  }|r+|j                  d||j                  |j                  fz         |j                  d       dj                  |      S )N   qs   %g w 0 0 %g %g re S   Q    )r   rz   rP   appendr   extendr^   rO   r   r   join)r.   command_streaminner_contentbboxrO   s        r/   r   zBaseStamp.render  s    224
 ::  !!$"9"9";< !!-0 xxzz..!!&,

DKK)PP 	d#yy((r1   r2   c                     | j                   }|4| j                  }| j                         }|j                  |      x| _         }|S )a  
        Register the stamp with the writer coupled to this instance, and
        cache the returned reference.

        This works by calling :meth:`.PdfContent.as_form_xobject`.

        :return:
            An indirect reference to the form XObject containing the stamp.
        )r   _ensure_writeras_form_xobject
add_object)r.   	stamp_refwr	form_xobjs       r/   registerzBaseStamp.register  sG     OO	$$B,,.I*,--	*BBDOir1   	dest_pagexyc           
      4   | j                         }dt        t        j                         j                        z   }dt        |      t        |      |fz  }t        j                  |      }t        j                  t        d      t        j                  t        |j                  d            |i      i      }| j                  }	|	J |	j                  ||	j                  |      |      }
| 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.
        :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ascii)r   r   uuiduuid4bytesr   r   StreamObjectr4   r   decoderA   add_stream_to_pager   r^   r   r   )r.   r   r   r   r   resource_namestamp_paintstamp_wrapper_streamr   r   page_refdimss               r/   applyzBaseStamp.apply  s      MMO	!GDJJL,>,>$??3qEqE7
 

  '33L,,$g&>&>m227;<iH'
	 [[~~((r}}%9:I
 0~r1   c                 :    | j                         }t        |      S )a  
        Turn this stamp into an appearance dictionary for an annotation
        (or a form field widget), after rendering it.
        Only the normal appearance will be defined.

        :return:
            An instance of :class:`.AnnotAppearances`.
        )r)   )r   r   )r.   r   s     r/   as_appearanceszBaseStamp.as_appearances"  s     MMO	y11r1   r-   )r8   r9   r:   r   r   r   ro   r0   r   r   r   r   r   r   re   r   r   r   rq   rr   s   @r/   r!   r!     st    
 04		9!	9 f++,		9%N")2'00 "%s %s %s %N2 0 2r1   r!   c                   J     e Zd ZdZdededej                  f fdZd Z	 xZ
S )r$   z.Class representing stamps with static content.rA   rz   r^   c                     |r|j                   r|j                  st        j                  d      t        |   |||       y )Nz9StaticContentStamp requires a predetermined bounding box.r^   rz   rA   )r   r   r   r   rX   r0   r   s       r/   r0   zStaticContentStamp.__init__4  sD     **s/@/@$$K  	Sf=r1   c                     g S r-   r<   r   s    r/   r   z(StaticContentStamp._render_inner_content@  s    	r1   )r8   r9   r:   r;   r   r   r   ro   r0   r   rq   rr   s   @r/   r$   r$   1  s2    8
>!
>  
> ""	
>r1   r$   c                   j     e Zd ZdZ	 	 d
dedeej                     f fdZd Z	d Z
d Zd Zd	 Z xZS )r"   zf
    Class that renders a text stamp as specified by an instance
    of :class:`.TextStampStyle`.
    rA   r^   c                 F    t         |   |||       || _        d | _        y )Nr   )rX   r0   r_   text_box)r.   rA   rz   r_   r^   r]   s        r/   r0   zTextStamp.__init__J  s(     	Sf=&+/r1   c                     t        j                  t        j                               }d|j	                  | j
                  j                        iS )aQ  
        Compute values for the default string interpolation parameters
        to be applied to the template string specified in the stamp
        style. This method does not take into account the ``text_params``
        init parameter yet.

        :return:
            A dictionary containing the parameters and their values.
        )tzts)r   nowtzlocalget_localzonestrftimerz   r   )r.   r   s     r/   get_default_text_paramsz!TextStamp.get_default_text_paramsV  s=     \\W2245"++djj99:
 	
r1   c                    t        | j                  j                  | j                  | j                  d       x| _        }| j                         }| j                  |j                  | j                         	 | j                  j                  |z  }||_        |j                         S # t        $ r!}t        d|j                  d    d      d }~ww xY w)N)rA   r   r^   zStamp text parameter 'r   z' is missing)r   rz   r|   rA   r   r   r   r_   updater~   rZ   r   argsr   r   )r.   tb_text_paramstextes        r/   _text_layoutzTextStamp._text_layoute  s    $JJ%%;;nn	
 	
 335' 0 01	P::((<7D 
 yy{  	P 6qvvaykNOO	Ps   7B' '	C0CCc                     | j                         }| j                  j                  }|g|j                  |j                  ffS r-   )r  r   r^   r   r   )r.   text_commandsinn_boxs      r/   _inner_layout_natural_sizez$TextStamp._inner_layout_natural_sizez  s9    ))+--## ???r1   c                 >    | j                   j                  xs t        S r-   )rz   r}   r   r   s    r/   _inner_content_layout_rulez$TextStamp._inner_content_layout_rule  s    zz..D2DDr1   c                    dg}| j                         \  }\  }}| j                         }| j                  }|j                  |||      }|j	                  |j                                |j                  |       |j	                  d       |S )Nr   r   )r  r	  r^   r   r   r   r   )r.   r   inn_commands	inn_width
inn_heightinner_layoutr   inn_positions           r/   r   zTextStamp._render_inner_content  s     ++-	
 
 668xx $''iDl0023l+d#r1   r7   )r8   r9   r:   r;   r   r   r   ro   r0   r   r  r  r	  r   rq   rr   s   @r/   r"   r"   D  sM     /3
0!
0
 f++,
0
*@Er1   r"   c            
            e Zd Z	 	 ddedededeej                     f fdZ	d Z
deee   eeef   f   f fdZd	 Z fd
Z fdZ xZS )r#   rA   r   rz   r^   c                 H    t         |   ||||       || _        d | _        y )N)r_   r^   )rX   r0   r   _qr_size)r.   rA   r   rz   r_   r^   r]   s         r/   r0   zQRStamp.__init__  s)     	KSIr1   c                 v    | j                   }|j                  |j                  S |j                  j                  S r-   )rz   r}   r   r   )r.   rz   s     r/   r	  z"QRStamp._inner_content_layout_rule  s7    

%%1---   &&&r1   r2   c                    t         |          \  }\  }}| j                         \  }}| j                  t        j
                  j                  t        d      |       | j                  }| j                  }|j                  }|j                  |j                  }	np|j                  rI|j                  r=t        t        |j                   |      t        |j"                  |            }
|
d|z  z
  }	nt%        t'        t(        |z              }	|	|z  }|	d|z  z   }|j*                  j,                  r||z   }t        ||      }nt        ||      }||z   }|j*                  j.                  }t1        j2                  |j4                  |j6                  t0        j8                  j;                  |      t0        j<                  j>                        }t1        j@                  ||      }|jC                  ||	|	      }d|jD                  |z  |jF                  |z  |jH                  |jJ                  fz  }|j*                  tL        jN                  k(  rt1        j8                  |ddd      }n|j*                  tL        jP                  k(  rt1        j8                  |ddd      }nP|j*                  tL        jR                  k(  rt1        j8                  |ddd	      }nt1        j8                  |ddd
      }t1        j2                  |j4                  jT                  |j6                  jT                  |t0        j<                  j>                        }|jC                  |||      }|d|jW                         g}|jY                  |       |j[                  d       |||ffS )Nz/QRr      )rR   rS   rT   inner_content_scalings   q %g 0 0 %g %g %g cm /QR Do Qr   r   )r   r   r   r   )r   r   r   r   )r   r   r   r   r   r   ).rX   r  _qr_xobjectr   r   r   XOBJECTr   rz   r^   r   r   r   r   minmaxr   r   re   roundDEFAULT_QR_SCALEr   r   r   r   rh   rR   rS   rk   rl   InnerScaling
NO_SCALINGro   r   r   r   r   r   r    r   r   r   flippedr   r   r   )r.   r  
text_widthtext_heightqr_refnatural_qr_sizerz   	stamp_boxr   qr_sizemin_dimqr_innunits_scale	qr_paddedr  r  default_layoutqr_layout_rule	inner_box
qr_inn_posdraw_qr_command
tb_marginstb_layout_ruletext_inn_poscommandsr]   s                           r/   r  z"QRStamp._inner_layout_natural_size  sG    G.0	
 
 #'"2"2"4))11% 	 	
 

HH	 *))G$$)A)A I$$k2IOOZ0G F
*G% 0? BCDG#o5a&j(	 ,,!J.IY4JIz2I"[0J5:5F5F5L5L  33"**"**NN**62 #)"5"5"@"@
 )))Z@	#''	7GD
 ;!22!22	>
 
 
 7 77aQqJ *":"::aQqJ *"7"77 qJ  QQqJ  33 #**22"**22"("5"5"@"@
 &)))ZM#T<+=+=+?@&)Z000r1   c                    | j                   j                  d u}|rt        j                  j                  nt        j                  j
                  }t        j                  |      }|j                  | j                         |j                          |r7|j                  t        |j                  | j                   j                        }n|j                  t              }|j                         }|j                  d|j                   z  z   |j"                  z  }t%        |||      }|j'                          | j(                  j+                  |      |fS )N)error_correction)image_factoryversioncenter_image)r4  r  )rz   r   qrcode	constantsERROR_CORRECT_HERROR_CORRECT_MQRCodeadd_datar   make
make_imager   r5  r   render_command_streammodules_countborderbox_sizer   compressrA   r   )r.   is_fancyerr_corrqrrJ   r   	bbox_sizeqr_xobjs           r/   r  zQRStamp._qr_xobject  s   ::..d:  ,,!!11 	
 ]]H5
DHH
	---

!ZZ88   C --.>-?C224%%BII5D	).)YO{{%%g.	99r1   c                 B    t         |          }| j                  |d<   |S )Nr   )rX   r   r   )r.   tpr]   s     r/   r   zQRStamp.get_default_text_params8  s"    W,.HH5		r1   c                 H   t         
|   |||      \  }\  }}||||z   ||z   f}t        j                  t	        d      t	        d      t	        d      t	        d      t	        d      t        j
                  t        t        t        j                  |                  t	        d      t        j                  t	        d      t	        d      t	        d      t        | j                        i      i      }| j                  }	|	j                  ||	j                  |             |||ffS )	Nz/Typez/Annotz/Subtypez/Linkz/Rectz/Az/Sz/URI)rX   r   r   r4   r   ArrayObjectlistmapr   r   r   rA   register_annotationr   )r.   r   r   r   r   wh	link_rect
link_annotr   r]   s             r/   r   zQRStamp.apply=  s     7=Aq9&1a1q5!a%(	--!8H#5$hw&7!7#6#6W00)<=$  8 8 (8 (*TXX*>!

 [[
xz)BC!Qr1   r7   )r8   r9   r:   r   rC   r   r   r   ro   r0   r	  r   r   r   re   r  r  r   r   rq   rr   s   @r/   r#   r#     s     /3
!
 
 	
 f++,
'l1E$u+uS#X2N,O l1\:4
   r1   r#   
input_nameoutput_namerz   r   r   r   c                     t        | d      5 }t        |d      }	 |d|	|d|}
|
j                  |||       t        |d      5 }|	j                  |       d d d        d d d        y # 1 sw Y   xY w# 1 sw Y   y xY w)NrbF)strict)rA   rz   wbr<   )rH   r   r   write)rT  rU  rz   stamp_classr   r   r   stamp_kwargsfinpdf_outstampouts               r/   _stamp_filera  T  s     
j$	 3*3u=H7%H<HIq!$+t$ 	MM#	 
	 	 s#   8A4A(A4(A1	-A44A=c           
      2    t        | ||t        ||||       y)a5  
    Add a text stamp to a file.

    :param input_name:
        Path to the input file.
    :param output_name:
        Path to the output file.
    :param style:
        Text stamp style to use.
    :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 text_params:
        Additional parameters for text template interpolation.
    )r_   N)ra  r"   )rT  rU  rz   r   r   r   r_   s          r/   r%   r%   g  s$    6 			r1   r   c                 4    t        | ||t        |||||	       y)aj  
    Add a QR stamp to a file.

    :param input_name:
        Path to the input file.
    :param output_name:
        Path to the output file.
    :param style:
        QR stamp style to use.
    :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 url:
        URL for the QR code to point to.
    :param text_params:
        Additional parameters for text template interpolation.
    )r   r_   N)ra  r#   )rT  rU  rz   r   r   r   r   r_   s           r/   r&   r&     s'    > 		
r1   d   )r   r   s  
q 1 0 0 -1 0 100 cm 
0.603922 0.345098 0.54902 rg
3.699 65.215 m 3.699 65.215 2.375 57.277 7.668 51.984 c 12.957 46.695 27.512
 49.34 39.418 41.402 c 39.418 41.402 31.48 40.078 32.801 33.465 c 34.125
 26.852 39.418 28.172 39.418 24.203 c 39.418 20.234 30.156 17.59 30.156
14.945 c 30.156 12.297 28.465 1.715 50 1.715 c 71.535 1.715 69.844 12.297
 69.844 14.945 c 69.844 17.59 60.582 20.234 60.582 24.203 c 60.582 28.172
 65.875 26.852 67.199 33.465 c 68.52 40.078 60.582 41.402 60.582 41.402
c 72.488 49.34 87.043 46.695 92.332 51.984 c 97.625 57.277 96.301 65.215
 96.301 65.215 c h f
3.801 68.734 92.398 7.391 re f
3.801 79.512 92.398 7.391 re f
3.801 90.289 92.398 7.391 re f
Q
)r^   datar-   )Ar;   enumr   binasciir   dataclassesr   r   typingr   r   r   r7  r   pyhanko.config.apir	   pyhanko.config.errorsr
   pyhanko.pdf_utilsr   r   r   pyhanko.pdf_utils.genericr   r   r   $pyhanko.pdf_utils.incremental_writerr   pyhanko.pdf_utils.layoutr   pyhanko.pdf_utils.miscr   pyhanko.pdf_utils.qrr   r   pyhanko.pdf_utils.textr   r   r   pyhanko.pdf_utils.writerr   r   __all__r   rg   rK   r   r   r   Enumr    r  r   r!   r$   r"   r#   rC   re   ra  r%   r&   
RawContentro   r'   r<   r1   r/   <module>rw     sX      !  ( (   0 4 6 6 J J I 0 % B L L O". .b*(:(: *( $="& =" ="@ $(F~ (F (FV $.
^ .
 .
b1 1h   $E
> E
 E
PS2"" S2l &T	 Tnv i v r 
   4 $$$ $ 	$
 $ $^ ))) ) 	)
 ) ) 
)X 'G&&C4
 &r1   