
    Wwgo                         	 d dl Z d dlmZmZ d dlmZ d dlm	Z	 d dl
mZ ddgZd	efd
ZdZd Z G d de      Z G d de      Zy# e$ rZ ede      dZ[ww xY w)    N)
BaseWritermm2pxzpyhanko.pdf_utils.barcodes requires pyHanko to be installed with the [image-support] option. You can install missing dependencies by running "pip install 'pyHanko[image-support]'".)
PdfContent)BoxConstraints)rd
BarcodeBoxPdfStreamBarcodeWriterreturnc                     | dk(  rdS dS )Nwhites   1 1 1s   0 0 0 )colours    Q/var/www/horilla/myenv/lib/python3.12/site-packages/pyhanko/pdf_utils/barcodes.pybarcode_colour_to_pdfr      s     (86h6    H   c                 ,    t        | dz  t        z        S )Ngffffff9@)r   PDF_UUPI)mm_lens    r   mm2uur   !   s    v}())r   c                   J    e Zd ZdZd Zd Zd ZdefdZe	defd       Z
d Zy	)
r	   z
    Implementation of writer class for the python-barcode library to output
    PDF graphics operators.
    Note: _paint_text is intentionally dummied out.
    Please use the functionality implemented in pyhanko.pdf_utils.text instead.
    c                     d }t        j                  | | j                  | j                  || j                         d | _        y )Nc                       y Nr   )_args_kwargss     r   dummyz.PdfStreamBarcodeWriter.__init__.<locals>.dummy.   s    r   )r   __init___init_paint_module_finish_command_stream)selfr   s     r   r   zPdfStreamBarcodeWriter.__init__-   s:    	 	$**d00%	
  $r   c                     | j                  t        |d         t        |            \  }}t        t        |t                    t        t        |t                    f| _        dg| _        y )Nr      q)calculate_sizelenintr   r   sizer"   )r#   codewidthheights       r   r   zPdfStreamBarcodeWriter._init9   sR    ++CQL#d)Dvuh/0#eFH6M2NO	 $vr   c           
          | j                   j                  dt        |      t        |      t        |      t        |      t        | j                        fz         y )Ns   %s rg %g %g %g %g re f)r"   appendr   r   module_height)r#   xposyposr+   colors        r   r    z$PdfStreamBarcodeWriter._paint_module>   sN    ##%%e,dded(()		
r   r
   c                 P    | j                   j                  d       | j                  S )N   Q)r"   r.   command_streamr#   s    r   r!   zPdfStreamBarcodeWriter._finishJ   s"    ##D)"""r   c                 8    dj                  | j                        S )N   
)joinr"   r6   s    r   r5   z%PdfStreamBarcodeWriter.command_streamN   s    zz$..//r   c                      y r   r   )r#   filenameoutputs      r   savezPdfStreamBarcodeWriter.saveS   s    r   N)__name__
__module____qualname____doc__r   r   r    bytesr!   propertyr5   r=   r   r   r   r	   r	   %   sB    
$&


# # 0 0 0r   c                   .     e Zd ZdZ fdZdefdZ xZS )r   z
    Thin wrapper around python-barcode functionality.

    This will render a barcode of the specified type as PDF graphics operators.
    c                     || _         || _        t               }t        j                  | j                   ||      }|j                         | _        |j                  \  }}t        | %  t        ||             y )N)r*   writer)r+   r,   )box)barcode_typer*   r	   barcodeget_barcoderender_barcode_commandsr)   superr   r   )r#   rH   r*   rF   bwh	__class__s          r   r   zBarcodeBox.__init__^   sh    (	')
  1 1VL!"A^!A>?r   r
   c                     | j                   S r   )rL   r6   s    r   rK   zBarcodeBox.renderl   s    %%%r   )r>   r?   r@   rA   r   rB   rK   __classcell__)rQ   s   @r   r   r   W   s    @& &r   )rI   barcode.writerr   r   ImportErrorepyhanko.pdf_utils.contentr   pyhanko.pdf_utils.layoutr   pyhanko.pdf_utils.miscr   __all__rB   r   r   r   r	   r   r   r   r   <module>r[      s   
0 1 3 %1
27U 7 */Z /d& &g  
	4 	
 s   A A	AA