;
0sDc           @   si  d  Z  d Z d Z d k Z d k Z d k Z d k l Z l Z l	 Z	 l
 Z
 l Z l Z l Z d k Z d k Td k l Z l Z l Z l Z l Z d k Z d k l Z d k l Z d	 k l Z d
 k l Z d k l Z l Z l  Z  d k! l" Z" d k! l# Z# e i$ d  Z% e"   Z& e' e( f Z) d Z* d Z+ h  d d e* f d <d d e+ f d <d d e* f d <d d e+ f d <d d e* f d <d d e+ f d <d d e* f d <d d e+ f d <Z, e i- Z. e i/ Z/ e i0 d j o d   Z1 n
 d   Z1 d   Z2 d e  i3 f d     YZ4 e/ o% d k5 Z5 e5 i6 e/ e7 e4  e4 _- n e8 d j o	 d GHn d S(   s5    $Id: canvas.py 2854 2006-05-10 12:57:21Z rgbecker $ sp   
The Canvas object is the primary interface for creating PDF files. See
doc/userguide.pdf for copious examples.
i   N(   s   joins   splits   strips   atois   replaces   uppers   digits(   s   *(   s   sins   coss   tans   pis   ceil(   s	   rl_config(   s   pdfutils(   s   pdfdoc(   s
   pdfmetrics(   s   pdfgeoms
   pathobjects
   textobject(   s   import_zlib(   s   fp_strs   \di    s   ns   Ss   f*s   fs   B*s   Bi   c         C   s   t  i  |   i   Sd  S(   N(   s   md5s   ss	   hexdigest(   s   s(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys	   _digester;   s    c         C   s,   t  t d   t i |   i    d  Sd  S(   Nc         C   s   d t  |   S(   Ns   %02x(   s   ords   x(   s   x(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   <lambda>@   s    s    (   s   joins   maps   md5s   ss   digest(   s   s(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys	   _digester?   s    c         C   s   d k  l } | o& | | i | i | i g  |  d <n d d d g } | o | | d <n | o | i
 | |   n | |  |  d <d  S(   N(   s   PDFArrays   Ci    i   s   Border(   s   reportlab.pdfbase.pdfdocs   PDFArrays   colors   reds   greens   blues   Ds   borders	   thicknesss	   dashArrays   append(   s   Ds   colors	   thicknesss	   dashArrays   PDFArrays   border(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys
   _annFormatB   s    &s   Canvasc           B   s  t  Z d  Z e d e e d d  Z d   Z d   Z d   Z e d  Z	 e
 e e	   Z d   Z e o d	   Z n d
   Z d   Z d e d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d e e e e e d  Z d d d  Z  d   Z! d   Z" d   Z# e e d   Z$ e e e d!  Z% d"   Z& d#   Z' d d e e d$  Z( d%   Z) d d&  Z* d d'  Z+ e d e d d(  Z, e d e d d)  Z- e- Z. e e d e d d*  Z/ e/ Z0 e d e d e e d+  Z1 e d e d d e e d,  Z2 d d e e d- d.  Z3 e d d/  Z4 d0   Z5 d1   Z6 d2   Z7 d3   Z8 d4   Z9 d5   Z: d d6  Z; d7   Z< d8   Z= d9   Z> d:   Z? d;   Z@ d<   ZA d=   ZB d>   ZC d?   ZD d@   ZE dA   ZF dB   ZG dC   ZH d dD dE  ZI d d dF  ZJ d d dG  ZK d d dH  ZL d d dI  ZM d d dJ  ZN dK   ZO dL   ZP dM   ZQ dN dO  ZR dP   ZS dQ   ZT dR   ZU dS   ZV e dT  ZW e e dU  ZX dV   ZY dW   ZZ dX   Z[ dY   Z\ dZ   Z] g  d d[  Z^ d\   Z_ d d d]  Z` d d d^  Za d d d_  Zb d`   Zc d da  Zd e db  Ze e d d dc dd de  Zf df   Zg RS(g   sN  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.

    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()
    i   i    c         C   s   | t j o t i } n | t j o t i } n | |  _ t i	 d | d | d |  |  _ | |  _ t |  _ | |  _ d |  _ t |  _ t |  _ h  |  _ |  i |  d |  _ g  |  _ |  i   d |  _ g  |  _ g  |  _ g  |  _ | |  _ t i |  _ |  i   |  i    g  |  _! d S(   s  Create a canvas of a given size. etc.

        You may pass a file-like object to filename as an alternative to
        a string.
        
        Most of the attributes are private - we will use set/get methods
        as the preferred interface.  Default page size is A4.s   compressions	   invariants   filenamei    i   N("   s   pagesizes   Nones	   rl_configs   defaultPageSizes	   invariants   filenames   selfs	   _filenames   pdfdocs   PDFDocuments   pageCompressions   _docs	   verbositys
   _verbositys   _onPages	   _pagesizes   _pageRotations   _pageTransitions   _pageDurations   _destinationss   setPageCompressions   _pageNumbers
   _codeStacks   _restartAccumulatorss   _annotationCounts	   _outliness   _psCommandsBeforePages   _psCommandsAfterPages   bottomups   defaultImageCachings   imageCachings   _make_preambles   init_graphics_states   state_stack(   s   selfs   filenames   pagesizes   bottomups   pageCompressions	   invariants	   verbosity(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   __init__|   s8       										
					

c         C   s  d |  _ d |  _ d |  _ d |  _ d |  _ d |  _ d |  _ d d d d d d f |  _ d |  _	 d |  _
 d |  _ d |  _ d |  _ d |  _ d d d d d d f |  _ d d d d d d f |  _ d |  _ d |  _ t |  _ d |  _ d |  _ d d d f |  _ d d d f |  _ d  S(   Ni    s   Times-Romani   f14.4f1.0f0.0id   (   s   selfs   _xs   _ys	   _fontnames	   _fontsizes   _dynamicFonts	   _textModes   _leadings   _currentMatrixs	   _fillModes
   _charSpaces
   _wordSpaces   _horizScales   _textRenderModes   _rises   _textLineMatrixs   _textMatrixs   _lineCaps	   _lineJoins   Nones	   _lineDashs
   _lineWidths   _mitreLimits   _fillColorRGBs   _strokeColorRGB(   s   self(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   init_graphics_state   s.    																		c         C   sE   h  } |  i } x |  i D] } | | | | <q W|  i i |  d  S(   N(   s   states   selfs   __dict__s   ds   STATE_ATTRIBUTESs   names   state_stacks   append(   s   selfs   states   names   d(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   push_state_stack   s    	
 c         C   s1   |  i d } |  i d =|  i } | i |  d  S(   Ni(   s   selfs   state_stacks   states   __dict__s   ds   update(   s   selfs   states   d(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   pop_state_stack   s    
	s  
     _x _y _fontname _fontsize _dynamicFont _textMode _leading _currentMatrix _fillMode
     _fillMode _charSpace _wordSpace _horizScale _textRenderMode _rise _textLineMatrix
     _textMatrix _lineCap _lineJoin _lineDash _lineWidth _mitreLimit _fillColorRGB
     _strokeColorRGBc         C   sQ   |  i i d  } |  i o d | |  _ n! d t |  i d  | f |  _ d  S(   Ns	   Helveticas%   1 0 0 1 0 0 cm BT %s 12 Tf 14.4 TL ETs'   1 0 0 -1 0 %s cm BT %s 12 Tf 14.4 TL ETi   (   s   selfs   _docs   getInternalFontNames   iNames   bottomups	   _preambles   fp_strs	   _pagesize(   s   selfs   iName(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   _make_preamble   s    
c         C   s   t  |  Sd  S(   N(   s
   _escapePDFs   s(   s   selfs   s(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   _escape   s    c         C   s   |  i i |  d S(   s  identify 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(   s   selfs   _docs	   setAuthors   author(   s   selfs   author(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys	   setAuthor   s     c         C   s   |  i i |  d S(   sH   accepts a func(yyyy,mm,dd,hh,m,s) used to create embedded formatted dateN(   s   selfs   _docs   setDateFormatters   dateFormatter(   s   selfs   dateFormatter(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   setDateFormatter  s     c         C   s#   |  i i i | | | d | d S(   sl  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.
        s   closedN(   s   selfs   _docs   outlines   addOutlineEntrys   keys   levels   titles   closed(   s   selfs   titles   keys   levels   closed(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   addOutlineEntry  s    / c         G   s   |  i i i |  f |   d S(   s  nametree 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(   s   selfs   _docs   outlines   setNamess   nametree(   s   selfs   nametree(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   setOutlineNames09  s     c         C   s   |  i i |  d S(   sc   write a title into the PDF file that won't automatically display
           in the document itself.N(   s   selfs   _docs   setTitles   title(   s   selfs   title(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   setTitleJ  s     c         C   s   |  i i |  d S(   se   write a subject into the PDF file that won't automatically display
           in the document itself.N(   s   selfs   _docs
   setSubjects   subject(   s   selfs   subject(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys
   setSubjectO  s     c         C   s   t  |  i  d j Sd S(   sH   Info function - app can call it after showPage to see if it needs a savei    N(   s   lens   selfs   _code(   s   self(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   pageHasDataT  s     c         C   s   |  i i i   d S(   s   Specify that Acrobat Reader should start with the outline tree visible.
        showFullScreen() and showOutline() conflict; the one called last
        wins.N(   s   selfs   _docs   _catalogs   showOutline(   s   self(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   showOutlineX  s     c         C   s   |  i i i   d S(   s   Specify that Acrobat Reader should start in full screen mode.
        showFullScreen() and showOutline() conflict; the one called last
        wins.N(   s   selfs   _docs   _catalogs   showFullScreen(   s   self(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   showFullScreen0^  s     c         C   s  |  i i d  t i   } |  i d | _ |  i d | _ |  i	 | _
 |  i | _ | i |  i  | i |  i  |  i t j	 o |  i | _ n |  i |  i g |  i |  i } | i |  |  i |  |  i |  |  i i |  |  i o |  i |  i  n |  i   d S(   s8   Close the current page and possibly start on a new page.s    i    i   N(    s   selfs   _codes   appends   pdfdocs   PDFPages   pages	   _pagesizes	   pagewidths
   pageheights   _pageRotations   Rotates   _currentPageHasImagess	   hasImagess   setPageTransitions   _pageTransitions   setCompressions   _pageCompressions   _pageDurations   Nones   Durs   _psCommandsBeforePages	   _preambles   _psCommandsAfterPages   strms	   setStreams   _setXObjectss   _setAnnotationss   _docs   addPages   _onPages   _pageNumbers
   _startPage(   s   selfs   strms   page(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   showPaged  s&     !
 c         C   s1   |  i d |  _ |  i   |  i   g  |  _ d  S(   Ni   (   s   selfs   _pageNumbers   _restartAccumulatorss   init_graphics_states   state_stack(   s   self(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys
   _startPage~  s    

c         C   s   | |  _ d S(   s   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(   s   funcs   selfs   _onPage(   s   selfs   func(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   setPageCallBack  s     c         C   s   |  i | _ d  S(   N(   s   selfs   _annotationrefss   pages   Annots(   s   selfs   page(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   _setAnnotations  s    c         C   s<   |  i } | o |  i i |  } | | _ n
 t | _ d S(   sK   for pages and forms, define the XObject dictionary for resources, if neededN(	   s   selfs   _formsinuses   formss   _docs   xobjDicts   xobjectsdicts   things   XObjectss   None(   s   selfs   things   formss   xobjectsdict(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   _setXObjects  s     	c         C   s>   |  i } y | | SWn t i |  } | | <n X| Sd S(   sD   get a reference to a (possibly undefined, possibly unbound) bookmarkN(   s   selfs   _destinationss   ds   names   pdfdocs   Destinations   result(   s   selfs   names   results   d(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   _bookmarkReference  s     	s   Fitc   
      C   s  |  i |  } |  i i   |  i i   }	 | t	 j o
 d } n | t	 j o
 d } n | t	 j o
 d } n | t	 j o
 d } n | t	 j o
 d } n | d j o | i | | |  n | d j o | i   n | d j o | i |  n | d j o | i |  n | d j o | i | | | |  ne | d j o | i   nJ | d j o | i |  n, | d	 j o | i |  n d
 | f  | i |	  | Sd S(   s|  
        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?)s   nulls   XYZs   Fits   FitHs   FitVs   FitRs   FitBs   FitBHs   FitBVs   Unknown Fit type %sN(   s   selfs   _bookmarkReferences   keys   dests   _docs   inPages   thisPageRefs   pagerefs   lefts   Nones   tops   bottoms   rights   zooms   fits   xyzs   fiths   fitvs   fitrs   fitbs   fitbhs   fitbvs   setPage(
   s   selfs   keys   fits   lefts   tops   bottoms   rights   zooms   dests   pageref(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   bookmarkPage  sB    $ 




s   XYZc      
   K   s)   |  i | d | d | d | d d Sd S(   s   Bind 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.s   fits   tops   lefts   zoomi    N(   s   selfs   bookmarkPages   keys   fits   tops   left(   s   selfs   keys   tops   lefts   fits   kw(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   bookmarkHorizontalAbsolute  s     c         K   s5   |  i | |  \ } } |  i | | d | | d S(   s<   w.r.t. the current transformation, bookmark this horizontal.s   leftN(	   s   selfs   absolutePositions	   relativeXs	   relativeYs   lefts   tops   bookmarkHorizontalAbsolutes   keys   kw(   s   selfs   keys	   relativeXs	   relativeYs   kws   tops   left(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   bookmarkHorizontal  s     c         C   s4   |  i i d |  i i |   |  i i |  d S(   sI  use 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   /%s DoN(   s   selfs   _codes   appends   _docs   getXObjectNames   names   _formsinuse(   s   selfs   name(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   doForm  s      c         C   s   |  i i |  Sd S(   s*   Query whether form XObj really exists yet.N(   s   selfs   _docs   hasForms   name(   s   selfs   name(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   hasForm  s     c         C   sO   d |  _ d k l } | | | | | |  } | i
 |   | i | i f Sd S(   s   Draw an Image into the specified rectangle.  If width and
        height are omitted, they are calculated from the image size.
        Also allow file names as well as images.  The size in pixels
        of the image is returned.i   (   s   PDFImageN(   s   selfs   _currentPageHasImagess	   pdfimagess   PDFImages   images   xs   ys   widths   heights   img_objs   drawInlineImage(   s   selfs   images   xs   ys   widths   heights   img_objs   PDFImage(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   drawInlineImage  s     	c         C   s  d |  _ t |  t d  j o t d | | f  } n# | i   }	 t |	 t	 |   } |  i
 i |  } |  i
 i i | t  }
 |
 oX t i | | d | }
 | |
 _ |  i |
  |  i
 i |
 |  |  i
 i | |
  n | t j o |
 i } n | t j o |
 i } n |  i   |  i | |  |  i | |  |  i i d |  |  i   |  i  i |  |
 i |
 i f Sd S(   s  Draws the image (ImageReader object or filename) as specified.

        "image" may be an image filename or a ImageReader object.  If width
        and height are not given, the "natural" width and height in pixels
        is used at a scale of 1 point to 1 pixel.

        The mask parameter 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)

        The method returns the width and height of the underlying image since
        this is often useful for layout algorithms.

        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.  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.i   s    s   %s%ss   masks   /%s DoN(!   s   selfs   _currentPageHasImagess   types   images	   _digesters   masks   names
   getRGBDatas   rawdatas   strs   _docs   getXObjectNames   regNames
   idToObjects   gets   Nones   imgObjs   pdfdocs   PDFImageXObjects   _setXObjectss	   References   addForms   widths   heights	   saveStates	   translates   xs   ys   scales   _codes   appends   restoreStates   _formsinuse(   s   selfs   images   xs   ys   widths   heights   masks   names   regNames   rawdatas   imgObj(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys	   drawImage'  s2     		

c         C   s}   |  i o9 |  i d } |  i d =| \ |  _ |  _ |  _ |  _ n7 g  |  _ g  |  _ d |  _ g  |  _ g  |  _ t	 |  _ d  S(   Nii   (
   s   selfs
   _codeStacks   saveds   _codes   _formsinuses   _annotationrefss	   _formDatas   _psCommandsAfterPages   _currentPageHasImagess   None(   s   selfs   saved(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   _restartAccumulatorsi  s    

"					c         C   s_   |  i |  i |  i |  i f } |  i i |  g  |  _ d |  _ g  |  _ g  |  _ t	 |  _ d S(   sV   when you enter a form, save accumulator info not related to the form for page (if any)i   N(
   s   selfs   _codes   _formsinuses   _annotationrefss	   _formDatas   saveds
   _codeStacks   appends   _currentPageHasImagess   None(   s   selfs   saved(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   _pushAccumulatorsw  s     				c         C   sU   |  i   |  i   |  i o |  i   n | | | | | f |  _
 |  i i   d S(   s}  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(   s   selfs   push_state_stacks   init_graphics_states   _codes   _pushAccumulatorss   names   lowerxs   lowerys   upperxs   upperys	   _formDatas   _docs   inForm(   s   selfs   names   lowerxs   lowerys   upperxs   uppery(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys	   beginForm  s     


c   	   	   C   s   |  i \ } } } } } |  i \ } } | t
 j o
 | } n | t
 j o
 | } n t i d | d | d | d |  } |  i | _ | i |  i g |  i  |  i |  |  i |  |  i i | |  |  i   |  i   d S(   sl   emit the current collection of graphics operations as a Form
           as declared previously in beginForm.s   lowerxs   lowerys   upperxs   upperyN(   s   selfs	   _formDatas   names   lowerxs   lowerys   upperxs   upperys	   _pagesizes   ws   hs   Nones   pdfdocs   PDFFormXObjects   forms   _pageCompressions   compressions   setStreamLists	   _preambles   _codes   _setXObjectss   _setAnnotationss   _docs   addForms   _restartAccumulatorss   pop_state_stack(	   s   selfs   names   forms   hs   lowerxs   upperxs   upperys   ws   lowery(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   endForm  s        
 
$
c         C   s  d t  i  |  i   } |  i i |  } |  i i i	 | t
  } | oJ t i | d  } |  i |  |  i i | |  |  i i | |  n | d j o |  i i d |  n: | d j o |  i i d |  n |  i i d |  |  i i |  d S(   s  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.
        s   PSs   
i    s   /%s Doi   N(   s   md5s   commands	   hexdigests   rawNames   selfs   _docs   getXObjectNames   regNames
   idToObjects   gets   Nones   psObjs   pdfdocs   PDFPostScriptXObjects   _setXObjectss	   References   addForms   positions   _psCommandsBeforePages   appends   _codes   _psCommandsAfterPages   _formsinuse(   s   selfs   commands   positions   rawNames   regNames   psObj(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   addPostScriptCommand  s     c         C   s$  | o% |  i \ } } d d | | f } n | o | \ } } } } |  i
 | |  \ } } |  i
 | |  \ } } |  i
 | |  \ } } |  i
 | |  \ } }
 | | | | f } | | | |
 f } t |  t |  f \ } } t |  t |  f \ }	 } | | |	 | f } n | Sd  S(   Ni    (   s   rects   selfs	   _pagesizes   ws   hs   relatives   lxs   lys   uxs   uys   absolutePositions   xlls   ylls   xurs   yurs   xuls   yuls   xlrs   ylrs   xss   yss   mins   xmins   ymins   maxs   xmaxs   ymax(   s   selfs   rects   relatives   xmins   xss   ymins   ymaxs   lxs   lys   xmaxs   ylrs   yss   xlls   uys   uxs   xurs   hs   yurs   yuls   ws   xuls   ylls   xlr(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   _absRect  s    c         K   s;   |  i | |  } |  i t i | | | |  | |  d S(   s&   DA is the default appearance string???N(   s   selfs   _absRects   Rects   relatives   _addAnnotations   pdfdocs   FreeTextAnnotations   contentss   DAs   kws   names	   addtopage(   s   selfs   contentss   DAs   Rects	   addtopages   names   relatives   kw(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   freeTextAnnotation  s     c         K   s8   |  i | |  } |  i t i | | |  | |  d S(   s!   Experimental, but works.
        N(   s   selfs   _absRects   Rects   relatives   _addAnnotations   pdfdocs   TextAnnotations   contentss   kws   names	   addtopage(   s   selfs   contentss   Rects	   addtopages   names   relatives   kw(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   textAnnotation  s     c         K   s~   t   |  i | |  } | o5 d d d t d t d t d t d d f f } n |  i t	 i
 | | | |  | |  d  S(   Nid   (   s   NotImplementedErrors   selfs   _absRects   Rects   relatives   InkLists   hs   ws   _addAnnotations   pdfdocs   InkAnnotations   contentss   kws   names	   addtopage(   s   selfs   contentss   InkLists   Rects	   addtopages   names   relatives   kw(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   inkAnnotation  s     5c	   
      K   s8   |  i | | | | | d d d | d | d | |	 Sd S(   s9  rectangular 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.s   relativei    s	   thicknesss   colors	   dashArrayN(   s   selfs   linkRects   contentss   destinationnames   Rects	   addtopages   names	   thicknesss   colors	   dashArrays   kw(
   s   selfs   contentss   destinationnames   Rects	   addtopages   names	   thicknesss   colors	   dashArrays   kw(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   linkAbsolute  s     c
         K   sr   |  i |  } |  i | |  } | |
 d <| |
 d <| |
 d <t	 |
 | | |	  |  i t i |
   | |  Sd S(   s   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
        s   Rects   Contentss   DestinationN(   s   selfs   _bookmarkReferences   destinationnames   destinations   _absRects   Rects   relatives   kws   contentss
   _annFormats   colors	   thicknesss	   dashArrays   _addAnnotations   pdfdocs   LinkAnnotations   names	   addtopage(   s   selfs   contentss   destinationnames   Rects	   addtopages   names   relatives	   thicknesss   colors	   dashArrays   kws   destination(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   linkRect  s     


s   URIc         K   s  d k  l } l } l } l } | d |  } | d  | d <| d  | d <| |  i | |   | d <|   }	 | d  |	 d <| |  }
 | |  |	 d	 <| d
 j o |
 |	 d
 <n6 | d j o |
 |	 d <d |	 d <n t d |   |	 | d <t | | | |  |  i |  d S(   s  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.(   s   PDFDictionarys   PDFNames   PDFArrays	   PDFStrings   dicts   Annots   Types   Links   Subtypes   Rects   Actions   Ss   URIs   GoToRs   Fs   [ 0 /XYZ null null null ]s   Ds   Unknown linkURI kind '%s's   AN(   s   reportlab.pdfbase.pdfdocs   PDFDictionarys   PDFNames   PDFArrays	   PDFStrings   kws   anns   selfs   _absRects   rects   relatives   As   urls   uris   kinds
   ValueErrors
   _annFormats   colors	   thicknesss	   dashArrays   _addAnnotation(   s   selfs   urls   rects   relatives	   thicknesss   colors	   dashArrays   kinds   kws   As   uris   PDFArrays   PDFNames   PDFDictionarys	   PDFStrings   ann(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   linkURL  s&    	 	

c         C   s_   |  i d } |  _ | o d t |  } n |  i i | |  | o |  i	 |  n d  S(   Ni   s   NUMBER(
   s   selfs   _annotationCounts   counts   names   reprs   _docs   addAnnotations
   annotations	   addtopages   _annotatePage(   s   selfs
   annotations   names	   addtopages   count(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   _addAnnotation7  s     c         C   s&   |  i i |  } |  i i |  d  S(   N(   s   selfs   _docs   refAnnotations   names   refs   _annotationrefss   append(   s   selfs   names   ref(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   _annotatePage>  s    c         C   s   |  i Sd S(   s9   get the page number for the current page being generated.N(   s   selfs   _pageNumber(   s   self(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   getPageNumberB  s     c         C   s8   t  |  i  o |  i   n |  i i |  i |   d S(   s   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(   s   lens   selfs   _codes   showPages   _docs
   SaveToFiles	   _filename(   s   self(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   saveF  s      c         C   s2   t  |  i  o |  i   n |  i i |   Sd S(   s   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.N(   s   lens   selfs   _codes   showPages   _docs
   GetPDFData(   s   self(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys
   getpdfdataM  s      c         C   s   | |  _ |  i   d S(   sP   accepts a 2-tuple in points for paper size for this
        and subsequent pagesN(   s   sizes   selfs	   _pagesizes   _make_preamble(   s   selfs   size(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   setPageSizeT  s     	c         C   s(   | d d j p
 t d  | |  _ d S(   s7   Instruct display device that this page is to be rotatedf90.0f0.0s)   Rotation must be a multiple of 90 degreesN(   s   rots   AssertionErrors   selfs   _pageRotation(   s   selfs   rot(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   setPageRotationZ  s     c         C   s@   t  |  } | d j o |  i |  } n |  i i |  d S(   s   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.i    N(   s   strs   ss   escapeds   selfs   _escapes   _codes   append(   s   selfs   ss   escaped(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys
   addLiteral_  s
     c         C   s   |  i \ } } } } } } | | | | }	 | |	 } | |	 } | | | | |	 } | |	 }
 | |	 } | | | | |	 } |  i | | | |
 | |  d S(   sJ  I 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(   s   selfs   _currentMatrixs   selfas   selfbs   selfcs   selfds   selfes   selffs   dets   resultas   resultcs   resultes   resultds   resultbs   resultfs	   transform(   s   selfs   selffs   selfes   selfds   selfcs   selfbs   selfas   resultcs   resultfs   dets   resultds   resultes   resultbs   resulta(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   resetTransformsl  s     

c      
   C   s  t  o |  i \ } } } }	 } } | | | | | | |	 | | | | | | | |	 | | | | | | | | |	 | | f |  _ n |  i o |  i d d d j o t |  i d  }
 t t |
 d d ! \ } } } }	 } } t |
  d j o t |
  d p d } | t | | | | | | |	 | | | | | | | |	 | | | | | | | | |	 | |  |  i d <n* |  i i d t | | | | | |   d S(	   so   adjoin a mathematical transform to the current graphics state matrix.
           Not recommended for beginners.iis    cmii   s    %s cms   %s cmN(   s   ENABLE_TRACKINGs   selfs   _currentMatrixs   a0s   b0s   c0s   d0s   e0s   f0s   as   bs   cs   ds   es   fs   _codes   splits   Ls   maps   floats   lens   joins   ss   fp_strs   append(   s   selfs   as   bs   cs   ds   es   fs   f0s   b0s   d0s   Ls   a0s   c0s   e0s   s(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys	   transform  s     o"(*zc         C   sj   t  o t d  n |  i \ } } } } } } | | | | | }
 | | | | | }	 |
 |	 f Sd S(   sK   return the absolute position of x,y in user space w.r.t. default user spaces0   tracking not enabled! (canvas.ENABLE_TRACKING=0)N(   s   ENABLE_TRACKINGs
   ValueErrors   selfs   _currentMatrixs   as   bs   cs   ds   es   fs   xs   ys   xps   yp(   s   selfs   xs   ys   as   cs   bs   es   ds   fs   yps   xp(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   absolutePosition  s     c         C   s    |  i d d d d | |  d S(   sz   move the origin from the current (0,0) point to the (dx,dy) point
           (with respect to the current graphics state).i   i    N(   s   selfs	   transforms   dxs   dy(   s   selfs   dxs   dy(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys	   translate  s     c         C   s    |  i | d d | d d  d S(   s   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.i    N(   s   selfs	   transforms   xs   y(   s   selfs   xs   y(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   scale  s     c         C   sI   t  | t d  } t | t d  } |  i | | | | d d  d S(   sP   Canvas.rotate(theta)

        Rotate the canvas by the angle theta (in degrees).i   i    N(   s   coss   thetas   pis   cs   sins   ss   selfs	   transform(   s   selfs   thetas   cs   s(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   rotate  s     c         C   sH   t  | t d  } t  | t d  } |  i d | | d d d  d  S(   Ni   i   i    (   s   tans   alphas   pis   tanAlphas   betas   tanBetas   selfs	   transform(   s   selfs   alphas   betas   tanAlphas   tanBeta(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   skew  s    c         C   s   |  i   |  i i d  d S(   si  Save 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.
        s   qN(   s   selfs   push_state_stacks   _codes   append(   s   self(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys	   saveState  s     
c         C   s   |  i i d  |  i   d S(   sG   restore the graphics state to the matching saved state (see saveState).s   QN(   s   selfs   _codes   appends   pop_state_stack(   s   self(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   restoreState  s     c         C   s0   |  i i d t | |  t | |  f  d S(   s   draw a line segment from (x1,y1) to (x2,y2) (with color, thickness and
        other attributes determined by the current graphics state).s   n %s m %s l SN(   s   selfs   _codes   appends   fp_strs   x1s   y1s   x2s   y2(   s   selfs   x1s   y1s   x2s   y2(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   line  s     c         C   sm   |  i i d  xF | D]> \ } } } } |  i i d t | |  t | |  f  q W|  i i d  d S(   s  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)
        s   ns	   %s m %s ls   SN(	   s   selfs   _codes   appends   linelists   x1s   y1s   x2s   y2s   fp_str(   s   selfs   linelists   y2s   x2s   y1s   x1(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   lines  s    	  0c   
      C   s   t  |  d j p
 t d  t  |  d j p
 t d  g  } | d | d f \ } } | d | d f \ } }	 x' | D] } | i
 | | | | f  q{ Wx' | D] } | i
 | | |	 | f  q W|  i |  d S(   sP   Lays out a grid in current line style.  Supply list of
        x an y positions.i   s$   x coordinate list must have 2+ itemss$   y coordinate list must have 2+ itemsi    iN(   s   lens   xlists   AssertionErrors   ylists   liness   y0s   y1s   x0s   x1s   xs   appends   ys   self(
   s   selfs   xlists   ylists   liness   ys   xs   y1s   y0s   x0s   x1(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   grid  s       c	   	   
   C   s<   |  i i d t | |  t | | | | | |  f  d S(   s/   Bezier curve with the four given control pointss   n %s m %s c SN(   s   selfs   _codes   appends   fp_strs   x1s   y1s   x2s   y2s   x3s   y3s   x4s   y4(	   s   selfs   x1s   y1s   x2s   y2s   x3s   y3s   x4s   y4(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   bezier	  s     iZ   c   	      C   s   t  i | | | | | |  } |  i
 i d t | d d    x, | D]$ } |  i
 i d t | d   qG W|  i
 i d  d S(   sC  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.

        Contributed to piddlePDF by Robert Kern, 28/7/99.
        Trimmed down by AR to remove color stuff for pdfgen.canvas and
        revert to positive coordinates.

        The algorithm is an elliptical generalization of the formulae in
        Jim Fitzsimmon's TeX tutorial <URL: http://www.tinaja.com/bezarc1.pdf>.s   n %s mi    i   s   %s cs   SN(   s   pdfgeoms	   bezierArcs   x1s   y1s   x2s   y2s   startAngs   extents	   pointLists   selfs   _codes   appends   fp_strs   curve(	   s   selfs   x1s   y1s   x2s   y2s   startAngs   extents   curves	   pointList(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   arc  s     " "c         C   s;   |  i i d t | | | |  t | | |  i f  d S(   sP   draws a rectangle with lower left corner at (x,y) and width and height as given.s   n %s re N(   s   selfs   _codes   appends   fp_strs   xs   ys   widths   heights   PATH_OPSs   strokes   fills	   _fillMode(   s   selfs   xs   ys   widths   heights   strokes   fill(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   rect%  s     c   	      C   s   t  i | | | | d d  } |  i i	 d t
 | d d    x, | D]$ } |  i i	 d t
 | d   qG W|  i i	 t | | |  i f  d S(   s   Draw an ellipse defined by an enclosing rectangle.

        Note that (x1,y1) and (x2,y2) are the corner points of
        the enclosing rectangle.

        Uses bezierArc, which conveniently handles 360 degrees.
        Special thanks to Robert Kern.i    ih  s   n %s mi   s   %s cN(   s   pdfgeoms	   bezierArcs   x1s   y1s   x2s   y2s	   pointLists   selfs   _codes   appends   fp_strs   curves   PATH_OPSs   strokes   fills	   _fillMode(	   s   selfs   x1s   y1s   x2s   y2s   strokes   fills	   pointLists   curve(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   ellipse*  s     " "c	         C   s   | | d } | | d } t i | | | | | |  }	 |  i i d t | |   |  i i d t |	 d d    x, |	 D]$ }
 |  i i d t |
 d   q W|  i i d t | |   |  i i t | | |  i f  d S(	   sc   Like arc, but connects to the centre of the ellipse.
        Most useful for pie charts and PacMan!f2.0s   n %s ms   %s li    i   s   %s cs   %s l N(   s   x1s   x2s   x_cens   y1s   y2s   y_cens   pdfgeoms	   bezierArcs   startAngs   extents	   pointLists   selfs   _codes   appends   fp_strs   curves   PATH_OPSs   strokes   fills	   _fillMode(   s   selfs   x1s   y1s   x2s   y2s   startAngs   extents   strokes   fills	   pointLists   curves   x_cens   y_cen(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   wedge;  s     " "c   
      C   sH   | | }	 | | } | | } | | } |  i |	 | | | | |  d S(   sN   draw a cirle centered at (x_cen,y_cen) with radius r (special case of ellipse)N(   s   x_cens   rs   x1s   x2s   y_cens   y1s   y2s   selfs   ellipses   strokes   fill(
   s   selfs   x_cens   y_cens   rs   strokes   fills   y2s   y1s   x2s   x1(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   circleM  s     



c      	   C   s  d | } | } | | } | | } | | | } | | | } | | } | }	 |	 | } |	 | } |	 | | }
 |	 | | } |	 | } |  i i d t | |	   |  i i d t | |	   |  i i d t | |	 | | | |   |  i i d t | |
   |  i i d t | | | | | |   |  i i d t | |   |  i i d t | | | | | |
   |  i i d t | |   |  i i d t | | | |	 | |	   |  i i d  |  i i t | | |  i f  d S(   s|   Draws a rectangle with rounded corners.  The corners are
        approximately quadrants of a circle, with the given radius.f0.44719999999999999s   n %s ms   %s ls   %s cs   hN(   s   radiuss   ts   xs   x0s   x1s   x2s   widths   x3s   x4s   x5s   ys   y0s   y1s   y2s   heights   y3s   y4s   y5s   selfs   _codes   appends   fp_strs   PATH_OPSs   strokes   fills	   _fillMode(   s   selfs   xs   ys   widths   heights   radiuss   strokes   fills   y1s   y0s   y3s   y2s   y5s   y4s   x2s   x3s   x0s   x1s   x4s   x5s   t(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys	   roundRectV  s2     






))))c         C   s0   |  i | |  } | i |  |  i |  d S(   s*   Draws a string in the current text styles.N(   s   selfs	   beginTexts   xs   ys   ts   textLines   texts   drawText(   s   selfs   xs   ys   texts   t(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys
   drawString  s     c         C   sO   |  i | |  i |  i  } |  i | | |  } | i
 |  |  i |  d S(   s2   Draws a string right-aligned with the x coordinateN(   s   selfs   stringWidths   texts	   _fontnames	   _fontsizes   widths	   beginTexts   xs   ys   ts   textLines   drawText(   s   selfs   xs   ys   texts   widths   t(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   drawRightString  s
     c         C   sS   |  i | |  i |  i  } |  i | d | |  } | i
 |  |  i |  d S(   s+   Draws a string centred on the x coordinate.f0.5N(   s   selfs   stringWidths   texts	   _fontnames	   _fontsizes   widths	   beginTexts   xs   ys   ts   textLines   drawText(   s   selfs   xs   ys   texts   widths   t(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   drawCentredString  s
     s   .c   	      C   s]  | i | d  } |  i | |  i |  i  } t	 |  d j o$ t
 i |  t j	 o | d t j o | d d d !} | d d } x1 | d t j o | d | } | d d !} q W|  i | d | | |  |  i | d | | |  nf | d } |  i | d | | |  t	 |  d j o- | | d } |  i | d | | |  n d S(   s  Draws 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.
        
        i   ii    f0.5N(   s   texts   splits	   pivotChars   partss   selfs   stringWidths	   _fontnames	   _fontsizes   pivWs   lens   digitPats   searchs   Nones   digitss   leftTexts	   rightTexts   drawRightStrings   xs   ys
   drawString(	   s   selfs   xs   ys   texts	   pivotChars   pivWs   partss   leftTexts	   rightText(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   drawAlignedString  s"     : 
c         C   s!   |  i i   } | i   | Sd S(   s{   Returns the list of PostScript font names available.

        Standard set now, but may grow in future with font embedding.N(   s   selfs   _docs   getAvailableFontss	   fontnamess   sort(   s   selfs	   fontnames(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   getAvailableFonts  s     
c         C   s   |  i i |  d S(   s"   add a new font for subsequent use.N(   s   selfs   _docs   addFonts   fontObj(   s   selfs   fontObj(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   addFont  s     c         C   s,   x% t  i D] } |  i t  i |  q
 Wd S(   sn   Ensures the standard 14 fonts are available in the system encoding.
        Called by canvas on initializationN(   s
   pdfmetricss   standardFontss   fontNames   selfs   addFonts   fontsByName(   s   selfs   fontName(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   _addStandardFonts  s     
 c         C   s!   t  i i   } | i   | Sd S(   s-   Convenience function to list all loaded fontsN(   s
   pdfmetricss   widthss   keyss   namess   sort(   s   selfs   names(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   listLoadedFonts0  s     
c         C   s   | |  _ | |  _ | t j o | d } n | |  _ t i	 |  i  } t | d d  |  _ |  i o? |  i i |  } |  i i d | t |  t |  f  n d S(   s   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.f1.2s   _dynamicFonti    s   BT %s %s Tf %s TL ETN(   s
   psfontnames   selfs	   _fontnames   sizes	   _fontsizes   leadings   Nones   _leadings
   pdfmetricss   getFonts   fonts   getattrs   _dynamicFonts   _docs   getInternalFontNames   pdffontnames   _codes   appends   fp_str(   s   selfs
   psfontnames   sizes   leadings   pdffontnames   font(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   setFont  s     			c         C   sN   | t j o |  i } n | t j o |  i } n |  i |  i | |  d S(   s7   Sets font size or leading without knowing the font faceN(   s   sizes   Nones   selfs	   _fontsizes   leadings   _leadings   setFonts	   _fontname(   s   selfs   sizes   leading(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   setFontSize  s       c         C   s   t  i | | |  Sd S(   s1   gets width of a string in the given font and sizeN(   s
   pdfmetricss   stringWidths   texts   fontNames   fontSize(   s   selfs   texts   fontNames   fontSize(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   stringWidth  s     c         C   s'   | |  _ |  i i d t |   d  S(   Ns   %s w(   s   widths   selfs
   _lineWidths   _codes   appends   fp_str(   s   selfs   width(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   setLineWidth  s    	c         C   sA   | d d d f j p
 t d  | |  _ |  i i d |  d S(   s   0=butt,1=round,2=squarei    i   i   s*   Line caps allowed: 0=butt,1=round,2=squares   %d JN(   s   modes   AssertionErrors   selfs   _lineCaps   _codes   append(   s   selfs   mode(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys
   setLineCap  s      	c         C   sA   | d d d f j p
 t d  | |  _ |  i i d |  d S(   s   0=mitre, 1=round, 2=beveli    i   i   s-   Line Joins allowed: 0=mitre, 1=round, 2=bevels   %d jN(   s   modes   AssertionErrors   selfs	   _lineJoins   _codes   append(   s   selfs   mode(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   setLineJoin  s      	c         C   s'   | |  _ |  i i d t |   d  S(   Ns   %s M(   s   limits   selfs   _miterLimits   _codes   appends   fp_str(   s   selfs   limit(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   setMiterLimit  s    	c         C   s   t  |  t j p t  |  t j o |  i i d | | f  nt t  |  t j p t  |  t	 j oM | d j p
 t
 d  d i t t |   } |  i i d | | f  n d S(   s7   Two notations.  pass two numbers, or an array and phases   [%s %s] 0 di    s   phase is a length in user spaces    s	   [%s] %s dN(   s   types   arrays   IntTypes	   FloatTypes   selfs   _codes   appends   phases   ListTypes	   TupleTypes   AssertionErrors   joins   maps   strs	   textarray(   s   selfs   arrays   phases	   textarray(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   setDash  s     &&c         C   s   t  i   Sd S(   s   Returns a fresh path object.  Paths are used to draw
        complex figures.  The object returned follows the protocol
        for a pathobject.PDFPathObject instanceN(   s
   pathobjects   PDFPathObject(   s   self(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys	   beginPath&  s     c         C   sF   | i   } t | | |  i f } d | | f } |  i
 i |  d S(   s*   Draw the path object in the mode indicateds   %s %sN(   s   aPaths   getCodes   gcs   PATH_OPSs   strokes   fills   selfs	   _fillModes   pathopss   items   _codes   append(   s   selfs   aPaths   strokes   fills   items   gcs   pathops(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   drawPath,  s     "c         C   sf   | i   } t | | |  i f } |  i t	 j o d p d } d | | | f } |  i i |  d S(   s   clip as well as drawings    W* s    W s   %s%s%sN(   s   aPaths   getCodes   gcs   PATH_OPSs   strokes   fills   selfs	   _fillModes   pathopss   FILL_EVEN_ODDs   clips   items   _codes   append(   s   selfs   aPaths   strokes   fills   clips   items   gcs   pathops(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   clipPath3  s
     "c         C   s   t  i |  | |  Sd S(   sz   Returns a fresh text object.  Text objects are used
           to add large amounts of text.  See textobject.PDFTextObjectN(   s
   textobjects   PDFTextObjects   selfs   xs   y(   s   selfs   xs   y(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys	   beginText=  s     c         C   s    |  i i t | i     d S(   s   Draws a text objectN(   s   selfs   _codes   appends   strs   aTextObjects   getCode(   s   selfs   aTextObject(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   drawTextB  s     c         C   sV   | t j o t i  } n | o t o d |  _ n
 | |  _ |  i i |  i  d S(   s>  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.i    N(   s   pageCompressions   Nones	   rl_configs   zlibs   selfs   _pageCompressions   _docs   setCompression(   s   selfs   pageCompression(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   setPageCompressionF  s      	c         C   s   | |  _ d S(   s  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(   s   durations   selfs   _pageDuration(   s   selfs   duration(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   setPageDurationT  s     s   Hs   Ic         C   s  h  |  _ | o d Sn | d d d d g j o d d | f } n
 d d	  | d
 d g j o d d | f } n
 d d  | d d g j o d d | f }	 n
 d d  h  d | |	 g <d | g <d |	 g <d | g <d g  <d | g <} y | | } Wn  t j
 o d d |  n Xh  }
 d |
 d <d | |
 d <d | |
 d <x | D] \ } } | |
 | <qaW|
 |  _ d S(   s7  PDF 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!
        Ni    iZ   i   i  s   Dis   /%ds   PDFErrors$    directions allowed are 0,90,180,270s   Hs   Vs   Dms   /s$   dimension values allowed are H and Vs   Is   Os   Ms!   motion values allowed are I and Os   Splits   Blindss   Boxs   Wipes   Dissolves   Glitters   Unknown Effect Name "%s"s   /Transs   Types   %ds   Ds   S(   s   selfs   _pageTransitions
   effectnames	   directions   direction_args	   dimensions   dimension_args   motions
   motion_args   PageTransitionEffectss   argss   KeyErrors	   transDicts   durations   keys   value(   s   selfs
   effectnames   durations	   directions	   dimensions   motions   direction_args   argss   values
   motion_args	   transDicts   keys   dimension_args   PageTransitionEffects(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   setPageTransition`  s4     				N	
 c         C   s   d i  |  i  Sd S(   s   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 disks   
N(   s   joins   selfs   _code(   s   self(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   getCurrentPageContent  s     (h   s   __name__s
   __module__s   __doc__s   Nones   __init__s   init_graphics_states   push_state_stacks   pop_state_stacks   splits   STATE_ATTRIBUTESs   ranges   lens   STATE_RANGEs   _make_preambles   _instanceEscapePDFs   _escapes	   setAuthors   setDateFormatters   addOutlineEntrys   setOutlineNames0s   setTitles
   setSubjects   pageHasDatas   showOutlines   showFullScreen0s   showPages
   _startPages   setPageCallBacks   _setAnnotationss   _setXObjectss   _bookmarkReferences   bookmarkPages   bookmarkHorizontalAbsolutes   bookmarkHorizontals   doForms   hasForms   drawInlineImages	   drawImages   _restartAccumulatorss   _pushAccumulatorss	   beginForms   endForms   addPostScriptCommands   _absRects   freeTextAnnotations   textAnnotations   textAnnotation0s   inkAnnotations   inkAnnotation0s   linkAbsolutes   linkRects   linkURLs   _addAnnotations   _annotatePages   getPageNumbers   saves
   getpdfdatas   setPageSizes   setPageRotations
   addLiterals   resetTransformss	   transforms   absolutePositions	   translates   scales   rotates   skews	   saveStates   restoreStates   lines   liness   grids   beziers   arcs   rects   ellipses   wedges   circles	   roundRects
   drawStrings   drawRightStrings   drawCentredStrings   drawAlignedStrings   getAvailableFontss   addFonts   _addStandardFontss   listLoadedFonts0s   setFonts   setFontSizes   stringWidths   setLineWidths
   setLineCaps   setLineJoins   setMiterLimits   setDashs	   beginPaths   drawPaths   clipPaths	   beginTexts   drawTexts   setPageCompressions   setPageDurations   setPageTransitions   getCurrentPageContent(    (    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   CanvasM   s   - 9	 			
		4														L			B		
	$$																					5			2										
	Hs   __main__s(   For test scripts, look in reportlab/test(9   s   __version__s   __doc__s   ENABLE_TRACKINGs   oss   syss   res   strings   joins   splits   strips   atois   replaces   uppers   digitss   tempfiles   typess   maths   sins   coss   tans   pis   ceils   md5s	   reportlabs	   rl_configs   reportlab.pdfbases   pdfutilss   pdfdocs
   pdfmetricss   reportlab.pdfgens   pdfgeoms
   pathobjects
   textobjects   reportlab.lib.utilss   import_zlibs   fp_strs   compiles   digitPats   zlibs	   TupleTypes   ListTypes	   _SeqTypess   FILL_EVEN_ODDs   FILL_NON_ZEROs   PATH_OPSs   _escapes
   _escapePDFs   _instanceEscapePDFs
   hexversions	   _digesters
   _annFormats   _PDFColorSetters   Canvass   news   instancemethods   Nones   __name__()   s   uppers   Canvass   pdfutilss   replaces   strips   tans   fp_strs	   _digesters
   pathobjects   tempfiles   res	   rl_configs   splits
   textobjects   FILL_NON_ZEROs   pis   sins   digitPats
   _annFormats   ceils   syss   atois   pdfgeoms
   _escapePDFs   news   PATH_OPSs   md5s   digitss   FILL_EVEN_ODDs   coss   __version__s   joins	   _SeqTypess   import_zlibs   zlibs   _instanceEscapePDFs   __doc__s
   pdfmetricss   ENABLE_TRACKINGs   pdfdocs   os(    (    sA   /home/packages/reportlab/reportlab_2_0/reportlab/pdfgen/canvas.pys   ?   sP   			1	%		
				     i	