%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/reportlab/pdfgen/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/reportlab/pdfgen/__pycache__/canvas.cpython-312.pyc

�

C��emC����dZdZddgZdZddlZddlZddlmZddlm	Z	m
Z
mZmZdd	l
mZdd
lmZddlmZddlmZdd
lmZmZddlmZmZmZmZmZddlmZmZm Z m!Z!m"Z"m#Z#ddl$m%Z%m&Z&ddl'm(Z(ejRd�Z*dZ+dZ,dde+fddde,fddde+fddde,fddde+fddde,fddde+fddde,fdiZ-d$d�Z.d�Z/d�Z0d�Z1Gd�d�Z2d�Z3Gd �d�Z4Gd!�de�Z5e6d"k(r	e7d#�yy)%z3.3.0zz
The Canvas object is the primary interface for creating PDF files. See
doc/reportlab-userguide.pdf for copious examples.
�Canvas�ShowBoundaryValue��N)�digits)�sin�cos�tan�pi)�	rl_config)�pdfdoc)�
pdfmetrics)�
pathobject)�
PDFTextObject�_PDFColorSetter)�black�_chooseEnforceColorSpace�Color�	CMYKColor�toColor)�ImageReader�isSeq�isStr�	isUnicode�	_digester�	asUnicode)�fp_str�	escapePDF)�aspectRatioFixz\d�n�Szf*�fzB*�Bc���ddlm}|r0d|vr,||j|j|jg�|d<d|vr.|||xsdg}|r|j||��||�|d<yy)Nr)�PDFArray�C�Border)�reportlab.pdfbase.pdfdocr$�red�green�blue�append)�D�color�	thickness�	dashArray�hradius�vradiusr$�borders        �9/usr/lib/python3/dist-packages/reportlab/pdfgen/canvas.py�
_annFormatr44sn��1���A���5�9�9�e�k�k�5�:�:�>�?��#���q���'�)�.�q�1����M�M�(�9�-�.��v�&��(��	�c���t|t�r0|j�dt�fd�|j	�D��fSt|t
�rd|j
�fSt|ttf�rt|�}|dk(rd|fS|dk(r(d|fSt|t�rtt|��Std|z��)N�
DeviceCMYKc3�(�K�|]	}|�z���y�w�N�)�.0�c�ds  �r3�	<genexpr>z"_normalizeColor.<locals>.<genexpr>Js�����">�1�1�Q�3�">�s��	DeviceRGB��zUnknown color %r)
�
isinstancer�density�tuple�cmykr�rgb�list�len�str�_normalizeColorr�
ValueError)�aColor�lr=s  @r3rJrJGs�����&�)�$��N�N���U�">����
�">�>�>�>�	�F�E�	"��F�J�J�L�(�(�	�F�U�D�M�	*���K����6���&�&�
�!�V���'�'�	�F�C�	 ��w�v��/�/�
�'�&�0�
1�1r5c��d}g}|D];}t|�\}}|�||k7rtd|�d|����|}|j|��=||fS)NzMismatch in color spaces: z and )rJrKr+)�colors�space�	outcolorsrL�nspace�outcolors      r3�_normalizeColorsrTWsf���E��I��#��*�6�2�������&���e�V�T�U�U�������"�#��)��r5c�`�ddlm}m}|�"t|�t|�k7rt	d��t|�dk(r|d|d|d��St|�dk(r#|�|ddk(r|ddk(r|d|d|d��S|�3t|�}t|�D�cgc]}t
|�|dz
z��}}n�tt||��}|jd���|dddk7r|jdd	|ddf�|d
ddk7r|jd|d
df�tt|��\}}g}|dd
D�cgc]}|��}	}g}
|d}|ddD]@}|j|d||���|}|
jd	�|
jd��B|||	|
d�
�Scc}wcc}w)Nr)�PDFExponentialFunction�PDFStitchingFunctionz4need to have the same number of colors and positionsr)�N�C0�C1�c��|dS�Nrr:)�xs r3�<lambda>z%_buildColorFunction.<locals>.<lambda>ts
��Q�q�T�r5)�key������?z	[0.0 1.0])�Domain)r'rVrWrHrK�range�floatrG�zip�sort�insertr+)
rO�	positionsrVrW�ncr^�	poscolors�	functions�pos�bounds�encode�	lastcolorr-s
             r3�_buildColorFunctionrrbs���U����Y��3�v�;�!>��O�P�P�
�6�{�a��%��f�Q�i�F�1�I�F�F�
�6�{�a�����1���!2�y��|�q�7H�)�A�&��)��q�	�J�J���
��[��.3�B�i�8��U�1�X�r�!�t�_�8�	�8���Y��/�0�	����>��*��Q�<��?�a�����Q��i��l�1�o� 6�7��R�=���q� ����c�9�R�=��#3�4�5� ��i��1��	�6��I�&�q��_�
-�c�c�
-�F�
-�
�F��q�	�I����������/�!�	�e�L�M��	��
�
�c���
�
�c��	�
 �	�6�6�+�N�N��+9��.s�F&�	F+c��eZdZedddddd��Zehd���ZdhZed	��Zed
��Z	ed��Z
d�Zd
�Zd�Z
d�Zd�Zy)�	ExtGStaterFr�Normal)�CA�ca�OP�op�OPM�BM>�Huer�Darkenru�Screen�Lighten�Overlay�Multiply�	ColorBurn�	Exclusion�	HardLight�	SoftLight�
ColorDodge�
Difference�
Luminosity�
Saturation)r{r{c�4�t|�j�Sr9)rI�lower��vs r3�_boolTransformzExtGState._boolTransform�s���1�v�|�|�~�r5c��|Sr9r:r�s r3�_identityTransformzExtGState._identityTransform�s���r5c��d|zS)N�/r:r�s r3�_pdfNameTransformzExtGState._pdfNameTransform�s���1�u�r5c� �i|_i|_yr9)�_d�_c��selfs r3�__init__zExtGState.__init__�s�������r5c	��|j|}t|t�rt|�}|j}nY||jvr?||j
|vr!t
d|�d|�d|j
|����|j}n|j}||jj||�k7s|dk(r�|jd�|k7r�||j|<|||�f}||jvr|j|}n0dtt|j��z}||j|<|jj!d|z�yyy)Nz
ExtGstate[z] = z not in allowed values ryrx�gRLsz/%s gs)�defaultsrB�boolr��
pdfNameValues�allowedrKr�r�r��get�getValuer�rIrH�_coder+)r��canv�ar�r=�
vTransform�t�names        r3�setz
ExtGState.set�s$���M�M�!����a����1�g�A��,�,�J�
�$�$�$�
$�����Q��'� ��a����Q��")�*�*��/�/�J��0�0�J��d�g�g�k�k�!�A���1�d�7�t�}�}�T�/B�A�/E��D�G�G�A�J��*�Q�-��A��D�G�G�|��w�w�q�z���c�#�d�g�g�,�/�/��!�����
��J�J���h��o�.�0F�7r5c�T�|jj||j|�Sr9)r�r�r�)r�r�s  r3r�zExtGState.getValue�s ���w�w�{�{�1�T�]�]�1�-�.�.r5c���i}|jj�D]'\}}tjt	|f��||<�)|xrtj|�xsdSr9)r��itemsr�
PDFDictionary�dict)r�r r�r�s    r3�getStatezExtGState.getState�sY�����g�g�m�m�o�	7�F�A�d��*�*�4���:�6�A�d�G�	7��,�V�)�)�!�,�4��4r5c��|j�}|jj�|_|j|_|S)z=the states must be shared across push/pop, but the values not)�	__class__r��copyr�)r�r^s  r3�pushCopyzExtGState.pushCopy�s/���N�N����w�w�|�|�~����w�w����r5N)�__name__�
__module__�__qualname__r�r�r�r��staticmethodr�r�r�r�r�r�r�r�r:r5r3rtrt�s����������
�H����G��F�M��������������/�,/�5�r5rtc��t|ttf�r3t|�dk7rt	d|z��d|D�cgc]}|rdnd��
c}zS|rdSdScc}w)Nr[z wrong length for extend argumentz[%s %s]�true�falsez[true true]z
[false false])rBrGrDrHrK)�extend�_s  r3�_gradientExtendStrr��s\���&�$�u��&��v�;��>��?�&�H�I�I��f�E��a�F�W�4�E�E�E�"�=�7��7��Fs�
Ac��eZdZdd�Zd�Zy)rNc�.�||_||_||_yr9)r-�widthr/)r�r-r�r/s    r3r�zShowBoundaryValue.__init__�s����
���
�"��r5c�@�|jduxr|jdk\Sr])r-r�r�s r3�__bool__zShowBoundaryValue.__bool__�s���z�z��%�7�$�*�*�a�-�7r5)�rrrg�������?N)r�r�r�r�r�r:r5r3rr�s��#�
8r5c� �eZdZdZ																	d�d�Zd�Zd�Zd�Zd	�Zd
j�Z
eee
e
���Zd�Zd�Zd
�Zd�Zd�d�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d�Z"d�Z#d �Z$d!�Z%d"�Z&d#�Z'd$�Z(d%�Z)d&�Z*d'�Z+						d�d(�Z,d�d)�Z-d*�Z.d+�Z/d,�Z0			d�d-�Z1			d�d.�Z2d/�Z3d0�Z4d1�Z5d�d2�Z6d3�Z7d�d4�Z8d�d5�Z9d�d6�Z:d�d7�Z;e;Z<dgd8�dddfd9�Z=d�d:�Z>e>Z?		d�d;�Z@		d�d<�ZAd�d=�ZBd�d>�ZCd?�ZDd@�ZEdA�ZFdB�ZGdC�ZHd�dD�ZIdE�ZJdF�ZKdG�ZLdH�ZMd�dI�ZNdJ�ZOdK�ZPdL�ZQdM�ZRdN�ZSdO�ZTdP�ZUdQ�ZVdR�ZWdS�ZXdT�ZYd�dU�ZZdV�Z[dW�Z\d�dX�Z]d�dY�Z^d�dZ�Z_d�d[�Z`d�d\�Zad�d]�Zbd^�Zcd_�Zdd�d`�Zed�da�Zfd�db�Zgd�dc�Zhd�dd�Ziejj�ddddfde�Zldf�Zmdg�Znd�dh�Zod�di�Zpd�dj�Zqdk�Zrdl�Zsdm�Ztdn�Zugdfdo�Zvdp�Zwd�dq�Zxd�dr�Zyd�ds�Zzd�dt�Z{du�Z|d�dv�Z}d�dw�Z~		d�dx�Zdy�Z�dz�Z�d{�Z�d|�Z�d}�Z�d~�Z�d�Z�d�d��Z�e�d���Z�d��Z�y)�ra�This class is the programmer's interface to the PDF file format.  Methods
    are (or will be) provided here to do just about everything PDF can do.

    The underlying model to the canvas concept is that of a graphics state machine
    that at any given point in time has a current font, fill color (for figure
    interiors), stroke color (for figure borders), line width and geometric transform, among
    many other characteristics.

    Canvas methods generally either draw something (like canvas.line) using the
    current state of the canvas or change some component of the canvas
    state (like canvas.setFont).  The current state can be saved and restored
    using the saveState/restoreState methods.

    Objects are "painted" in the order they are drawn so if, for example
    two rectangles overlap the last draw will appear "on top".  PDF form
    objects (supported here) are used to draw complex drawings only once,
    for possible repeated use.

    There are other features of canvas which are not visible when printed,
    such as outlines and bookmarks which are used for navigating a document
    in a viewer.

    Here is a very silly example usage which generates a Hello World pdf document.

    Example:: 
    
       from reportlab.pdfgen import canvas
       c = canvas.Canvas("hello.pdf")
       from reportlab.lib.units import inch
       # move the origin up and to the left
       c.translate(inch,inch)
       # define a large font
       c.setFont("Helvetica", 80)
       # choose some colors
       c.setStrokeColorRGB(0.2,0.5,0.3)
       c.setFillColorRGB(1,0,1)
       # draw a rectangle
       c.rect(inch,inch,6*inch,9*inch, fill=1)
       # make text go straight up
       c.rotate(90)
       # change color
       c.setFillColorRGB(0,0,0.77)
       # say hello (note after rotate the y coord needs to be negative!)
       c.drawString(3*inch, -3*inch, "Hello World")
       c.showPage()
       c.save()

    Nrrc�H�|�tj}|�tj}|r|ntj|_|�|nd|_|
�|
n|j
dz|_||_tj||||	xstj|��|_t|
�|_
||_d|_||_||_d|_d|_d|_d|_i|_|j/|�d|_g|_|j5�d|_g|_g|_g|_||_tj@|_!||_"||_#||_$||_%|jM�|jO�g|_(|jS|�y)a�Create a canvas of a given size. etc.

        You may pass a file-like object to filename as an alternative to
        a string.
        For more information about the encrypt parameter refer to the setEncrypt method.
        
        Most of the attributes are private - we will use set/get methods
        as the preferred interface.  Default page size is A4.
        cropMarks may be True/False or an object with parameters borderWidth, markColor, markWidth
        and markLength
    
        if enforceColorSpace is in ('cmyk', 'rgb', 'sep','sep_black','sep_cmyk') then one of
        the standard _PDFColorSetter callables will be used to enforce appropriate color settings.
        If it is a callable then that will be used.
        N��333333�?)�compression�	invariant�filename�
pdfVersion�langrr)*r�defaultPageSizer��canvas_basefontname�_initialFontName�_initialFontSize�_initialLeading�	_filenamer�PDFDocument�PDF_VERSION_DEFAULT�_docr�_enforceColorSpace�
_verbosity�_onPage�
_cropMarks�	_pagesize�_hanging_pagesize�
_pageRotation�_pageTransition�
_pageDuration�
_destinations�setPageCompression�_pageNumber�
_codeStack�_restartAccumulators�_annotationCount�	_outlines�_psCommandsBeforePage�_psCommandsAfterPage�bottomup�defaultImageCaching�imageCaching�_cropBox�_artBox�_trimBox�	_bleedBox�init_graphics_state�_make_preamble�state_stack�
setEncrypt)r�r��pagesizer��pageCompressionr��	verbosity�encrypt�	cropMarksr��enforceColorSpace�initialFontName�initialFontSize�initialLeading�cropBox�artBox�trimBox�bleedBoxr�s                   r3r�zCanvas.__init__s���D��	�(A�(A�X���)�*=�*=�i�3B��	�He�He���3B�3N��TV���1?�1K�~�QU�Qf�Qf�gj�Qj���!����&�&�?�1:�X�2<�2Z��@Z�@Z�,0�)��	�#;�;L�"M���$������#���!���!%������#���!����������0��������!�!�#� !������%'��"�$&��!�!��
�%�9�9�����
������
�!���� � �"������������ r5c�L�|r�ddlm}t|�r?t|�r|j	d�}|j|�}|j
d�n$t||j
�std|z��||j_
y	|j`
y#t$rYywxYw)ah
        Set the encryption used for the pdf generated by this canvas.
        If encrypt is a string object, it is used as the user password for the pdf.
        If encrypt is an instance of reportlab.lib.pdfencrypt.StandardEncryption, this object is
        used to encrypt the pdf. This allows more finegrained control over the encryption settings.
        r)�
pdfencrypt�utf-8rzjExpected string or instance of reportlab.lib.pdfencrypt.StandardEncryption as encrypt parameter but got %rN)�
reportlab.librrrrp�StandardEncryption�setAllPermissionsrB�	TypeErrorr�r��AttributeError)r�r�rs   r3r�zCanvas.setEncryptrs����0��W�~��W�%�%�n�n�W�5�G�$�7�7��@���)�)�!�,����)F�)F�G��!M�PW�!W�X�X� '�D�I�I��
��I�I�%��!�
��
�s�
B�	B#�"B#c��d|_d|_|j|_|j|_d|_|j|_d|_	t|_d|_d|_
d|_d|_d|_d|_d|_d|_d|_d|_d|_d|_t0j2xsdx|_|_t9�|_y)Nr)rcrararcrara�drr�)�_x�_yr��	_fontnamer��	_fontsize�	_textModer��_leading�_currentMatrix�
FILL_EVEN_ODD�	_fillMode�
_charSpace�
_wordSpace�_horizScale�_textRenderMode�_rise�_textLineMatrix�_textMatrix�_lineCap�	_lineJoin�	_lineDash�
_lineWidth�_mitreLimitr�canvas_baseColor�
_fillColorObj�_strokeColorObjrt�
_extgstater�s r3r�zCanvas.init_graphics_state�s����������.�.����.�.�������,�,��
�6���&������������ �����
�7���3�����
�������������4=�4N�4N�4Y�RY�Y���T�1�#�+��r5c���i}|j}|jD]
}||||<�|jj|�|jj�|_yr9)�__dict__�STATE_ATTRIBUTESr�r+r!r�)r��stater=r�s    r3�push_state_stackzCanvas.push_state_stack�sZ�����M�M���)�)�	"�D��D�'�E�$�K�	"�������&��/�/�2�2�4��r5c�j�|jj|jj��yr9)r#�updater��popr�s r3�pop_state_stackzCanvas.pop_state_stack�s#���
�
���T�-�-�1�1�3�4r5a_x _y _fontname _fontsize _textMode _leading _currentMatrix _fillMode
     _charSpace _wordSpace _horizScale _textRenderMode _rise _textLineMatrix
     _textMatrix _lineCap _lineJoin _lineDash _lineWidth _mitreLimit _fillColorObj
     _strokeColorObj _extgstatec���gj}|jr	|d�n!|dt|jd�z�|j}t|�}|jdk7r|j|j�|jdk7r|j|j�|dj||d��||d�=tj|j�}|jsQ|jj s
t#|dd�s.|d|j$j'|j�z�dj|j(�|_y)	Nz1 0 0 1 0 0 cmz1 0 0 -1 0 %s cmrr�� �_drawTextAsPathFzBT %s 12 Tf 14.4 TL ET)r+r�rr�r�rHr�setFillColorr �setStrokeColor�joinr
�getFontr�_dynamicFont�face�builtIn�getattrr��getInternalFontName�__self__�	_preamble)r��Pr%r�fonts     r3r�zCanvas._make_preamble�s���I�I���=�=�
���
� �6�$�.�.��*;�#<�<�=��J�J����F������(����d�0�0�1����7�*����� 4� 4�5�	�#�(�(�1�Q�R�5�/��
�a�b�E��!�!�$�.�.�1��� � ��y�y� � ���5F�u�(M��*�T�Y�Y�-J�-J�4�>�>�-Z�Z�[����!�*�*�-��r5c��t|�Sr9)r�r��ss  r3�_escapezCanvas._escape�s����|�r5c�:�|jj|�y)aidentify the author for invisible embedding inside the PDF document.
           the author annotation will appear in the the text of the file but will
           not automatically be seen when the document is viewed, but is visible
           in document properties etc etc.N)r��	setAuthor)r��authors  r3r@zCanvas.setAuthor�s��
	
�	�	���F�#r5c�:�|jj|�y)zHaccepts a func(yyyy,mm,dd,hh,m,s) used to create embedded formatted dateN)r��setDateFormatter)r��
dateFormatters  r3rCzCanvas.setDateFormatter�s���	�	�"�"�=�1r5c�V�|jjj||||��y)a�Adds a new entry to the outline at given level.  If LEVEL not specified,
        entry goes at the top level.  If level specified, it must be
        no more than 1 greater than the outline level in the last call.

        The key must be the (unique) name of a bookmark.
        the title is the (non-unique) name to be displayed for the entry.

        If closed is set then the entry should show no subsections by default
        when displayed.

        Example::
        
           c.addOutlineEntry("first section", "section1")
           c.addOutlineEntry("introduction", "s1s1", 1, closed=1)
           c.addOutlineEntry("body", "s1s2", 1)
           c.addOutlineEntry("detail1", "s1s2s1", 2)
           c.addOutlineEntry("detail2", "s1s2s2", 2)
           c.addOutlineEntry("conclusion", "s1s3", 1)
           c.addOutlineEntry("further reading", "s1s3s1", 2)
           c.addOutlineEntry("second section", "section1")
           c.addOutlineEntry("introduction", "s2s1", 1)
           c.addOutlineEntry("body", "s2s2", 1, closed=1)
           c.addOutlineEntry("detail1", "s2s2s1", 2)
           c.addOutlineEntry("detail2", "s2s2s2", 2)
           c.addOutlineEntry("conclusion", "s2s3", 1)
           c.addOutlineEntry("further reading", "s2s3s1", 2)

        generated outline looks like::
        
            - first section
            |- introduction
            |- body
            |  |- detail1
            |  |- detail2
            |- conclusion
            |  |- further reading
            - second section
            |- introduction
            |+ body
            |- conclusion
            |  |- further reading

        Note that the second "body" is closed.

        Note that you can jump from level 5 to level 3 but not
        from 3 to 5: instead you need to provide all intervening
        levels going down (4 in this case).  Note that titles can
        collide but keys cannot.
        )�closedN)r��outline�addOutlineEntry)r��titler`�levelrFs     r3rHzCanvas.addOutlineEntry�s&��h	
�	�	���)�)�#�u�e�F�)�Kr5c�R�|jjj|f|z�y)aFnametree should can be a recursive tree like so::
            
               c.setOutlineNames(
                 "chapter1dest",
                 ("chapter2dest",
                  ["chapter2section1dest",
                   "chapter2section2dest",
                   "chapter2conclusiondest"]
                 ), # end of chapter2 description
                 "chapter3dest",
                 ("chapter4dest", ["c4s1", "c4s2"])
                 )
          
          each of the string names inside must be bound to a bookmark
          before the document is generated.
        N)r�rG�setNames)r��nametrees  r3�setOutlineNames0zCanvas.setOutlineNames0s%��"	#��	�	���"�"�d�W�X�%5�7r5c�:�|jj|�y)zcwrite a title into the PDF file that won't automatically display
           in the document itself.N)r��setTitle)r�rIs  r3rPzCanvas.setTitle(s��	
�	�	���5�!r5c�:�|jj|�y)zewrite a subject into the PDF file that won't automatically display
           in the document itself.N)r��
setSubject)r��subjects  r3rRzCanvas.setSubject-s��	
�	�	���W�%r5c�:�|jj|�y)z�write a creator into the PDF file that won't automatically display
           in the document itself. This should be used to name the original app
           which is passing data into ReportLab, if you wish to name it.N)r��
setCreator)r��creators  r3rUzCanvas.setCreator2s��	
�	�	���W�%r5c�:�|jj|�y)z!change the default producer valueN)r��setProducer)r��producers  r3rXzCanvas.setProducer8s���	�	���h�'r5c��t|ttf�rdj|�}|jj|�y)z�write a list of keywords into the PDF file which shows in document properties.
        Either submit a single string or a list/tuplez, N)rBrGrDr0r��setKeywords)r��keywordss  r3r[zCanvas.setKeywords<s2���h��U�|�,��y�y��*�H��	�	���h�'r5c�2�t|j�dk(S)zHInfo function - app can call it after showPage to see if it needs a saver)rHr�r�s r3�pageHasDatazCanvas.pageHasDataCs���4�:�:��!�#�#r5c�L�|jjj�y)z�Specify that Acrobat Reader should start with the outline tree visible.
        showFullScreen() and showOutline() conflict; the one called last
        wins.N)r��_catalog�showOutliner�s r3razCanvas.showOutlineGs��	
�	�	���&�&�(r5c�L�|jjj�y)z�Specify that Acrobat Reader should start in full screen mode.
        showFullScreen() and showOutline() conflict; the one called last
        wins.N)r�r`�showFullScreenr�s r3�showFullScreen0zCanvas.showFullScreen0Ms��	
�	�	���)�)�+r5c�t�|jjd�|jj|d|�y)z�
        Define the transparency/opacity of strokes. 0 is fully
        transparent, 1 is fully opaque.

        Note that calling this function will cause a version 1.4 PDF
        to be generated (rather than 1.3).
        �transparencyrvN�r��ensureMinPdfVersionr!r��r�r�s  r3�_setStrokeAlphazCanvas._setStrokeAlphaS�,��	
�	�	�%�%�n�5������D��a�(r5c�t�|jjd�|jj|d|�y)z�
        Define the transparency/opacity of non-strokes. 0 is fully
        transparent, 1 is fully opaque.

        Note that calling this function will cause a version 1.4 PDF
        to be generated (rather than 1.3).
        rfrwNrgris  r3�
_setFillAlphazCanvas._setFillAlpha^rkr5c�>�|jj|d|�y)Nrx�r!r�ris  r3�_setStrokeOverprintzCanvas._setStrokeOverprinti��������D��a�(r5c�>�|jj|d|�y)Nryroris  r3�_setFillOverprintzCanvas._setFillOverprintlrqr5c�N�|jj|d|xrdxsd�y)Nrzrrroris  r3�_setOverprintMaskzCanvas._setOverprintMaskos �������D��q�w�Q�|�!�4r5c�>�|jj|d|�y)Nr{roris  r3�setBlendModezCanvas.setBlendModerrqr5c��|j}|r7tdt|dd��}tdt|dd��}|r||z}|Sy)Nr�
bleedWidth�borderWidth�$)r��maxr5)r��cM�bleedW�bws    r3�_getCmShiftzCanvas._getCmShiftusN��
�_�_��
���7�2�l�1�5�6�F��Q�w�r�-��3�4�B���f����I�r5c��|jd}|jd}|j}|j}|�r�tdt	|dd��}|�r�t	|dd�}t|tdt	|dd���}t	|dd	�}t	|d
t�}	d|z|z
}
t|�}|r�|	r�|j�|j|	�|j|�|j|d||f||zd||z|f|||
z||d|zzf||z||
z||z|d|zzfd|||f||
z||d|zz|fd||z|||zf||
z||z|d|zz||zfg�|j�|r||d}||d�=t|�}tdt	|d
d��}
|j�|j||
z
||
z
�|
r$|jdd|
z|zzdd|
z|zz�||d}||d�=||dd|j�|r|j�d|z|z}d|z|z}|j!d�t#j$�}||_||_|j*|_|j.|_|j3|j4�|j7|j8�dD]F}t	|d|zd�}|s�t;||j=�dzt#j>|���H|j@�|j@|_!|jD|jFgz|z|jHz}|jK|�|jM|�|jO|�|jQ|�|jS|�|jU|�|jVjY|�|jZr|j[|j\�|j_�y)z8Close the current page and possibly start on a new page.rrrzr{�markLast�
markLength��	markWidth��?�	markColorr[Nryg@r,)�crop�art�bleed�trim�_%sBox�Box)0r�r�r�r|r5�minrrH�	saveStater/�setLineWidth�lines�restoreState�	translate�scaler�r+r�PDFPage�	pagewidth�
pageheightr��Rotate�_currentPageHasImages�	hasImages�setPageTransitionr��setCompression�_pageCompression�setattr�
capitalizer$r��Durr�r8r��	setStream�_setColorSpace�
_setExtGState�_setXObjects�_setShadingUsed�_setAnnotationsr��addPager�r��
_startPage)r��	pageWidth�
pageHeightr}�coderr��ml�mw�mc�mg�cx0�Lr~r%�page�box�size�strms                   r3�showPagezCanvas.showPage~s����N�N�1�%�	��^�^�A�&�
�
�_�_���z�z��
��Q�w�r�-��3�4�B��"�2�j��3����C��'�"�\�"�"=�>�?���R��C�0���R��E�2���r�T�"�W���$�i���"��N�N�$��'�'��+��%�%�b�)��J�J��A�b���"�2��a�	�"��R�8��J�r�M�"�Z��"��_�=�"�2��j��m�I�b�L��A�b�D��Q��2�b���"�2��b��1�R�4���;��:�b�=��J�r�M�:�"�2��j��m�I�a��d�N�:�b�=�Q�	 �	��%�%�'��!���J�� ���J�!�$�i���Q�w�r�,�q�9�:����� ����r�&�y��F��3���J�J�q�#�f�*�i�!7�7��3�v�:�z�:Q�8Q�R����J�����J���Q�q�	��!�!�#���K�K��N��b�D�9�,�	��r�T�J�.�
����C���~�~���"���$����(�(����3�3������t�3�3�4����D�1�1�2�0�	K�C��4����T�2�D����S�^�^�-�e�3�F�O�O�D�4I�J�	K����)��)�)�D�H��*�*�d�n�n�-=�=��D�t�G`�G`�`�����t�����D�!����4� ����$�����T�"����T�"��	�	���$���<�<����d�&6�&6�7����r5c���|jr"|j|j�d|_|xjdz
c_|j�|j	�g|_y�Nr)r��setPageSizer�r�r�r�r�s r3r�zCanvas._startPage�sX���!�!����T�3�3�4�%)�D�"����A����!�!�#�� � �"���r5c��||_y)z�func(pageNum) will be called on each page end.

       This is mainly a hook for progress monitoring.
        Call setPageCallback(None) to clear a callback.N)r�)r��funcs  r3�setPageCallBackzCanvas.setPageCallBack�s��
��r5c�&�|j|_yr9)�_annotationrefs�Annots�r�r�s  r3r�zCanvas._setAnnotations�s���*�*��r5c�&�|j|_yr9)�_colorsUsed�r��objs  r3r�zCanvas._setColorSpace�s���*�*��r5c�&�|j|_yr9)�_shadingUsedr�s  r3r�zCanvas._setShadingUsed�s�� �-�-��r5c�t�|j}|r#|jj|�}||_yd|_y)zKfor pages and forms, define the XObject dictionary for resources, if neededN)�_formsinuser��xobjDict�XObjects)r��thing�forms�xobjectsdicts    r3r�zCanvas._setXObjects�s2��� � ����9�9�-�-�e�4�L�)�E�N�!�E�Nr5c�j�|j}	||S#tj|�x}||<Y|SxYw)zDget a reference to a (possibly undefined, possibly unbound) bookmark)r�r�Destination)r�r�r=�results    r3�_bookmarkReferencezCanvas._bookmarkReference�s@������	8��T�7�N��	8�%�1�1�$�7�7�F�Q�t�W��
�s��2c�~�|j|�}|jj�|jj�}	|�d}|�d}|�d}|�d}|�d}|dk(r|j	|||�n�|dk(r|j�n�|dk(r|j
|�n�|dk(r|j|�nu|dk(r|j||||�n[|dk(r|j�nE|dk(r|j|�n.|d	k(r|j|�ntd
t|�z��|j|	�|S)a]
        This creates a bookmark to the current page which can
        be referred to with the given key elsewhere.

        PDF offers very fine grained control over how Acrobat
        reader is zoomed when people link to this. The default
        is to keep the user's current zoom settings. the last
        arguments may or may not be needed depending on the
        choice of 'fitType'.

        Fit types and the other arguments they use are:
        
        - XYZ left top zoom - fine grained control.  null
          or zero for any of the parameters means 'leave
          as is', so "0,0,0" will keep the reader's settings.
          NB. Adobe Reader appears to prefer "null" to 0's.

        - Fit - entire page fits in window

        - FitH top - top coord at top of window, width scaled
          to fit.

        - FitV left - left coord at left of window, height
          scaled to fit

        - FitR left bottom right top - scale window to fit
          the specified rectangle

        (question: do we support /FitB, FitBH and /FitBV
        which are hangovers from version 1.1 / Acrobat 3.0?)�null�XYZ�Fit�FitH�FitV�FitR�FitB�FitBH�FitBVzUnknown Fit type %s)r�r��inPage�thisPageRef�xyz�fit�fith�fitv�fitr�fitb�fitbh�fitbvrK�ascii�setPage)
r�r`r��left�top�bottom�right�zoom�dest�pagerefs
          r3�bookmarkPagezCanvas.bookmarkPage�s*��L�&�&�s�+���	�	�����)�)�'�'�)���<��D��;��C��>��F��=��E��<��D��%�<��H�H�T�#�d�#�
�E�\��H�H�J�
�F�]��I�I�c�N�
�F�]��I�I�d�O�
�F�]��I�I�d�6�%��,�
�F�]��I�I�K�
�G�^��J�J�s�O�
�G�^��J�J�t���2�U�3�Z�?�@�@����W���r5c�.�|j||||d��S)aBind a bookmark (destination) to the current page at a horizontal position.
           Note that the yhorizontal of the book mark is with respect to the default
           user space (where the origin is at the lower left corner of the page)
           and completely ignores any transform (translation, scale, skew, rotation,
           etcetera) in effect for the current graphics state.  The programmer is
           responsible for making sure the bookmark matches an appropriate item on
           the page.r)r�r�r�r�)r�)r�r`r�r�r��kws      r3�bookmarkHorizontalAbsolutez!Canvas.bookmarkHorizontalAbsoluteLs ��� � ��#�3�T�� �J�Jr5c�Z�|j||�\}}|j||fd|i|��y)z<w.r.t. the current transformation, bookmark this horizontal.r�N)�absolutePositionr�)r�r`�	relativeX�	relativeYr�r�r�s       r3�bookmarkHorizontalzCanvas.bookmarkHorizontalWs4���+�+�I�i�@���s�'��'�'��S�B�t�B�r�Br5c��|jjd|jj|�z�|jj|�y)aIuse a form XObj in current operation stream.

        The form should either have been defined previously using
        beginForm ... endForm, or may be defined later.  If it is not
        defined at save time, an exception will be raised. The form
        will be drawn within the context of the current graphics
        state.�/%s DoN)r�r+r��getXObjectNamer��r�r�s  r3�doFormz
Canvas.doFormds>��	
�
�
���(�T�Y�Y�%=�%=�d�%C�C�D�������%r5c�8�|jj|�S)z*Query whether form XObj really exists yet.)r��hasFormr�s  r3r�zCanvas.hasFormos���y�y� � ��&�&r5c��d|_ddlm}||||||�}|j|||||	|
��|j|j
fS)a�See drawImage, which should normally be used instead... 
        
        drawInlineImage behaves like drawImage, but stores the image content
        within the graphics stream for the page.  This means that the mask
        parameter for transparency is not available.  It also means that there 
        is no saving in file size or time if the same image is reused.  
        
        In theory it allows images to be displayed slightly faster; however, 
        we doubt if the difference is noticeable to any human user these days.
        Only use this if you have studied the PDF specification and know the
        implications.
        rr)�PDFImage)�preserveAspectRatio�anchor�
anchorAtXY�showBoundary�extraReturn)r��reportlab.pdfgen.pdfimagesr�drawInlineImager��height)
r��imager^�yr�rrrrrrr�img_objs
             r3rzCanvas.drawInlineImagexsX�� &'��"�7��5�!�A�u�f�5������ 3��Z�\�#�	 �	%��
�
�w�~�~�.�.r5c��d|_t|t�rj|j�}|j}
|dk(r|
r|
j�}nt|�}t
|�r|jd�}t||z�}n-|�|��}t
|�r|jd�}t|�}|jj|�}|jjj|d�}|�stj|||��}||_|j!|�|jj#||�|jj%||�t'|dd�}
|
r�|jj|
j�}|jjj|d�}|s3|j!|
�|jj#|
|�|_ntj*|�|_|`t/|||||||j0|j2|	�	\}}}}}|j5�|j7||�|j9||�|j:j=d|z�|j?�|
r|jA|
||||�|jBj=|�|r%|jE�D]}tG�|||<�|j0|j2fS)	aXDraws the image (ImageReader object or filename) as specified.

        "image" may be an image filename or an ImageReader object. 
 
        x and y define the lower left corner of the image you wish to
        draw (or of its bounding box, if using preserveAspectRation below).
         
        If width and height are not given, the width and height of the
        image in pixels is used at a scale of 1 point to 1 pixel.  
       
        If width and height are given, the image will be stretched to fill 
        the given rectangle bounded by (x, y, x+width, y-height).  
        
        If you supply negative widths and/or heights, it inverts them and adjusts
        x and y accordingly.

        The method returns the width and height of the underlying image, since
        this is often useful for layout algorithms and saves you work if you have
        not specified them yourself.

        The mask parameter supports transparent backgrounds. It takes 6 numbers
        and defines the range of RGB values which will be masked out or treated
        as transparent.  For example with [0,2,40,42,136,139], it will mask out
        any pixels with a Red value from 0-2, Green from 40-42 and
        Blue from 136-139  (on a scale of 0-255).

        New post version 2.0:  drawImage can center an image in a box you
        provide, while preserving its aspect ratio.  For example, you might
        have a fixed square box in your design, and a collection of photos
        which might be landscape or portrait that you want to appear within 
        the box.  If preserveAspectRatio is true, your image will appear within
        the box specified.

        
        If preserveAspectRatio is True, the anchor property can be used to
        specify how images should fit into the given box.  It should 
        be set to one of the following values, taken from the points of
        the compass (plus 'c' for 'centre'):

                nw   n   ne
                w    c    e
                sw   s   se

        The default value is 'c' for 'centre'.  Thus, if you want your
        bitmaps to always be centred and appear at the top of the given box,
        set anchor='n'.      There are good examples of this in the output
        of test_pdfgen_general.py

        Unlike drawInlineImage, this creates 'external images' which
        are only stored once in the PDF file but can be drawn many times.
        If you give it the same filename twice, even at different locations
        and sizes, it will reuse the first occurrence, resulting in a saving
        in file size and generation time.  If you use ImageReader objects,
        it tests whether the image content has changed before deciding
        whether to reuse it.

        In general you should use drawImage in preference to drawInlineImage
        unless you have read the PDF Spec and understand the tradeoffs.r�auto�utf8rN)�mask�_smaskr�)$r�rBr�
getRGBData�_dataArIrrprr�r��
idToObjectr�r�PDFImageXObjectr�r��	Reference�addFormr5�smask�PDFObjectReferencerrr�rr�r�r�r�r+r��drawBoundaryr��keys�vars)r�r	r^r
r�rrrrrrr�rawdatar�mdatar�r=�regName�imgObj�mRegName�mImgObj�scaled�ks                       r3�	drawImagezCanvas.drawImage�s���|&'��"��e�K�(��&�&�(�G��L�L�E��V�|���(�(�*���D�	��������V�,���W�U�]�+�D� ��&�A���|��H�H�W�%���Q�<�D��)�)�*�*�4�0�����%�%�)�)�'�4�8����+�+�D�%�d�C�F��F�K����f�%��I�I�����0��I�I���d�F�+��F�8�D�1�E���9�9�3�3�E�J�J�?���)�)�.�.�2�2�8�T�B����%�%�e�,�#'�9�9�#6�#6�u�X�#F�F�L�#)�#<�#<�X�#F�F�L��M�#1�1D�V�A�a�PU�V\�]c�]i�]i�jp�jw�jw�yC�#D���!�E�&��	
�������q�!���
�
�5�&�!��
�
���(�W�,�-���������l�1�Q�u�V�<�	
������%�� �%�%�'�
+��!%�����A��
+����f�m�m�,�,r5c��|jrA|jjd�\|_|_|_|_|_|_yg|_g|_g|_	d|_
g|_g|_d|_i|_i|_y)Nrbr)r�r)r�r�r��	_formDatar�r�r�r�r�r�s r3r�zCanvas._restartAccumulatorss����?�?�uy�vE�vE�vI�vI�JL�vM�r�D�J��(�$�*>���t�O_�ae�ar��D�J�(*�D�%�)+�D�&�)*�D�&�!�D��#%�D� �!�D�N�!�D�� "�D�r5c�$�|j|j|j|j|j|j
f}|jj|�g|_d|_g|_g|_d|_i|_i|_y)zVwhen you enter a form, save accumulator info not related to the form for page (if any)rN)	r�r�r�r&r�r�r�r+r�)r��saveds  r3�_pushAccumulatorszCanvas._pushAccumulatorss~�����T�-�-�t�/C�/C�T�^�^�UY�Ue�Ue�gk�gx�gx�y�������u�%���
�%&��"����!�����������r5c�B�|jj�|_yr9)r!r�rtr�s  r3r�zCanvas._setExtGState*s�����0�0�2��
r5c���|j�|j�|js|jr|j	�|||||f|_|j
j
�y)a}declare the current graphics stream to be a named form.
           A graphics stream can either be a page or a form, not both.
           Some operations (like bookmarking) are permitted for pages
           but not forms.  The form will not automatically be shown in the
           document but must be explicitly referenced using doForm in pages
           that require the form.N)r&r�r�r&r)r��inForm)r�r��lowerx�lowery�upperx�upperys      r3�	beginFormzCanvas.beginForm-sY��	
����� � �"��:�:�����"�"�$������?����	�	���r5c�H�|j\}}}}}	|j\}}|�|}|�|}tj||||��}	|j|	_|	j
|jg|jz�|j�D]\}
}t|	|
|��|j|	�|j|	�|j|	�|j|	�|jj!||	�|j#�|j%�y)zlemit the current collection of graphics operations as a Form
           as declared previously in beginForm.N)r-r.r/r0)r&r�r�PDFFormXObjectr�r��
setStreamListr8r�r�r�r�r�r�r�r�rr�r*)r��extra_attributesr�r-r.r/r0�w�h�formr#r�s            r3�endFormzCanvas.endForm?s��26���.��v�v�v�v�	R������1��>�!�6��>�!�6��$�$�F�6�&�Y_�`���0�0������D�N�N�+�d�j�j�8�9�$�*�*�,�	�D�A�q��D��1��	����D�!����4� ����$�����T�"��	�	���$��%��!�!�#����r5c��t|�r6dtj|jd��j	�z}n&dtj|�j	�z}|j
j
|�}|j
jj|d�}|satj|dz�}|j|�|j
j||�|j
j||�|dk(r|jjd|z�nB|dk(r|j jd|z�n|j"jd|z�|j$j|�y)a�Embed literal Postscript in the document.

        With position=0, it goes at very beginning of page stream;
        with position=1, at current point; and
        with position=2, at very end of page stream.  What that does
        to the resulting Postscript depends on Adobe's header :-)

        Use with extreme caution, but sometimes needed for printer tray commands.
        Acrobat 4.0 will export Postscript to a printer or file containing
        the given commands.  Adobe Reader 6.0 no longer does as this feature is
        deprecated.  5.0, I don't know about (please let us know!). This was
        funded by Bob Marshall of Vector.co.uk and tested on a Lexmark 750.
        See test_pdfbase_postscript.py for 2 test cases - one will work on
        any Postscript device, the other uses a 'setpapertray' command which
        will error in Distiller but work on printers supporting it.
        �PSrN�
rr�r)r�hashlib�md5rp�	hexdigestr�r�rr�r�PDFPostScriptXObjectr�rrr�r+r�r�r�)r��command�position�rawNamer�psObjs      r3�addPostScriptCommandzCanvas.addPostScriptCommandXs5��$�W���W�[�[�����)@�A�K�K�M�M�G��W�[�[��1�;�;�=�=�G��)�)�*�*�7�3���	�	�$�$�(�(��$�7����/�/��$��?�E����e�$��I�I����w�/��I�I���g�u�-��q�=��&�&�-�-�h��.@�A�
�q�[��J�J���h��0�1��%�%�,�,�X��-?�@�������(r5c���|s|j\}}dd||f}n�|r�|\}}}}|j||�\}	}
|j||�\}}|j||�\}
}|j||�\}}|	||
|f}|
|||f}t|�t|�}}t|�t|�}}||||f}|j	�}|r|d|z|d|z|d|z|d|zf}|S)Nrrr[r@)r�r�r�r|r�)r��rect�relativer6r7�lx�ly�ux�uy�xll�yll�xur�yur�xul�yul�xlr�ylr�xs�ys�xmin�ymin�xmax�ymaxrs                        r3�_absRectzCanvas._absRects����.�.�C�A�a��a��!�9�D�
�!�N�B��B���+�+�B�r�2�G�C���+�+�B��3�G�C���+�+�B��3�G�C���+�+�B��3�G�C���c�3��#�B��c�3��#�B��R��#�b�'�$�D��R��#�b�'�$�D���t�T�)�D�
�
�
�
��
���7�2�:�d�1�g�b�j��a����D��G�B�J�>�D��r5c�z�|j||�}|jtj|||fi|��||�y)z&DA is the default appearance string???N)r[�_addAnnotationr�FreeTextAnnotation)r��contents�DA�Rect�	addtopager�rHr�s        r3�freeTextAnnotationzCanvas.freeTextAnnotation�s:���}�}�T�(�+�����F�5�5�d�H�b�O�B�O�QU�W`�ar5c�x�|j||�}|jtj||fi|��||�y)z!Experimental, but works.
        N)r[r]r�TextAnnotation)r�r_rarbr�rHr�s       r3�textAnnotationzCanvas.textAnnotation�s8���}�}�T�(�+�����F�1�1�$��G�B�G��y�Yr5)g��(\��?g{�G�z�?gffffff�?c��|j||�}|stj|�}|jtj||||fi|��||�y)a1
        Allows adding of a highlighted annotation.

        Rect: Mouseover area to show contents of annotation
        QuadPoints: List of four x/y points [TOP-LEFT, TOP-RIGHT, BOTTOM-LEFT, BOTTOM-RIGHT]
          These points outline the areas to highlight.
          You can have multiple groups of four to allow multiple highlighted areas.
          Is in the format [x1, y1, x2, y2, x3, y3, x4, y4, x1, y1, x2, y2, x3, y3, x4, y4] etc
          QuadPoints defaults to be area inside of passed in Rect
        Color: The color of the highlighting.
        N)r[r�rect_to_quadr]�HighlightAnnotation)	r�r_ra�
QuadPointsrrbr�rHr�s	         r3�highlightAnnotationzCanvas.highlightAnnotation�sS���}�}�T�8�,����,�,�T�2�J����F�6�6�t�X�z�SX�_�\^�_�ae�gp�qr5c��t�r9)�NotImplementedErrorr[r7r6r]r�
InkAnnotation)r�r_�InkListrarbr�rHr�s        r3�
inkAnnotationzCanvas.inkAnnotation�s��!�!r5c	�:�|j|||||fd|||d�|	��S)a9rectangular link annotation positioned wrt the default user space.
           The identified rectangle on the page becomes a "hot link" which
           when clicked will send the viewer to the page and position identified
           by the destination.

           Rect identifies (lowerx, lowery, upperx, uppery) for lower left
           and upperright points of the rectangle.  Translations and other transforms
           are IGNORED (the rectangular position is given with respect
           to the default user space.
           destinationname should be the name of a bookmark (which may be defined later
           but must be defined before the document is generated).

           You may want to use the keyword argument Border='[0 0 0]' to
           suppress the visible rectangle around the during viewing link.r)rHr.r-r/)�linkRect)
r�r_�destinationnamerarbr�r.r-r/r�s
          r3�linkAbsolutezCanvas.linkAbsolute�s<�� �t�}�}�X���i��M�XY�#�5�I�M�IK�M�	Mr5c
���|j|�}|j||�}||
d<||
d<||
d<t|
|||	�|jt	j
di|
��||�S)z�rectangular link annotation w.r.t the current user transform.
           if the transform is skewed/rotated the absolute rectangle will use the max/min x/y
        ra�Contentsr�r:)r�r[r4r]r�LinkAnnotation)r�r_rsrarbr�rHr.r-r/r��destinations            r3rrzCanvas.linkRect�sq��
�-�-�o�>���}�}�T�(�+����6�
�!��:��'��=���2�e�I�i�0��"�"�6�#8�#8�#>�2�#>��i�P�Pr5c�t�ddlm}	m}
m}m}|	|��}
|
d�|
d<|
d�|
d<||j||��|
d<|	�}|
d	�|d<||�}|
|�|d
<|dk(r||d<n|dk(r||d
<d|d<nt
d|z��||
d<t|
|||�|j|
�y)a�Create a rectangular URL 'hotspot' in the given rectangle.

        if relative=1, this is in the current coord system, otherwise
        in absolute page space.
        The remaining options affect the border appearance; the border is
        drawn by Acrobat, not us.  Set thickness to zero to hide it.
        Any border drawn this way is NOT part of the page stream and
        will not show when printed to a Postscript printer or distilled;
        it is safest to draw your own.r)r��PDFNamer$�	PDFString)r��Annot�Type�Link�Subtypera�Actionr �URI�GoToR�Fz[ 0 /XYZ null null null ]r,zUnknown linkURI kind '%s'�AN)	r'r�rzr$r{r[rKr4r])r��urlrGrHr.r-r/�kindr�r�rzr$r{�annr��uris                r3�linkURLzCanvas.linkURL�s���	Y�X���$���g�&��F�� ����I���t�}�}�T�(�;�<��F��
�O���H�%��&�	���n������#����;��A�e�H�
�7�]��A�c�F�0�A�c�F��8�4�?�@�@���C���3�u�Y�y�1����C� r5c��|jdzx}|_|sdt|�z}|jj||�|r|j	|�yy)Nr�NUMBER)r��reprr��
addAnnotation�
_annotatePage)r��
annotationr�rb�counts     r3r]zCanvas._addAnnotation�sT��(,�(=�(=�a�(?�?���%��(�4��;�.�T��	�	����j�1�����t�$�r5c�p�|jj|�}|jj|�yr9)r��
refAnnotationr�r+)r�r��refs   r3r�zCanvas._annotatePages*���i�i�%�%�d�+�����#�#�C�(r5c��|jS)z9get the page number for the current page being generated.)r�r�s r3�
getPageNumberzCanvas.getPageNumber	s�����r5c��t|j�r|j�|jj	|j
|�y)z�Saves and close the PDF document in the file.
           If there is current data a ShowPage is executed automatically.
           After this operation the canvas must not be used further.N)rHr�r�r��
SaveToFiler�r�s r3�savezCanvas.save
s/���t�z�z�?�D�M�M�O��	�	���T�^�^�T�2r5c��t|j�r|j�|jj	|�}t|�r|j
d�}|S)z�Returns the PDF data that would normally be written to a file.
        If there is current data a ShowPage is executed automatically.
        After this operation the canvas must not be used further.r)rHr�r�r��
GetPDFDatarrpr<s  r3�
getpdfdatazCanvas.getpdfdatasE���t�z�z�?�D�M�M�O��I�I� � ��&���Q�<�����!�A��r5c�2�||_|j�y)zPaccepts a 2-tuple in points for paper size for this
        and subsequent pagesN)r�r��r�r�s  r3r�zCanvas.setPageSizes��������r5c��|j�}|jd�r|dd}|dvrtd|z��t|d|z|�y)zMaccepts a 2-tuple in points for name+'Box' size for this and subsequent pagesr�N���)r�r�r�r�zunknown box name: %rr�)r��endswithrKr�)r�r�r�s   r3�
setCropBoxzCanvas.setCropBox$sM���z�z�|���=�=����S�b�	���4�4��3�d�:�;�;���X��_�d�+r5c�*�|j|d��y)Nr��r��r�r�s  r3�
setTrimBoxzCanvas.setTrimBox,s������&��)r5c�*�|j|d��y)Nr�r�r�r�s  r3�	setArtBoxzCanvas.setArtBox/s������%��(r5c�*�|j|d��y)Nr�r�r�r�s  r3�setBleedBoxzCanvas.setBleedBox2s������'��*r5c�0�|dzdk(sJd��||_y)z7Instruct display device that this page is to be rotatedg�V@raz)Rotation must be a multiple of 90 degreesN)r�)r��rots  r3�setPageRotationzCanvas.setPageRotation5s"���T�z�S� �M�"M�M� � ��r5c�|�t|�}|dk(r|j|�}|jj|�y)z�introduce the literal text of PDF operations s into the current stream.
           Only use this if you are an expert in the PDF file format.rN)rIr>r�r+)r�r=�escapeds   r3�
addLiteralzCanvas.addLiteral:s3��
��F���A�:����Q��A��
�
���!�r5c���|j\}}}}}}||z||zz
}||z}||z}	||z||zz
|z}
||z}||z}||z||zz
|z}
|j|||	||
|
�y)aXI want to draw something (eg, string underlines) w.r.t. the default user space.
           Reset the matrix! This should be used usually as follows::
           
              canv.saveState()
              canv.resetTransforms()
              #...draw some stuff in default space coords...
              canv.restoreState() # go back!
        N)r�	transform)r��selfa�selfb�selfc�selfd�selfe�selff�det�resulta�resultc�resulte�resultd�resultb�resultfs              r3�resetTransformszCanvas.resetTransformsGs���6:�5H�5H�2���u�e�U�E��E�k�E�%�K�'����)���&��*����;��u��,�c�1����)���&��*����;��u��,�c�1�����w���'�7�G�Lr5c���tr\|j\}}}	}
}}||z|	|zz||z|
|zz||z|	|zz||z|
|zz||z|	|zz|z||z|
|zz|zf|_|jr�|jddddk(r�|jdj�}
t	tt|
dd��\}}}	}
}}t|
�dkDxrt|
�dzxsd}|t||z|	|zz||z|
|zz||z|	|zz||z|
|zz||z|	|zz|z||z|
|zz|z�z|jd<y|jjdt||||||�z�y)	zoadjoin a mathematical transform to the current graphics state matrix.
           Not recommended for beginners.rbr�Nz cmi�����z %s cmz%s cm)�ENABLE_TRACKINGrr��splitrG�maprfrHr0rr+)r�r��br<r=�er!�a0�b0�c0�d0�e0�f0r�r=s               r3r�zCanvas.transform[s���� $� 3� 3��B�r�"�R��2�#%�a�4��1��9��A��b��d��#%�a�4��1��9��A��b��d��#%�a�4��1��9�R�<��A��b��d��2��#?�D���:�:�$�*�*�R�.���-�u�4��
�
�2��$�$�&�A�%)�#�e�A�b��H�*=�%>�"�B��B��B���A��q��.�T�!�W�h�.�9�'�A����1��R��T�	�"�Q�$�r�!�t�)�B�q�D��A��I�b��d�2�a�4�i�PR�ST�PT�UW�XY�UY�PY�Z\�P\�]_�`a�]a�bd�ef�bf�]f�gi�]i�!j�j�D�J�J�r�N��J�J���g��q��1�Q�q��(;�;�<r5c��tstd��|j\}}}}}}||z||zz|z}	||z||zz|z}
|	|
fS)zKreturn the absolute position of x,y in user space w.r.t. default user spacez0tracking not enabled! (canvas.ENABLE_TRACKING=0))r�rKr)r�r^r
r�r�r<r=r�r!�xp�yps           r3r�zCanvas.absolutePositionls[����O�P�P��+�+�
��1�Q�q��1�
�q�S�1�Q�3�Y��]��
�q�S�1�Q�3�Y��]���B�x�r5c�0�|jdddd||�y)zzmove the origin from the current (0,0) point to the (dx,dy) point
           (with respect to the current graphics state).rrN�r�)r��dx�dys   r3r�zCanvas.translateus��	
���q��1�Q�r�"�%r5c�0�|j|dd|dd�y)z�Scale the horizontal dimension by x and the vertical by y
           (with respect to the current graphics state).
           For example canvas.scale(2.0, 0.5) will make everything short and fat.rNr�)r�r^r
s   r3r�zCanvas.scalezs��	
���q��1�Q�q��#r5c��t|tzdz�}t|tzdz�}|j||||dd�y)zPCanvas.rotate(theta)

        Rotate the canvas by the angle theta (in degrees).�rN)rr
rr�)r��thetar<r=s    r3�rotatez
Canvas.rotate�sB��
���
�S� �!�����
�S� �!�����q�!�a�R��A�q�)r5c��t|tzdz�}t|tzdz�}|jd||ddd�y)Nr�rr)r	r
r�)r��alpha�beta�tanAlpha�tanBetas     r3�skewzCanvas.skew�s>���u�r�z�C�'�(���t�r�z�C�'�(�����q�(�G�Q��1�5r5c�Z�|j�|jjd�y)aiSave the current graphics state to be restored later by restoreState.

        For example:
            canvas.setFont("Helvetica", 20)
            canvas.saveState()
            ...
            canvas.setFont("Courier", 9)
            ...
            canvas.restoreState()
            # if the save/restore pairs match then font is Helvetica 20 again.
        �qN)r&r�r+r�s r3r�zCanvas.saveState�s"��	
�����
�
���#�r5c�Z�|jjd�|j�y)zGrestore the graphics state to the matching saved state (see saveState).�QN)r�r+r*r�s r3r�zCanvas.restoreState�s ���
�
���#�����r5c	�p�|jjdt||��dt||��d��y)z�draw a line segment from (x1,y1) to (x2,y2) (with color, thickness and
        other attributes determined by the current graphics state).�n � m z l SN�r�r+r)r��x1�y1�x2�y2s     r3�linezCanvas.line�s'��	
�
�
���V�B��^�V�B��^�L�Mr5c	���|jjd�|D]<\}}}}|jjt||��dt||��d���>|jjd�y)a&Like line(), permits many lines to be drawn in one call.
           for example for the figure::
           
               |
             -- --
               |

             crosshairs = [(20,0,20,10), (20,30,20,40), (0,20,10,20), (30,20,40,20)]
             canvas.lines(crosshairs)
        rr�z lr Nr�)r��linelistr�r�r�r�s      r3r�zCanvas.lines�sd��	
�
�
���#��%�	N�M�R��2�b��J�J���V�B��^�V�B��^�L�M�	N��
�
���#�r5c	��|dz}|dz}|||z
|||z
f|||z|||zf||z
|||z
|f||z|||z|fg}	|j�|r$|j|�|r|j|�|r|j|�|j	|	�|r)|�|j|�|j
||z
||�|j�y)Nr�)r�r/r.r�r��setFontSize�drawRightStringr�)
r�r^r
r��gap�text�strokeColor�strokeWidth�fontSize�
crosshairss
          r3�crosszCanvas.cross�s��������s�
����4���!�C�%�(�!�A�c�E�!�A�d�F�);�a��f�Q�q��u�Q�=O�QR�SV�QV�WX�YZ�[_�Y_�`a�Pb�c�
����������,���!�!�+�.�����k�*��
�
�:����#�T�%5�%5�h�%?�� � ��4���D�1����r5c��t|�dkDsJd��t|�dkDsJd��g}|d|d}}|d|d}}|D]}|j||||f��|D]}	|j||	||	f��|j|�y)zPLays out a grid in current line style.  Supply list of
        x an y positions.rz$x coordinate list must have 2+ itemsz$y coordinate list must have 2+ itemsrrbN)rHr+r�)
r��xlist�ylistr��y0r��x0r�r^r
s
          r3�gridzCanvas.grid�s����5�z�A�~�E�E�E�~��5�z�A�~�E�E�E�~����q��5��9�B���q��5��9�B���	&�A��L�L�!�B�q���%�	&��	&�A��L�L�"�Q�r�!��%�	&��
�
�5�r5c	
�x�|jjdt||��dt||||||��d��y)z/Bezier curve with the four given control pointsr�r�z c SNr�)	r�r�r�r�r��x3�y3�x4�y4s	         r3�bezierz
Canvas.bezier�s4���
�
���!�"�b�>�6�"�b�"�b�"�b�+I�K�	r5c��tj|j��j||||||�|j	dd�y)z�Draw a partial ellipse inscribed within the rectangle x1,y1,x2,y2,
        starting at startAng degrees and covering extent degrees.   Angles
        start with 0 to the right (+x) and increase counter-clockwise.
        These should have x1<x2 and y1<y2.�r�rrN)r�
PDFPathObjectr��arc�_strokeAndFill)r�r�r�r�r��startAng�extents       r3rz
Canvas.arc�s;��
	� � �d�j�j�1�5�5�b��B�r�(�6�R����A�a� r5c	��|jjdt||||�zt|||jfz�y)zPdraws a rectangle with lower left corner at (x,y) and width and height as given.zn %s re N)r�r+r�PATH_OPSr)r�r^r
r�r�stroke�fills       r3rGzCanvas.rect�s@���
�
���*�v�a��E�6�'B�B�$�V�T�4�>�>�%A�B�C�	Dr5c��tj|j��j||||z
||z
�|j	||�y)z�Draw an ellipse defined by an enclosing rectangle.

        Note that (x1,y1) and (x2,y2) are the corner points of
        the enclosing rectangle.
        rN)rrr��ellipser)r�r�r�r�r�r
rs       r3rzCanvas.ellipses?��	� � �d�j�j�1�9�9�"�b�"�R�%��B��O����F�D�)r5c	���tj|j��}	|	jd||zzd||zz�|	j	||||||�|	j�|j
||�y)zcLike arc, but connects to the centre of the ellipse.
        Most useful for pie charts and PacMan!rr�N)rrr��moveTo�arcTo�closer)
r�r�r�r�r�r	r
r
r�ps
          r3�wedgezCanvas.wedgese��
�$�$�$�*�*�5��	����b��e��S�"�R�%�[�)�	����2�b��H�V�,�	���	����F�4�(r5c�X�||z
}||z}||z
}||z}	|j||||	||�y)zNdraw a cirle centered at (x_cen,y_cen) with radius r (special case of ellipse)N)r)
r��x_cen�y_cen�rr
rr�r�r�r�s
          r3�circlez
Canvas.circles>���Q�Y��
�Q�Y��
�Q�Y��
�Q�Y�����R��R��V�T�2r5c��tj|j��j|||||�|j	||�y)z|Draws a rectangle with rounded corners.  The corners are
        approximately quadrants of a circle, with the given radius.rN)rrr��	roundRectr)r�r^r
r�r�radiusr
rs        r3rzCanvas.roundRects:��	� � �d�j�j�1�;�;�A�q�%��QW�X����F�4�(r5c�Z�|jj|�}||j|<|Sr9)r��
addShadingr��r��shadingr�s   r3�_addShadingzCanvas._addShading$s+���y�y�#�#�G�,��"&����$���r5c�b�|j|�}|jjd|z�y)Nz/%s sh)r#r�r+r!s   r3�shadezCanvas.shade)s(������(���
�
���(�T�/�*r5c��ddlm}t|�\}	}
t|
|�}|||||||	t	|���}|j|�y)Nr)�PDFAxialShading��Function�
ColorSpace�Extend)r'r'rTrrr�r%)
r�r�r�r�r�rOrjr�r'�
colorSpace�ncolors�fcnr"s
             r3�linearGradientzCanvas.linearGradient-sL��<�.�v�6��
�G�!�'�9�5��!�"�b�"�b�3�%�.@��.H�J���
�
�7�r5c
��ddlm}t|�\}}	t|	|�}
|||d||||
|t	|���	}|j|�y)Nr)�PDFRadialShadingrar()r'r1rTrrr�r%)r�r^r
rrOrjr�r1r,r-r.r"s            r3�radialGradientzCanvas.radialGradient6sP��=�.�v�6��
�G�!�'�9�5��"�1�a��a��F�S�%�.@��.H�J���
�
�7�r5c�j�t|�}|j|||��}|�|j|�|r|j|�|r|j	|�|j|�|r|jd�|r|j	d�|�|jd�|j
|�y)z*Draws a string in the current text styles.��	directionNr)r�	beginText�setTextRenderMode�setCharSpace�setWordSpace�textLine�drawText)	r�r^r
r��mode�	charSpacer5�	wordSpacer�s	         r3�
drawStringzCanvas.drawStringIs��������N�N�1�a�9�N�5����Q�0�0��6��a�n�n�Y�/��a�n�n�Y�/�	�
�
�4���a�n�n�Q�'��a�n�n�Q�'���Q�0�0��3��
�
�a�r5c�r�t|t�s|jd�}|j||j|j
�}|r|t
|�dz
|zz
}|r,||jd�|jd�zdz
|zz
}|j||z
||��}	|�|	j|�|r|	j|�|r|	j|�|	j|�|r|	jd�|r|	jd�|�|	jd�|j|	�y)z2Draws a string right-aligned with the x coordinaterrr,� r4Nr�rBrI�decode�stringWidthrrrHr�r6r7r8r9r:r;�
r�r^r
r�r<r=r5r>r�r�s
          r3r�zCanvas.drawRightStringWs
���$��$��;�;�w�'�D�� � ��t�~�~�t�~�~�F���e��D�	�!��Y�6�6�e��e��
�
�4� 0����G�1D� D�Q� F�	�Q�Q�e��N�N�1�u�9�a�9�N�=����Q�0�0��6��a�n�n�Y�/��a�n�n�Y�/�	�
�
�4���a�n�n�Q�'��a�n�n�Q�'���Q�0�0��3��
�
�a�r5c�x�t|t�s|jd�}|j||j|j
�}|r|t
|�dz
|zz
}|r,||jd�|jd�zdz
|zz
}|j|d|zz
||��}	|�|	j|�|r|	j|�|r|	j|�|	j|�|r|	jd�|r|	jd�|�|	jd�|j|	�y)	zoDraws a string centred on the x coordinate. 
        
        We're British, dammit, and proud of our spelling!rrr,rAr�r4NrrBrEs
          r3�drawCentredStringzCanvas.drawCentredStringhs���$��$��;�;�w�'�D�� � ��t�~�~�t�~�~�F���e��D�	�!��Y�6�6�e��e��
�
�4� 0����G�1D� D�Q� F�	�Q�Q�e��N�N�1�s�5�y�=�!�y�N�A����Q�0�0��6��a�n�n�Y�/��a�n�n�Y�/�	�
�
�4���a�n�n�Q�'��a�n�n�Q�'���Q�0�0��3��
�
�a�r5c		�d�|j|d�}	|j||j|j�}
t	|	�dk(r�t
j
|��||dtvrq|	ddd}|	dd}|dtvr|d|z}|dd}|dtvr�|j|d|
zz
||||||��|j|d|
zz
||||||��y|	d}|j|d|
zz
||||||��t	|	�dkDr'||	dz}|j|d|
zz
||||||��yy)aDraws a string aligned on the first '.' (or other pivot character).

        The centre position of the pivot character will be used as x.
        So, you could draw a straight line down through all the decimals in a
        column of numbers, and anything without a decimal should be
        optically aligned with those that have.

        There is one special rule to help with accounting formatting.  Here's
        how normal numbers should be aligned on the 'dot'. Look at the
        LAST two::
        
           12,345,67
              987.15
               42
           -1,234.56
             (456.78)
             (456)
               27 inches
               13cm
        
        Since the last three do not contain a dot, a crude dot-finding
        rule would place them wrong. So we test for the special case
        where no pivot is found, digits are present, but the last character
        is not a digit.  We then work back from the end of the string
        This case is a tad slower but hopefully rare.
        
        rNrbrr�)r<r=r5r>)
r�rDrrrH�digitPat�searchrr�r?)
r�r^r
r��	pivotCharr<r=r5r>�parts�pivW�leftText�	rightTexts
             r3�drawAlignedStringzCanvas.drawAlignedString{sv��8�
�
�9�Q�'�����	�4�>�>�4�>�>�J���u�:��?�x���t�4�@�T�"�X�U[�E[��Q�x��"�~�H��a����I��2�,�f�,�$�R�L�9�4�	�#�A�b�>���2�,�f�,�
� � ��3�t�8��Q��t�y�'�9�
!�
>��O�O�A�c�$�h�J��9�4�9�'�9�
�
>�
�Q�x�H�� � ��3�t�8��Q��t�y�'�9�
!�
>��5�z�A�~�%��a��0�	�����#�d�(�
�A�y�t�y�"+�y� �B�r5c�:�|jj�}|S)z{Returns the list of PostScript font names available.

        Standard set now, but may grow in future with font embedding.)r��getAvailableFonts)r��	fontnamess  r3rRzCanvas.getAvailableFonts�s���I�I�/�/�1�	��r5c�t�ttjj��}|j	�|S)z-Convenience function to list all loaded fonts)rGr
�widthsrrh)r��namess  r3�listLoadedFonts0zCanvas.listLoadedFonts0�s)���Z�&�&�+�+�-�.��
�
�
���r5c
��||_||_|�|dz}||_tj|j�}|j
sw|jjs
t|dd�sS|jj|�}|jjd|�dt|��dt|��d��yyy)	z�Sets the font.  If leading not specified, defaults to 1.2 x
        font size. Raises a readable exception if an illegal font
        is supplied.  Font names are case-sensitive! Keeps track
        of font name and size for metrics.Nr�r-FzBT r,z Tf z TL ET)rrrr
r1r2r3r4r5r�r6r�r+r)r��
psfontnamer��leadingr:�pdffontnames      r3�setFontzCanvas.setFont�s���
$�������?��S�j�G���
��!�!�$�.�.�1��� � ��y�y� � ���5F�u�(M�"�i�i�;�;�J�G���
�
�!�!�K��PT��W]�^e�Wf�"g�h�)N�!r5c�v�|�|j}|�|j}|j|j||�y)z7Sets font size or leading without knowing the font faceN)rrr\r)r�r�rZs   r3r�zCanvas.setFontSize�s0���<������?�d�m�m�G����T�^�^�T�7�3r5c�n�tj||xs|j||jf|du�S)z1gets width of a string in the given font and sizeN)r
rDrr)r�r��fontNamer�s    r3rDzCanvas.stringWidth�s:���%�%�d�H�,F����%-�d�n�n�$=�h�$�>N�$O�Q�	Qr5c�`�||_|jjdt|�z�y)Nz%s w)rr�r+r)r�r�s  r3r�zCanvas.setLineWidth�s$������
�
���&�6�%�=�0�1r5c�d�|dvsJd��||_|jjd|z�y)z0=butt,1=round,2=square�rrr[z*Line caps allowed: 0=butt,1=round,2=squarez%d JN)rr�r+�r�r<s  r3�
setLineCapzCanvas.setLineCap�s1���w��L� L�L����
��
�
���&�4�-�(r5c�d�|dvsJd��||_|jjd|z�y)z0=mitre, 1=round, 2=bevelrbz-Line Joins allowed: 0=mitre, 1=round, 2=bevelz%d jN)rr�r+rcs  r3�setLineJoinzCanvas.setLineJoin�s1���w��O� O�O������
�
���&�4�-�(r5c�`�||_|jjdt|�z�y)Nz%s M)�_miterLimitr�r+r)r��limits  r3�
setMiterLimitzCanvas.setMiterLimit�s%�� ����
�
���&�6�%�=�0�1r5c��d}t|ttf�r||f}d}n
t|�sd}|D�cgc] }t|ttf�r|dks�|��"}}|st|ttf�r|dkrd}n|rt	|�dkrd}|rtd|�d|�d|����|jjd	t|��d
|�d��ycc}w)
z7Two notations.  pass two numbers, or an array and phase�rz1array should be a sequence of numbers or a numberz,array & phase should be non-negative numbersz%dash cycle should be larger than zerozsetDash: array=z phase=r<�[z] z dN)	rB�intrfr�sumrKr�r+r)r��array�phase�reasonr��bads      r3�setDashzCanvas.setDash�s������e�S��K�(��E�N�E��E��u��H�F��J�Q�z�!�S��K�'@�A��E�q�J��J��j���E�{�3�u�Q�w�C�F�
�s�5�z�1�}�<�F�����v�V�W�W��
�
�������>�?��Ks� C�Cc�*�tj�S)z�Returns a fresh path object.  Paths are used to draw
        complex figures.  The object returned follows the protocol
        for a pathobject.PDFPathObject instance)rrr�s r3�	beginPathzCanvas.beginPaths���'�'�)�)r5c��|�t|d|j�}|jjt	|j���|j
|||�y)z*Draw the path object in the mode indicatedNr)r5rr�r+rI�getCoder)r��aPathr
r�fillModes     r3�drawPathzCanvas.drawPath
sI�����u�[����@�H��
�
���#�e�m�m�o�.�/����F�4��1r5c�j�|jjt|||�|n|jf�yr9)r�r+rr)r�r
rrzs    r3rzCanvas._strokeAndFills.���
�
���(�6�4�X�=Q��W[�We�We�#e�f�gr5c���|�t|d|j�}|j�}t|||f}|tk(xrdxsd}|�|�|��}|j
j
|�y)zclip as well as drawingNrz W* z W )r5rrxrrr�r+)	r�ryr
rrz�gc�pathops�clip�items	         r3�clipPathzCanvas.clipPathsg�����u�[����@�H�
�]�]�_�����x�1G�(H�g��M�)�4�f�=����t�W�-���
�
���$�r5c� �t||||��S)zoReturns a fresh text object.  Text objects are used
           to add large amounts of text.  See PDFTextObjectr4)r)r�r^r
r5s    r3r6zCanvas.beginText s���T�1�a�9�=�=r5c�h�|jjt|j���y)zDraws a text objectN)r�r+rIrx)r��aTextObjects  r3r;zCanvas.drawText%s"���
�
���#�k�1�1�3�4�5r5c��|�tj}||_|jj	|j�y)a>Possible values None, 1 or 0
        If None the value from rl_config will be used.
        If on, the page data will be compressed, leading to much
        smaller files, but takes a little longer to create the files.
        This applies to all subsequent pages, or until setPageCompression()
        is next called.N)rr�r�r�r�)r�r�s  r3r�zCanvas.setPageCompression)s4���"�i�6O�6O�O� /����	�	� � ��!6�!6�7r5c��||_y)a�Allows hands-off animation of presentations :-)

        If this is set to a number, in full screen mode, Acrobat Reader
        will advance to the next page after this many seconds. The
        duration of the transition itself (fade/flicker etc.) is controlled
        by the 'duration' argument to setPageTransition; this controls
        the time spent looking at the page.  This is effective for all
        subsequent pages.N)r�)r��durations  r3�setPageDurationzCanvas.setPageDuration4s��&��r5c��i|_|sy|dvrdd|zf}ntjd��|dvrdd|zf}ntjd	��|d
vrdd|zf}ntjd��||g|g|g|gg|gd
�}		|	|}
i}d|d<d|z|d<d|z|d<|
D]
\}}
|
||<�||_y#t$rtjd|z��wxYw)asPDF allows page transition effects for use when giving
        presentations.  There are six possible effects.  You can
        just guive the effect name, or supply more advanced options
        to refine the way it works.  There are three types of extra
        argument permitted, and here are the allowed values::
        
            direction_arg = [0,90,180,270]
            dimension_arg = ['H', 'V']
            motion_arg = ['I','O'] (start at inside or outside)
        
        This table says which ones take which arguments::

            PageTransitionEffects = {
                'Split': [direction_arg, motion_arg],
                'Blinds': [dimension_arg],
                'Box': [motion_arg],
                'Wipe' : [direction_arg],
                'Dissolve' : [],
                'Glitter':[direction_arg]
                }
        
        Have fun!
        N)r�Zr�i�Diz/%dz$ directions allowed are 0,90,180,270)�H�V�Dmr�z$dimension values allowed are H and V)�I�O�Mz!motion values allowed are I and O)�Split�Blindsr��Wipe�Dissolve�GlitterzUnknown Effect Name "%s"z/Transr}z%dr,r )r�r�PDFError�KeyError)r��
effectnamer�r5�	dimension�motion�
direction_arg�
dimension_arg�
motion_arg�PageTransitionEffects�args�	transDictr`�values              r3r�zCanvas.setPageTransition@s8��< "�������&�!�5�9�#4�5�M��/�/�"H�I�I��
�"�!�3��?�3�M��/�/�"H�I�I��Y���s�V�|�,�J��/�/�"E�F�F�$�Z�0�$�o��<�#�_��$�o�
!��	K�(��4�D�
�	�$�	�&�����	�#���z�)�	�#�� �	#�L�S�%�"�I�c�N�	#�(�����	K��/�/�"<�z�"I�J�J�	K�s�>B1�1"Cc�8�dj|j�S)z�Return uncompressed contents of current page buffer.

        This is useful in creating test cases and assertions of what
        got drawn, without necessarily saving pages to diskr<)r0r�r�s r3�getCurrentPageContentzCanvas.getCurrentPageContent�s��
�y�y����$�$r5c��|jj}t|dd�}|�ddlm}|�x}|_|||<y)zCset one of the allowed enbtries in the documents viewer preferences�ViewerPreferencesNr)�ViewerPreferencesPDFDictionary)r��Catalogr5r'r�r�)r��prefr��catalog�VPr�s      r3�setViewerPreferencezCanvas.setViewerPreference�sA���)�)�#�#��
�W�0��
6��
�:�O�-K�-M�M�B��*���4�r5c�H�|jjj|S)�.you'll get an error here if none have been set�r�r�r��r�r�s  r3�getViewerPreferencezCanvas.getViewerPreference�s���y�y� � �2�2�4�8�8r5c�F�|jjj|=y)r�Nr�r�s  r3�delViewerPreferencezCanvas.delViewerPreference�s���I�I���/�/��5r5c���ddlm}m}m}t	|�r	||�}n7t|ttf�r	||�}nt|t�r||�}t|jj||�y)Nr)r�r$r{)r'r�r$r{rrBrGrDr�r�r�r�)r�r`r�r�r$r{s      r3�setCatalogEntryzCanvas.setCatalogEntry�sZ��O�O���<��e�$�E�
��t�E�l�
+��U�O�E�
��d�
#�!�%�(�E���	�	�!�!�#�e�,r5c�B�t|jj|�Sr9)r5r�r��r�r`s  r3�getCatalogEntryzCanvas.getCatalogEntry�s���t�y�y�(�(��-�-r5c�D�t|jj|�y)z-you'll get an error here if it's not been setN)�delattrr�r�r�s  r3�delCatalogEntryzCanvas.delCatalogEntry�s����	�	�!�!�#�&r5c��|jj}t|dd�}|�ddlm}|�x}|_ddlm}|j|||||��y)zadd a PDFPageLabel for pageNum�
PageLabelsNr)�
PDFPageLabels)�PDFPageLabel)r�r�r5r'r�r�r��addPageLabel)	r��pageNum�style�start�prefixr��PLr�r�s	         r3r�zCanvas.addPageLabel�sP���)�)�#�#��
�W�\�$�
/��
�:�>�&3�o�5�B��#�9�
�����U�5�� @�Ar5c��	|jS#t$r=ddlm}||�x|jj_|_|jcYSwxYw)z/get form from canvas, create the form if neededr)�AcroForm)r�r�reportlab.pdfbase.acroformr�r`)r�r�s  r3�acroFormzCanvas.acroForm�sJ��	!��=�=� ���	!�;�:B�4�.�H�D�I�I���'�$�-��=�=� �	!�s��AA�Ac��t|tttf�xst|t�}d}d}|rt|d�}	|	dk7}nGt|t�r7|r5t|jd�}	|	dk7}|r|j}|j}|rJ|j�|j	�|dk\r|j|�|r|j|�|j||||�|r|j�yy)z9draw a boundary as a rectangle (primarily for debugging).rbNr)rBrIrDrGrrrr-r�r/r�r/r�rtrGr�)
r��sbr�r�r�r�ssr6�dar<s
          r3rzCanvas.drawBoundary�s���
��C��d�+�
,�
D�
�2�e�0D����
��
���2��A��b��B�
��,�
-�"������$�A��b��B���H�H���\�\��
��N�N������"��!�t�T�&�&�q�)��4�<�<��#��	�	�"�R��f�%�
�t� � �"�2r5)NrNNrNNNNNNNNNNNN)rN)r�NNNNN)rr�)NNFr<FFN)NNNFr<FFN)rrNN)r)r)NrNr)NNrNr)NrNrNN)NrNrrNN)rrNNr�r�)r�)�rNNNr@)rr�)rr)NT)NrNNr9)NN)rrN)rrN)Nrrr�r�)NNN)�r�r�r��__doc__r�r�r�r&r*r�r$rGrerH�STATE_RANGEr�r>r@rCrHrNrPrRrUrXr[r^rardrjrmrprsrurwr�r�r�r�r�r�r�r�r�r�r�r�r�r�rr$r�r)r�r1r9rEr[rcrf�textAnnotation0rkrp�inkAnnotation0rtrrr�r]r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrGrrrrr#r%r/r2r?r�rGr�
decimalSymbolrPrRrWr\r�rDr�rdrfrjrtrvr{rr�r6r;r�r�r�r�r�r�r�r�r�r�r��propertyr�rr:r5r3rr�s���/�d��!%�!���� �#'�!%�!%� $������#^!�@�.&�>5�5�#�$)�5�7���u�S�!1�2�3�4�K�.�*�$�2�4L�l8�&"�
&�
&�(�(�$�)�,�	)�	)�)�)�5�)��S�j��+�+�.�"�� ���!� ��
K�Z	K�C�	&�'�=A�QV��/�2DH�RW��|-�|
#�
�3��$�2%)�N�(b�
Z�
%�O�=A�I[�gh�!%��r�$b�#�N�SW�/3�M�&_`�/3�Q�"!�H%�)� �3���,�*�)�+�!�
�M�(=�"�&�
$�*�6�
��2N�
� �"��
!�D�
*�)�3�)��
+���&��"�&7@�6M�6M�TX�de�qu�BF�6B�p��i� 4�Q�2�)�)�2��a�@�&*�2�h� �>�
6�	8�
&�;<�9<�H)�T%��9�6�-�.�'�	B��!��!�#r5�__main__zFor test scripts, look in tests)rr)8�__version__r��__all__r��rer=�stringr�mathrrr	r
�	reportlabr�reportlab.pdfbaserr
�reportlab.pdfgenr�reportlab.pdfgen.textobjectrr�reportlab.lib.colorsrrrrr�reportlab.lib.utilsrrrrrr�reportlab.lib.rl_accelrr�reportlab.lib.boxstuffr�compilerIr�
FILL_NON_ZEROrr4rJrTrrrtr�rrr��printr:r5r3�<module>r�s7��
��	��	��
����	���"�"��$�(�(�F�[�[�Z�Z�4�1��2�:�:�e����
��
���=�!�C�
��=�!�C�
��=�!�C�
��=�!�C�
��=�!�D�
��=�!�C�
��=�!�D�
��=�!�C���'�&2� 	�#O�JG�G�R8�8�8�|#�_�|#�|7�z��	�
+�,�r5

Zerion Mini Shell 1.0