Example #1
0
    def drawString(self, s, x, y, angle=0, link_info=None, **_svgAttrs):
        s = asNative(s)
        if self.verbose: print("+++ SVGCanvas.drawString")

        if self._fillColor != None:
            self.setColor(self._fillColor)
            s = self._escape(s)
            st = self._formatStyle(TEXT_STYLES)
            if angle != 0:
                st = st + " rotate(%f %f %f);" % (angle, x, y)
            st = st + " fill: %s;" % self.style['fill']
            text = transformNode(self.doc,
                                 "text",
                                 x=x,
                                 y=y,
                                 style=st,
                                 transform="translate(0,%d) scale(1,-1)" %
                                 (2 * y),
                                 **_svgAttrs)
            content = self.doc.createTextNode(s)
            text.appendChild(content)

            if link_info:
                text = self._add_link(text, link_info)

            self.currGroup.appendChild(text)
Example #2
0
 def drawit(F, w=400, h=200, fontSize=12, slack=2, gap=5):
     D = Drawing(w, h)
     th = 2 * gap + fontSize * 1.2
     gh = gap + 0.2 * fontSize
     y = h
     maxx = 0
     for fontName in F:
         y -= th
         text = fontName + asNative(
             b": I should be totally horizontal and enclosed in a box and end in alphabetagamma \xc2\xa2\xc2\xa9\xc2\xae\xc2\xa3\xca\xa5\xd0\x96\xd6\x83\xd7\x90\xd9\x82\xe0\xa6\x95\xce\xb1\xce\xb2\xce\xb3"
         )
         textWidth = stringWidth(text, fontName, fontSize)
         maxx = max(maxx, textWidth + 20)
         D.add(
             Group(
                 Rect(
                     8,
                     y - gh,
                     textWidth + 4,
                     th,
                     strokeColor=colors.red,
                     strokeWidth=0.5,
                     fillColor=colors.lightgrey,
                 ),
                 String(10, y, text, fontName=fontName, fontSize=fontSize),
             )
         )
         y -= 5
     return maxx, h - y + gap, D
Example #3
0
    def _issueT1String(self, fontObj, x, y, s):
        fc = fontObj
        code_append = self.code_append
        fontSize = self._fontSize
        fontsUsed = self._fontsUsed
        escape = self._escape
        if not isUnicode(s):
            try:
                s = s.decode('utf8')
            except UnicodeDecodeError as e:
                i, j = e.args[2:4]
                raise UnicodeDecodeError(
                    *(e.args[:4] +
                      ('%s\n%s-->%s<--%s' %
                       (e.args[4], s[i - 10:i], s[i:j], s[j:j + 10]), )))

        for f, t in unicode2T1(s, [fontObj] + fontObj.substitutionFonts):
            if f != fc:
                psName = asNative(f.face.name)
                code_append('(%s) findfont %s scalefont setfont' %
                            (psName, fp_str(fontSize)))
                if psName not in fontsUsed:
                    fontsUsed.append(psName)
                fc = f
            code_append('%s m (%s) show ' % (fp_str(x, y), escape(t)))
            x += f.stringWidth(t.decode(f.encName), fontSize)
        if fontObj != fc:
            self._font = None
            self.setFont(fontObj.face.name, fontSize)
Example #4
0
 def drawString(self, x, y, s, angle=0, text_anchor='left', textRenderMode=0):
     needFill = textRenderMode in (0,2,4,6) 
     needStroke = textRenderMode in (1,2,5,6) 
     if needFill or needStroke:
         if text_anchor!='left':
             textLen = stringWidth(s, self._font,self._fontSize)
             if text_anchor=='end':
                 x -= textLen
             elif text_anchor=='middle':
                 x -= textLen/2.
             elif text_anchor=='numeric':
                 x -= numericXShift(text_anchor,s,textLen,self._font,self._fontSize)
         fontObj = getFont(self._font)
         if not self.code[self._fontCodeLoc]:
             psName = asNative(fontObj.face.name)
             self.code[self._fontCodeLoc]='(%s) findfont %s scalefont setfont' % (psName,fp_str(self._fontSize))
             if psName not in self._fontsUsed:
                 self._fontsUsed.append(psName)
         if angle!=0:
             self.code_append('gsave %s translate %s rotate' % (fp_str(x,y),fp_str(angle)))
             x = y = 0
         oldColor = self._color
         if fontObj._dynamicFont:
             self._textOut(x, y, s, textRenderMode=textRenderMode)
         else:
             self._issueT1String(fontObj,x,y,s, textRenderMode=textRenderMode)
         self.setColor(oldColor)
         if angle!=0:
             self.code_append('grestore')
Example #5
0
    def __call__(self,arg,default=None):
        '''try to map an arbitrary arg to a color instance
        '''
        if isinstance(arg,Color): return arg
        if isinstance(arg,(tuple,list)):
            assert 3<=len(arg)<=4, 'Can only convert 3 and 4 sequences to color'
            assert 0<=min(arg) and max(arg)<=1
            return len(arg)==3 and Color(arg[0],arg[1],arg[2]) or CMYKColor(arg[0],arg[1],arg[2],arg[3])
        elif isStr(arg):
            arg = asNative(arg)
            C = cssParse(arg)
            if C: return C
            if arg in self.extraColorsNS: return self.extraColorsNS[arg]
            C = getAllNamedColors()
            s = arg.lower()
            if s in C: return C[s]
            try:
                return toColor(eval(arg))
            except:
                pass

        try:
            return HexColor(arg)
        except:
            default = '#FFFFFF'
            # default = '#000000'
            logging.warning("(colors.py) defaulting color to #000000...")
            if default is None:
                raise ValueError('Invalid color value %r' % arg)
            return HexColor(default)
Example #6
0
    def extractText(self, stuff):
        "returns all words"
        stuff = asNative(stuff, 'latin1')  #basicall assumes 1-1 bytes
        self.cursor = 0
        self.maxLen = len(stuff)
        self.stuff = stuff
        self.textFound = []
        # this matches start of a text array, or start of a string
        patStartTextAny = re.compile(r"(\[\s*\d*\s*\()|(\()")

        while self.cursor < self.maxLen:
            match = patStartTextAny.search(self.stuff, self.cursor)
            if match is None:
                break  # we're done
            # set to character after the match, which is in the text
            firstChar = match.group()[0]
            if firstChar == '[':
                #complex case: it is an array
                # find a sequence of strings
                self.cursor = match.start()
                self.textFound.append(self.readTextArray())
            elif firstChar == '(':
                #simple case, it's a string
                self.cursor = match.end()
                self.textFound.append(self.readString())

        text = '\n'.join(self.textFound)

        #now unescape for human readability
        for (find, repl) in [("\\(", "("), ("\\)", ")"), ("\\n", "\n")]:
            text = text.replace(find, repl)
        return text
Example #7
0
    def __call__(self,arg,default=None):
        '''try to map an arbitrary arg to a color instance
        '''
        if isinstance(arg,Color): return arg
        if isinstance(arg,(tuple,list)):
            assert 3<=len(arg)<=4, 'Can only convert 3 and 4 sequences to color'
            assert 0<=min(arg) and max(arg)<=1
            return len(arg)==3 and Color(arg[0],arg[1],arg[2]) or CMYKColor(arg[0],arg[1],arg[2],arg[3])
        elif isStr(arg):
            arg = asNative(arg)
            C = cssParse(arg)
            if C: return C
            if arg in self.extraColorsNS: return self.extraColorsNS[arg]
            C = getAllNamedColors()
            s = arg.lower()
            if s in C: return C[s]
            try:
                return toColor(eval(arg))
            except:
                pass

        try:
            return HexColor(arg)
        except:
            if default is None:
                raise ValueError('Invalid color value %r' % arg)
            return default
Example #8
0
 def drawit(F, w=400, h=200, fontSize=12, slack=2, gap=5):
     D = Drawing(w, h)
     th = 2 * gap + fontSize * 1.2
     gh = gap + .2 * fontSize
     y = h
     maxx = 0
     for fontName in F:
         y -= th
         text = fontName + asNative(
             b': I should be totally horizontal and enclosed in a box and end in alphabetagamma \xc2\xa2\xc2\xa9\xc2\xae\xc2\xa3\xca\xa5\xd0\x96\xd6\x83\xd7\x90\xd9\x82\xe0\xa6\x95\xce\xb1\xce\xb2\xce\xb3'
         )
         textWidth = stringWidth(text, fontName, fontSize)
         maxx = max(maxx, textWidth + 20)
         D.add(
             Group(
                 Rect(8,
                      y - gh,
                      textWidth + 4,
                      th,
                      strokeColor=colors.red,
                      strokeWidth=.5,
                      fillColor=colors.lightgrey),
                 String(10, y, text, fontName=fontName, fontSize=fontSize)))
         y -= 5
     return maxx, h - y + gap, D
Example #9
0
    def _issueT1String(self,fontObj,x,y,s):
        fc = fontObj
        code_append = self.code_append
        fontSize = self._fontSize
        fontsUsed = self._fontsUsed
        escape = self._escape
        if not isUnicode(s):
            try:
                s = s.decode('utf8')
            except UnicodeDecodeError as e:
                i,j = e.args[2:4]
                raise UnicodeDecodeError(*(e.args[:4]+('%s\n%s-->%s<--%s' % (e.args[4],s[i-10:i],s[i:j],s[j:j+10]),)))

        for f, t in unicode2T1(s,[fontObj]+fontObj.substitutionFonts):
            if f!=fc:
                psName = asNative(f.face.name)
                code_append('(%s) findfont %s scalefont setfont' % (psName,fp_str(fontSize)))
                if psName not in fontsUsed:
                    fontsUsed.append(psName)
                fc = f
            code_append('%s m (%s) show ' % (fp_str(x,y),escape(t)))
            x += f.stringWidth(t.decode(f.encName),fontSize)
        if fontObj!=fc:
            self._font = None
            self.setFont(fontObj.face.name,fontSize)
Example #10
0
    def extractText(self, stuff):
        "returns all words"
        stuff = asNative(stuff,'latin1')    #basicall assumes 1-1 bytes
        self.cursor = 0
        self.maxLen = len(stuff)
        self.stuff = stuff
        self.textFound = []
        # this matches start of a text array, or start of a string
        patStartTextAny = re.compile(r"(\[\s*\d*\s*\()|(\()")

        while self.cursor < self.maxLen:
            match = patStartTextAny.search(self.stuff, self.cursor)
            if match is None:
                break  # we're done
            # set to character after the match, which is in the text
            firstChar = match.group()[0]
            if firstChar == '[':
                #complex case: it is an array
                # find a sequence of strings
                self.cursor = match.start()
                self.textFound.append(self.readTextArray())
            elif firstChar == '(':
                #simple case, it's a string
                self.cursor = match.end()
                self.textFound.append(self.readString())

        text = '\n'.join(self.textFound)

        #now unescape for human readability
        for (find, repl) in [("\\(", "("),
                             ("\\)", ")"),
                             ("\\n", "\n")]:
            text = text.replace(find, repl)
        return text
Example #11
0
def HexColor(val, htmlOnly=False, hasAlpha=False):
    """This function converts a hex string, or an actual integer number,
    into the corresponding color.  E.g., in "#AABBCC" or 0xAABBCC,
    AA is the red, BB is the green, and CC is the blue (00-FF).

    An alpha value can also be given in the form #AABBCCDD or 0xAABBCCDD where
    DD is the alpha value if hasAlpha is True.

    For completeness I assume that #aabbcc or 0xaabbcc are hex numbers
    otherwise a pure integer is converted as decimal rgb.  If htmlOnly is true,
    only the #aabbcc form is allowed.

    >>> HexColor('#ffffff')
    Color(1,1,1,1)
    >>> HexColor('#FFFFFF')
    Color(1,1,1,1)
    >>> HexColor('0xffffff')
    Color(1,1,1,1)
    >>> HexColor('16777215')
    Color(1,1,1,1)

    An '0x' or '#' prefix is required for hex (as opposed to decimal):

    >>> HexColor('ffffff')
    Traceback (most recent call last):
    ValueError: invalid literal for int() with base 10: 'ffffff'

    >>> HexColor('#FFFFFF', htmlOnly=True)
    Color(1,1,1,1)
    >>> HexColor('0xffffff', htmlOnly=True)
    Traceback (most recent call last):
    ValueError: not a hex string
    >>> HexColor('16777215', htmlOnly=True)
    Traceback (most recent call last):
    ValueError: not a hex string

    """ #" for emacs

    if isStr(val):
        val = asNative(val)
        b = 10
        if val[:1] == '#':
            val = val[1:]
            b = 16
            if len(val) == 8:
                alpha = True
        else:
            if htmlOnly:
                raise ValueError('not a hex string')
            if val[:2].lower() == '0x':
                b = 16
                val = val[2:]
                if len(val) == 8:
                    alpha = True
        val = int(val,b)
    if hasAlpha:
        return Color(((val>>24)&0xFF)/255.0,((val>>16)&0xFF)/255.0,((val>>8)&0xFF)/255.0,(val&0xFF)/255.0)
    return Color(((val>>16)&0xFF)/255.0,((val>>8)&0xFF)/255.0,(val&0xFF)/255.0)
Example #12
0
def HexColor(val, htmlOnly=False, hasAlpha=False):
    """This function converts a hex string, or an actual integer number,
    into the corresponding color.  E.g., in "#AABBCC" or 0xAABBCC,
    AA is the red, BB is the green, and CC is the blue (00-FF).

    An alpha value can also be given in the form #AABBCCDD or 0xAABBCCDD where
    DD is the alpha value if hasAlpha is True.

    For completeness I assume that #aabbcc or 0xaabbcc are hex numbers
    otherwise a pure integer is converted as decimal rgb.  If htmlOnly is true,
    only the #aabbcc form is allowed.

    >>> HexColor('#ffffff')
    Color(1,1,1,1)
    >>> HexColor('#FFFFFF')
    Color(1,1,1,1)
    >>> HexColor('0xffffff')
    Color(1,1,1,1)
    >>> HexColor('16777215')
    Color(1,1,1,1)

    An '0x' or '#' prefix is required for hex (as opposed to decimal):

    >>> HexColor('ffffff')
    Traceback (most recent call last):
    ValueError: invalid literal for int() with base 10: 'ffffff'

    >>> HexColor('#FFFFFF', htmlOnly=True)
    Color(1,1,1,1)
    >>> HexColor('0xffffff', htmlOnly=True)
    Traceback (most recent call last):
    ValueError: not a hex string
    >>> HexColor('16777215', htmlOnly=True)
    Traceback (most recent call last):
    ValueError: not a hex string

    """ #" for emacs

    if isStr(val):
        val = asNative(val)
        b = 10
        if val[:1] == '#':
            val = val[1:]
            b = 16
            if len(val) == 8:
                alpha = True
        else:
            if htmlOnly:
                raise ValueError('not a hex string')
            if val[:2].lower() == '0x':
                b = 16
                val = val[2:]
                if len(val) == 8:
                    alpha = True
        val = int(val,b)
    if hasAlpha:
        return Color(((val>>24)&0xFF)/255.0,((val>>16)&0xFF)/255.0,((val>>8)&0xFF)/255.0,(val&0xFF)/255.0)
    return Color(((val>>16)&0xFF)/255.0,((val>>8)&0xFF)/255.0,(val&0xFF)/255.0)
Example #13
0
    def drawString(self,
                   s,
                   x,
                   y,
                   angle=0,
                   link_info=None,
                   text_anchor='left',
                   textRenderMode=0,
                   **_svgAttrs):
        if textRenderMode == 3: return  #invisible
        s = asNative(s)
        if self.verbose: print("+++ SVGCanvas.drawString")
        needFill = textRenderMode == 0 or textRenderMode == 2 or textRenderMode == 4 or textRenderMode == 6
        needStroke = textRenderMode == 1 or textRenderMode == 2 or textRenderMode == 5 or textRenderMode == 6

        if (self._fillColor != None and needFill) or (self._strokeColor != None
                                                      and needStroke):
            if not text_anchor in ['start', 'inherited', 'left']:
                textLen = stringWidth(s, self._font, self._fontSize)
                if text_anchor == 'end':
                    x -= textLen
                elif text_anchor == 'middle':
                    x -= textLen / 2.
                elif text_anchor == 'numeric':
                    x -= numericXShift(text_anchor, s, textLen, self._font,
                                       self._fontSize)
                else:
                    raise ValueError('bad value for text_anchor ' +
                                     str(text_anchor))
            s = self._escape(s)
            st = self._formatStyle(TEXT_STYLES)
            if angle != 0:
                st = st + " rotate(%s);" % self.fp_str(angle, x, y)
            if needFill:
                st += self._formatStyle(EXTRA_FILL_STYLES)
            else:
                st += " fill:none;"
            if needStroke:
                st += self._formatStyle(EXTRA_STROKE_STYLES)
            else:
                st += " stroke:none;"
            #if textRenderMode>=4:
            #   _gstate_clipPathSetOrAddself, -1, 1, 0  /*we are adding*/
            text = transformNode(self.doc,
                                 "text",
                                 x=x,
                                 y=y,
                                 style=st,
                                 transform="translate(0,%d) scale(1,-1)" %
                                 (2 * y),
                                 **_svgAttrs)
            content = self.doc.createTextNode(s)
            text.appendChild(content)

            if link_info:
                text = self._add_link(text, link_info)

            self.currGroup.appendChild(text)
 def drawImage(self, image, x, y, width, height, embed=True):
     buf = getBytesIO()
     image.save(buf,'png')
     buf = asNative(base64.b64encode(buf.getvalue()))
     self.currGroup.appendChild(
             transformNode(self.doc,'image',
                 x=x,y=y,width=width,height=height,
                 href="data:image/png;base64,"+buf,
                 )
             )
Example #15
0
    def __init__(self, value = "", **args):
        value = asNative(value)
        for k, v in args.items():
            setattr(self, k, v)

        if self.quiet:
            if self.lquiet is None:
                self.lquiet = max(inch * 0.25, self.barWidth * 10.0)
                self.rquiet = max(inch * 0.25, self.barWidth * 10.0)
        else:
            self.lquiet = self.rquiet = 0.0

        Barcode.__init__(self, value)
Example #16
0
    def __init__(self, value = "", **args):
        value = asNative(value)
        for k, v in args.items():
            setattr(self, k, v)

        if self.quiet:
            if self.lquiet is None:
                self.lquiet = max(inch * 0.25, self.barWidth * 10.0)
                self.rquiet = max(inch * 0.25, self.barWidth * 10.0)
        else:
            self.lquiet = self.rquiet = 0.0

        Barcode.__init__(self, value)
Example #17
0
 def __styledWrap__(self, style):
     fontName = getattr(style,'fontname',None)
     if fontName is None:
         fontName = style.fontName
     fontSize = getattr(style,'fontsize',None)
     if fontSize is None:
         fontSize = style.fontSize
     leading = getattr(style,'leading',1.2*fontSize)
     if fontSize is None:
         fontSize = style.fontSize
     L = asNative(self._text).split('\n')
     self._width = max([stringWidth(_, fontName, fontSize) for _ in L])
     self._height = len(L)*leading
     return self._width, self._height
Example #18
0
    def __init__(self, value='', **args):
        value = str(value) if isinstance(value, int) else asNative(value)

        for k, v in args.items():
            setattr(self, k, v)

        if self.quiet:
            if self.lquiet is None:
                self.lquiet = max(inch * 0.25, self.barWidth * 10.0)
            if self.rquiet is None:
                self.rquiet = max(inch * 0.25, self.barWidth * 10.0)
        else:
            self.lquiet = self.rquiet = 0.0

        MultiWidthBarcode.__init__(self, value)
Example #19
0
    def __init__(self, value='', **args):
        value = str(value) if isinstance(value,int) else asNative(value)
            
        for k, v in args.items():
            setattr(self, k, v)

        if self.quiet:
            if self.lquiet is None:
                self.lquiet = max(inch * 0.25, self.barWidth * 10.0)
            if self.rquiet is None:
                self.rquiet = max(inch * 0.25, self.barWidth * 10.0)
        else:
            self.lquiet = self.rquiet = 0.0

        MultiWidthBarcode.__init__(self, value)
def parse_catalog(filename):
    """Validate and parse XML.  This will complain if invalid

    We fully parse the XML and turn into Python variables, so that any encoding
    issues are confronted here rather than in the template
    """
    xml = open(filename).read()
    if isUnicode(xml):
        xml = xml.encode('utf8')  #required for python 2.7 & >=3.3
    p = pyRXPU.Parser()
    tree = p.parse(xml)
    tagTree = TagWrapper(tree)
    request_a_quote = [109, 110, 4121, 4122, 4123]
    # we now need to de-duplicate; the query returns multiple rows with different images
    # in them.  if id is same, assume it's the same product.
    ids_seen = set()
    products = []
    for prodTag in tagTree:
        id = int(str(prodTag.ProductId1))  #extract tag content
        if id in ids_seen:
            continue
        else:
            ids_seen.add(id)
        prod = Product()
        prod.id = id
        prod.modelNumber = int(str(prodTag.ModelNumber))
        prod.archived = (str(prodTag.Archived) == 'true')
        prod.name = fix(prodTag.ModelName)
        prod.summary = fix(prodTag.Summary)
        prod.description = fix(prodTag.Description)

        #originally the images came from a remote site.  We have stashed them in
        #the img/ subdirectory, so just chop off the final part of the path.
        #asNative required for python 2.7 & >=3.3
        prod.image = os.path.split(asNative(fix(
            prodTag.ImageUrl)))[-1].replace(' ', '')

        if prod.modelNumber in request_a_quote:
            prod.price = "Call us on 01635 246830 for a quote"
        else:
            prod.price = '&pound;' + str(
                prodTag.UnitCost)[0:len(str(prodTag.UnitCost)) - 2]
        if prod.archived:
            pass
        else:
            products.append(prod)
    products.sort(key=lambda x: x.modelNumber)
    return products
Example #21
0
    def __init__(self, value='', **args):

        if type(value) is type(1):
            value = asNative(value)

        for (k, v) in args.items():
            setattr(self, k, v)

        if self.quiet:
            if self.lquiet is None:
                self.lquiet = max(inch * 0.25, self.barWidth * 10.0)
                self.rquiet = max(inch * 0.25, self.barWidth * 10.0)
        else:
            self.lquiet = self.rquiet = 0.0

        MultiWidthBarcode.__init__(self, value)
Example #22
0
    def __init__(self, value='', **args):

        if type(value) is type(1):
            value = asNative(value)
            
        for (k, v) in args.items():
            setattr(self, k, v)

        if self.quiet:
            if self.lquiet is None:
                self.lquiet = max(inch * 0.25, self.barWidth * 10.0)
                self.rquiet = max(inch * 0.25, self.barWidth * 10.0)
        else:
            self.lquiet = self.rquiet = 0.0

        MultiWidthBarcode.__init__(self, value)
    def __call__(self, arg, default=None):
        '''try to map an arbitrary arg to a color instance
        '''
        if isinstance(arg, Color): return arg
        if isinstance(arg, (tuple, list)):
            assert 3 <= len(
                arg) <= 4, 'Can only convert 3 and 4 sequences to color'
            assert 0 <= min(arg) and max(arg) <= 1
            return len(arg) == 3 and Color(arg[0], arg[1],
                                           arg[2]) or CMYKColor(
                                               arg[0], arg[1], arg[2], arg[3])
        elif isStr(arg):
            arg = asNative(arg)
            C = cssParse(arg)
            if C: return C
            if arg in self.extraColorsNS: return self.extraColorsNS[arg]
            C = getAllNamedColors()
            s = arg.lower()
            if s in C: return C[s]
            G = C.copy()
            G.update(self.extraColorsNS)
            if not self._G:
                C = globals()
                self._G = {
                    s: C[s]
                    for s in
                    '''Blacker CMYKColor CMYKColorSep Color ColorType HexColor PCMYKColor PCMYKColorSep Whiter
                    _chooseEnforceColorSpace _enforceCMYK _enforceError _enforceRGB _enforceSEP _enforceSEP_BLACK
                    _enforceSEP_CMYK _namedColors _re_css asNative cmyk2rgb cmykDistance color2bw colorDistance
                    cssParse describe fade fp_str getAllNamedColors hsl2rgb hue2rgb isStr linearlyInterpolatedColor
                    literal_eval obj_R_G_B opaqueColor rgb2cmyk setColors toColor toColorOrNone'''
                    .split()
                }
            G.update(self._G)
            try:
                return toColor(rl_safe_eval(arg, g=G, l={}))
            except:
                pass

        try:
            return HexColor(arg)
        except:
            if default is None:
                raise ValueError('Invalid color value %r' % arg)
            return default
Example #24
0
 def __init__(self, value='01234567094987654321', routing='', **kwd):
     self._init()
     value = str(value) if isinstance(value, int) else asNative(value)
     if not routing:
         #legal values for combined tracking + routing
         if len(value) in (20, 25, 29, 31):
             value, routing = value[:20], value[20:]
         else:
             raise ValueError(
                 'value+routing length must be 20, 25, 29 or 31 digits not %d'
                 % len(value))
     elif len(routing) not in (5, 9, 11):
         raise ValueError(
             'routing length must be 5, 9 or 11 digits not %d' %
             len(routing))
     self._tracking = value
     self._routing = routing
     self._setKeywords(**kwd)
Example #25
0
 def drawString(self, x, y, s, angle=0):
     if self._fillColor != None:
         fontObj = getFont(self._font)
         if not self.code[self._fontCodeLoc]:
             psName = asNative(fontObj.face.name)
             self.code[self._fontCodeLoc]='(%s) findfont %s scalefont setfont' % (psName,fp_str(self._fontSize))
             if psName not in self._fontsUsed:
                 self._fontsUsed.append(psName)
         self.setColor(self._fillColor)
         if angle!=0:
             self.code_append('gsave %s translate %s rotate' % (fp_str(x,y),fp_str(angle)))
             x = y = 0
         if fontObj._dynamicFont:
             s = self._escape(s)
             self.code_append('%s m (%s) show ' % (fp_str(x,y),s))
         else:
             self._issueT1String(fontObj,x,y,s)
         if angle!=0:
             self.code_append('grestore')
Example #26
0
 def drawString(self, x, y, s, angle=0):
     if self._fillColor != None:
         fontObj = getFont(self._font)
         if not self.code[self._fontCodeLoc]:
             psName = asNative(fontObj.face.name)
             self.code[self._fontCodeLoc]='(%s) findfont %s scalefont setfont' % (psName,fp_str(self._fontSize))
             if psName not in self._fontsUsed:
                 self._fontsUsed.append(psName)
         self.setColor(self._fillColor)
         if angle!=0:
             self.code_append('gsave %s translate %s rotate' % (fp_str(x,y),fp_str(angle)))
             x = y = 0
         if fontObj._dynamicFont:
             s = self._escape(s)
             self.code_append('%s m (%s) show ' % (fp_str(x,y),s))
         else:
             self._issueT1String(fontObj,x,y,s)
         if angle!=0:
             self.code_append('grestore')
Example #27
0
    def _add_human_readable(self, s, gAdd):
        barWidth = self.barWidth
        fontSize = self.fontSize
        textColor = self.textColor
        fontName = self.fontName
        fth = fontSize * 1.2
        # draw the num below the line.
        y = self.y + 0.2 * fth

        x = self.x + (self._nbars + self._lquiet * 2) * barWidth / 2

        gAdd(
            String(x,
                   y,
                   s,
                   fontName=fontName,
                   fontSize=fontSize,
                   fillColor=textColor,
                   textAnchor='middle'))

        price = getattr(self, 'price', None)
        if price:
            price = None
            if s[0] in '3456':
                price = '$'
            elif s[0] in '01':
                price = asNative(b'\xc2\xa3')

            if price is None:
                return

            price += s[1:3] + '.' + s[3:5]
            y += self.barHeight
            gAdd(
                String(x,
                       y,
                       price,
                       fontName=fontName,
                       fontSize=fontSize,
                       fillColor=textColor,
                       textAnchor='middle'))
Example #28
0
    def __call__(self,canv,kind,label):
        label = asNative(label,'latin1')
        try:
            terms, format, offset = decode_label(label)
        except:
            terms = label
            format = offset = None
        if format is None:
            formatFunc = self.formatFunc
        else:
            formatFunc = self.getFormatFunc(format)
        if offset is None:
            offset = self.offset

        terms = commasplit(terms)
        cPN = canv.getPageNumber()
        pns = formatFunc(cPN-offset)
        key = 'ix_%s_%s_p_%s' % (self.name, label, pns)

        info = canv._curr_tx_info
        canv.bookmarkHorizontal(key, info['cur_x'], info['cur_y'] + info['leading'])
        self.addEntry(terms, (cPN,pns), key)
Example #29
0
 def handle_data(self, data):
     #the only data should be paragraph text, preformatted para
     #text, 'string text' for a fixed string on the page,
     #or table data
     data = asNative(data)
     if self._curPara:
         self._curPara.rawtext = self._curPara.rawtext + data
     elif self._curPrefmt:
         self._curPrefmt.rawtext = self._curPrefmt.rawtext + data
     elif self._curPyCode:
         self._curPyCode.rawtext = self._curPyCode.rawtext + data
     elif  self._curString:
         self._curString.text = self._curString.text + data
     elif self._curTable:
         self._curTable.rawBlocks.append(data)
     elif self._curTitle != None:  # need to allow empty strings,
         # hence explicitly testing for None
         self._curTitle = self._curTitle + data
     elif self._curAuthor != None:
         self._curAuthor = self._curAuthor + data
     elif self._curSubject != None:
         self._curSubject = self._curSubject + data
Example #30
0
 def handle_data(self, data):
     #the only data should be paragraph text, preformatted para
     #text, 'string text' for a fixed string on the page,
     #or table data
     data = asNative(data)
     if self._curPara:
         self._curPara.rawtext = self._curPara.rawtext + data
     elif self._curPrefmt:
         self._curPrefmt.rawtext = self._curPrefmt.rawtext + data
     elif self._curPyCode:
         self._curPyCode.rawtext = self._curPyCode.rawtext + data
     elif self._curString:
         self._curString.text = self._curString.text + data
     elif self._curTable:
         self._curTable.rawBlocks.append(data)
     elif self._curTitle != None:  # need to allow empty strings,
         # hence explicitly testing for None
         self._curTitle = self._curTitle + data
     elif self._curAuthor != None:
         self._curAuthor = self._curAuthor + data
     elif self._curSubject != None:
         self._curSubject = self._curSubject + data
Example #31
0
    def __call__(self, canv, kind, label):
        label = asNative(label, 'latin1')
        try:
            terms, format, offset = decode_label(label)
        except:
            terms = label
            format = offset = None
        if format is None:
            formatFunc = self.formatFunc
        else:
            formatFunc = self.getFormatFunc(format)
        if offset is None:
            offset = self.offset

        terms = commasplit(terms)
        cPN = canv.getPageNumber()
        pns = formatFunc(cPN - offset)
        key = 'ix_%s_%s_p_%s' % (self.name, label, pns)

        info = canv._curr_tx_info
        canv.bookmarkHorizontal(key, info['cur_x'],
                                info['cur_y'] + info['leading'])
        self.addEntry(terms, (cPN, pns), key)
Example #32
0
    def drawString(self, s, x, y, angle=0, link_info=None,**_svgAttrs):
        s = asNative(s)
        if self.verbose: print("+++ SVGCanvas.drawString")

        if self._fillColor != None:
            self.setColor(self._fillColor)
            s = self._escape(s)
            st = self._formatStyle(TEXT_STYLES)
            if angle != 0:
               st = st + " rotate(%f %f %f);" % (angle, x, y)
            st = st + " fill: %s;" % self.style['fill']
            text = transformNode(self.doc, "text",
                x=x, y=y, style=st,
                transform="translate(0,%d) scale(1,-1)" % (2*y),
                **_svgAttrs
                )
            content = self.doc.createTextNode(s)
            text.appendChild(content)

            if link_info:
                text = self._add_link(text, link_info)
    
            self.currGroup.appendChild(text)
Example #33
0
 def __init__(self,value='01234567094987654321',routing='',**kwd):
     self._init()
     value = str(value) if isinstance(value,int) else asNative(value)
     self._tracking = value
     self._routing = routing
     self._setKeywords(**kwd)
Example #34
0
 def getRefStr(self,obj):
     return asNative(self.getRef(obj).format(self.canv._doc))
Example #35
0
def hexText(text):
    "a legitimate way to show strings in PDF"
    return '<%s>' % asNative(hexlify(rawBytes(text))).upper()
Example #36
0
    def asciiBase85Decode(input):
        """Decodes input using ASCII-Base85 coding.

        This is not normally used - Acrobat Reader decodes for you
        - but a round trip is essential for testing."""
        #strip all whitespace
        stripped = ''.join(asNative(input).split())
        #check end
        assert stripped[-2:] == '~>', 'Invalid terminator for Ascii Base 85 Stream'
        stripped = stripped[:-2]  #chop off terminator

        #may have 'z' in it which complicates matters - expand them
        stripped = stripped.replace('z','!!!!!')
        # special rules apply if not a multiple of five bytes.
        whole_word_count, remainder_size = divmod(len(stripped), 5)
        #print '%d words, %d leftover' % (whole_word_count, remainder_size)
        #assert remainder_size != 1, 'invalid Ascii 85 stream!'
        cut = 5 * whole_word_count
        body, lastbit = stripped[0:cut], stripped[cut:]

        out = [].append
        for i in range(whole_word_count):
            offset = i*5
            c1 = ord(body[offset]) - 33
            c2 = ord(body[offset+1]) - 33
            c3 = ord(body[offset+2]) - 33
            c4 = ord(body[offset+3]) - 33
            c5 = ord(body[offset+4]) - 33

            num = ((85**4) * c1) + ((85**3) * c2) + ((85**2) * c3) + (85*c4) + c5

            temp, b4 = divmod(num,256)
            temp, b3 = divmod(temp,256)
            b1, b2 = divmod(temp, 256)

            assert  num == 16777216 * b1 + 65536 * b2 + 256 * b3 + b4, 'dodgy code!'
            out(chr(b1))
            out(chr(b2))
            out(chr(b3))
            out(chr(b4))

        #decode however many bytes we have as usual
        if remainder_size > 0:
            while len(lastbit) < 5:
                lastbit = lastbit + '!'
            c1 = ord(lastbit[0]) - 33
            c2 = ord(lastbit[1]) - 33
            c3 = ord(lastbit[2]) - 33
            c4 = ord(lastbit[3]) - 33
            c5 = ord(lastbit[4]) - 33
            num = (((85*c1+c2)*85+c3)*85+c4)*85 + (c5
                     +(0,0,0xFFFFFF,0xFFFF,0xFF)[remainder_size])
            temp, b4 = divmod(num,256)
            temp, b3 = divmod(temp,256)
            b1, b2 = divmod(temp, 256)
            assert  num == 16777216 * b1 + 65536 * b2 + 256 * b3 + b4, 'dodgy code!'
            #print 'decoding: %d %d %d %d %d -> %d -> %d %d %d %d' % (
            #    c1,c2,c3,c4,c5,num,b1,b2,b3,b4)

            #the last character needs 1 adding; the encoding loses
            #data by rounding the number to x bytes, and when
            #divided repeatedly we get one less
            if remainder_size == 2:
                lastword = chr(b1)
            elif remainder_size == 3:
                lastword = chr(b1) + chr(b2)
            elif remainder_size == 4:
                lastword = chr(b1) + chr(b2) + chr(b3)
            else:
                lastword = ''
            out(lastword)

        r = ''.join(out.__self__)
        return asBytes(r,enc='latin1')
Example #37
0
    def __init__(self, value='', **args):
        value = str(value) if isinstance(value,int) else asNative(value)
        for k, v in args.items():
            setattr(self, k, v)

        Barcode.__init__(self, value)
Example #38
0
 def getRefStr(self, obj):
     return asNative(self.getRef(obj).format(self.canv._doc))
Example #39
0
    def __init__(self, value='', **args):
        value = str(value) if isinstance(value, int) else asNative(value)
        for k, v in args.items():
            setattr(self, k, v)

        Barcode.__init__(self, value)
Example #40
0
 def __init__(self, value='123456789012', **kw):
     value = str(value) if isinstance(value, int) else asNative(value)
     self.value = max(self._digits - len(value),
                      0) * '0' + value[:self._digits]
     for k, v in kw.items():
         setattr(self, k, v)
Example #41
0
 def __init__(self,value='Hello World',**kw):
     value = str(value) if isinstance(value,int) else asNative(value)
     self.value=value
     for k, v in kw.items():
         setattr(self, k, v)
Example #42
0
    def asciiBase85Decode(input):
        """Decodes input using ASCII-Base85 coding.

        This is not normally used - Acrobat Reader decodes for you
        - but a round trip is essential for testing."""
        #strip all whitespace
        stripped = ''.join(asNative(input).split())
        #check end
        assert stripped[
            -2:] == '~>', 'Invalid terminator for Ascii Base 85 Stream'
        stripped = stripped[:-2]  #chop off terminator

        #may have 'z' in it which complicates matters - expand them
        stripped = stripped.replace('z', '!!!!!')
        # special rules apply if not a multiple of five bytes.
        whole_word_count, remainder_size = divmod(len(stripped), 5)
        #print '%d words, %d leftover' % (whole_word_count, remainder_size)
        #assert remainder_size != 1, 'invalid Ascii 85 stream!'
        cut = 5 * whole_word_count
        body, lastbit = stripped[0:cut], stripped[cut:]

        out = [].append
        for i in range(whole_word_count):
            offset = i * 5
            c1 = ord(body[offset]) - 33
            c2 = ord(body[offset + 1]) - 33
            c3 = ord(body[offset + 2]) - 33
            c4 = ord(body[offset + 3]) - 33
            c5 = ord(body[offset + 4]) - 33

            num = ((85**4) * c1) + ((85**3) * c2) + (
                (85**2) * c3) + (85 * c4) + c5

            temp, b4 = divmod(num, 256)
            temp, b3 = divmod(temp, 256)
            b1, b2 = divmod(temp, 256)

            assert num == 16777216 * b1 + 65536 * b2 + 256 * b3 + b4, 'dodgy code!'
            out(chr(b1))
            out(chr(b2))
            out(chr(b3))
            out(chr(b4))

        #decode however many bytes we have as usual
        if remainder_size > 0:
            while len(lastbit) < 5:
                lastbit = lastbit + '!'
            c1 = ord(lastbit[0]) - 33
            c2 = ord(lastbit[1]) - 33
            c3 = ord(lastbit[2]) - 33
            c4 = ord(lastbit[3]) - 33
            c5 = ord(lastbit[4]) - 33
            num = (((85 * c1 + c2) * 85 + c3) * 85 + c4) * 85 + (
                c5 + (0, 0, 0xFFFFFF, 0xFFFF, 0xFF)[remainder_size])
            temp, b4 = divmod(num, 256)
            temp, b3 = divmod(temp, 256)
            b1, b2 = divmod(temp, 256)
            assert num == 16777216 * b1 + 65536 * b2 + 256 * b3 + b4, 'dodgy code!'
            #print 'decoding: %d %d %d %d %d -> %d -> %d %d %d %d' % (
            #    c1,c2,c3,c4,c5,num,b1,b2,b3,b4)

            #the last character needs 1 adding; the encoding loses
            #data by rounding the number to x bytes, and when
            #divided repeatedly we get one less
            if remainder_size == 2:
                lastword = chr(b1)
            elif remainder_size == 3:
                lastword = chr(b1) + chr(b2)
            elif remainder_size == 4:
                lastword = chr(b1) + chr(b2) + chr(b3)
            else:
                lastword = ''
            out(lastword)

        r = ''.join(out.__self__)
        return asBytes(r, enc='latin1')
Example #43
0
def _objStr(s):
    if isStr(s):
        return asNative(s)
    else:
        return str(s)
Example #44
0
    def test3(Self):
        from reportlab.platypus import BalancedColumns, IndexingFlowable, ShowBoundaryValue, NullDraw
        doc = SimpleDocTemplate(outputfile('test_balancedcolumns.pdf'))
        styleSheet = getSampleStyleSheet()

        class MyIndexingNull(IndexingFlowable, NullDraw):
            _ZEROSIZE = True
            def __init__(self,*args,**kwds):
                IndexingFlowable.__init__(self,*args,**kwds)
                self._n = 2

            def isSatisfied(self):
                if self._n>0: self._n -= 1
                return self._n==0

        story = [MyIndexingNull()]

        def first():
            spam = """
            Welcome to PLATYPUS!

            Platypus stands for "Page Layout and Typography Using Scripts".  It is a high
            level page layout library which lets you programmatically create complex
            documents with a minimum of effort.

            This document is both the user guide &amp; the output of the test script.
            In other words, a script used platypus to create the document you are now
            reading, and the fact that you are reading it proves that it works.  Or
            rather, that it worked for this script anyway.  It is a first release!

            Platypus is built 'on top of' PDFgen, the Python library for creating PDF
            documents.  To learn about PDFgen, read the document testpdfgen.pdf.

            """
            for text in getParagraphs(spam):
                story.append(Paragraph(text, styleSheet['BodyText']))

        
        def balanced(spam=None):
            L = [Paragraph("""
                What concepts does PLATYPUS deal with?
                """, styleSheet['Heading2']),
                Paragraph("""
                The central concepts in PLATYPUS are Flowable Objects, Frames, Flow
                Management, Styles and Style Sheets, Paragraphs and Tables.  This is
                best explained in contrast to PDFgen, the layer underneath PLATYPUS.
                PDFgen is a graphics library, and has primitive commans to draw lines
                and strings.  There is nothing in it to manage the flow of text down
                the page.  PLATYPUS works at the conceptual level fo a desktop publishing
                package; you can write programs which deal intelligently with graphic
                objects and fit them onto the page.
                """, styleSheet['BodyText']),

                Paragraph("""
                How is this document organized?
                """, styleSheet['Heading2']),

                Paragraph("""
                Since this is a test script, we'll just note how it is organized.
                the top of each page contains commentary.  The bottom half contains
                example drawings and graphic elements to whicht he commentary will
                relate.  Down below, you can see the outline of a text frame, and
                various bits and pieces within it.  We'll explain how they work
                on the next page.
                """, styleSheet['BodyText']),
                ]
            if spam:
                for text in getParagraphs(spam):
                    L.append(Paragraph(text, styleSheet['BodyText']))
            story.append(BalancedColumns(L,spaceBefore=20,spaceAfter=30, showBoundary=ShowBoundaryValue(color=colors.lightgreen,width=2)))

        def second():
            spam = '''The concept of an integrated one box solution for advanced voice and
    data applications began with the introduction of the IMACS. The
    IMACS 200 carries on that tradition with an integrated solution
    optimized for smaller port size applications that the IMACS could not
    economically address. An array of the most popular interfaces and
    features from the IMACS has been bundled into a small 2U chassis
    providing the ultimate in ease of installation.

    With this clarification, an important property of these three types of
    EC can be defined in such a way as to impose problems of phonemic and
    morphological analysis.  Another superficial similarity is the interest
    in simulation of behavior, this analysis of a formative as a pair of
    sets of features does not readily tolerate a stipulation to place the
    constructions into these various categories.

    We will bring evidence in
    favor of the following thesis:  the earlier discussion of deviance is
    not to be considered in determining the extended c-command discussed in
    connection with (34).  Another superficial similarity is the interest in
    simulation of behavior, relational information may remedy and, at the
    same time, eliminate a descriptive fact.

    There is also a different
    approach to the [unification] problem, the descriptive power of the base
    component delimits the traditional practice of grammarians.'''
            for text in getParagraphs(spam):
                story.append(Paragraph(text, styleSheet['BodyText']))

        xtra_spam=asNative(b'''If you imagine that the box of X's tothe left is
an image, what I want to be able to do is flow a
series of paragraphs around the image
so that once the bottom of the image is reached, then text will flow back to the
left margin. I know that it would be possible to something like this
using tables, but I can't see how to have a generic solution.
There are two examples of this in the demonstration section of the reportlab
site.

If you look at the "minimal" euro python conference brochure, at the end of the
timetable section (page 8), there are adverts for "AdSu" and "O'Reilly". I can
see how the AdSu one might be done generically, but the O'Reilly, unsure...
I guess I'm hoping that I've missed something, and that
it's actually easy to do using platypus.We can do greek letters <greek>mDngG</greek>.

This should be a u with a dieresis on top &lt;unichar code=0xfc/&gt;="<unichar code="0xfc"/>" and this &amp;#xfc;="&#xfc;" and this \\xc3\\xbc="\xc3\xbc". On the other hand this
should be a pound sign &amp;pound;="&pound;" and this an alpha &amp;alpha;="&alpha;".
You can have links in the page <link href="http://www.reportlab.com" color="blue">ReportLab</link> &amp; <a href="http://www.reportlab.org" color="green">ReportLab.org</a>.
Use scheme "pdf:" to indicate an external PDF link, "http:", "https:" to indicate an external link eg something to open in
your browser. If an internal link begins with something that looks like a scheme, precede with "document:".

Empty hrefs should be allowed ie <a href="">&lt;a href=""&gt;test&lt;/a&gt;</a> should be allowed. <strike>This text should have a strike through it.</strike>
This should be a mailto link <a href="mailto:[email protected]"><font color="blue">reportlab-users at lists2.reportlab.com</font></a>.''')

        story.append(Paragraph("""Testing the BalancedColumns""", styleSheet['Heading1']))
        first()
        balanced()
        second()
        story.append(PageBreak())
        story.append(Paragraph("""Testing the BalancedColumns Breaking""", styleSheet['Heading1']))
        story.append(Spacer(0,200))
        first()
        balanced(spam=xtra_spam)
        second()
        doc.build(story)
Example #45
0
    def test3(Self):
        from reportlab.platypus import BalancedColumns, IndexingFlowable, ShowBoundaryValue, NullDraw
        doc = SimpleDocTemplate(outputfile('test_balancedcolumns.pdf'))
        styleSheet = getSampleStyleSheet()

        class MyIndexingNull(IndexingFlowable, NullDraw):
            _ZEROSIZE = True

            def __init__(self, *args, **kwds):
                IndexingFlowable.__init__(self, *args, **kwds)
                self._n = 2

            def isSatisfied(self):
                if self._n > 0: self._n -= 1
                return self._n == 0

        story = [MyIndexingNull()]

        def first():
            spam = """
            Welcome to PLATYPUS!

            Platypus stands for "Page Layout and Typography Using Scripts".  It is a high
            level page layout library which lets you programmatically create complex
            documents with a minimum of effort.

            This document is both the user guide &amp; the output of the test script.
            In other words, a script used platypus to create the document you are now
            reading, and the fact that you are reading it proves that it works.  Or
            rather, that it worked for this script anyway.  It is a first release!

            Platypus is built 'on top of' PDFgen, the Python library for creating PDF
            documents.  To learn about PDFgen, read the document testpdfgen.pdf.

            """
            for text in getParagraphs(spam):
                story.append(Paragraph(text, styleSheet['BodyText']))

        def balanced(spam=None):
            L = [
                Paragraph(
                    """
                What concepts does PLATYPUS deal with?
                """, styleSheet['Heading2']),
                Paragraph(
                    """
                The central concepts in PLATYPUS are Flowable Objects, Frames, Flow
                Management, Styles and Style Sheets, Paragraphs and Tables.  This is
                best explained in contrast to PDFgen, the layer underneath PLATYPUS.
                PDFgen is a graphics library, and has primitive commans to draw lines
                and strings.  There is nothing in it to manage the flow of text down
                the page.  PLATYPUS works at the conceptual level fo a desktop publishing
                package; you can write programs which deal intelligently with graphic
                objects and fit them onto the page.
                """, styleSheet['BodyText']),
                Paragraph(
                    """
                How is this document organized?
                """, styleSheet['Heading2']),
                Paragraph(
                    """
                Since this is a test script, we'll just note how it is organized.
                the top of each page contains commentary.  The bottom half contains
                example drawings and graphic elements to whicht he commentary will
                relate.  Down below, you can see the outline of a text frame, and
                various bits and pieces within it.  We'll explain how they work
                on the next page.
                """, styleSheet['BodyText']),
            ]
            if spam:
                for text in getParagraphs(spam):
                    L.append(Paragraph(text, styleSheet['BodyText']))
            story.append(
                BalancedColumns(L,
                                spaceBefore=20,
                                spaceAfter=30,
                                showBoundary=ShowBoundaryValue(
                                    color=colors.lightgreen, width=2)))

        def second():
            spam = '''The concept of an integrated one box solution for advanced voice and
    data applications began with the introduction of the IMACS. The
    IMACS 200 carries on that tradition with an integrated solution
    optimized for smaller port size applications that the IMACS could not
    economically address. An array of the most popular interfaces and
    features from the IMACS has been bundled into a small 2U chassis
    providing the ultimate in ease of installation.

    With this clarification, an important property of these three types of
    EC can be defined in such a way as to impose problems of phonemic and
    morphological analysis.  Another superficial similarity is the interest
    in simulation of behavior, this analysis of a formative as a pair of
    sets of features does not readily tolerate a stipulation to place the
    constructions into these various categories.

    We will bring evidence in
    favor of the following thesis:  the earlier discussion of deviance is
    not to be considered in determining the extended c-command discussed in
    connection with (34).  Another superficial similarity is the interest in
    simulation of behavior, relational information may remedy and, at the
    same time, eliminate a descriptive fact.

    There is also a different
    approach to the [unification] problem, the descriptive power of the base
    component delimits the traditional practice of grammarians.'''
            for text in getParagraphs(spam):
                story.append(Paragraph(text, styleSheet['BodyText']))

        xtra_spam = asNative(
            b'''If you imagine that the box of X's tothe left is
an image, what I want to be able to do is flow a
series of paragraphs around the image
so that once the bottom of the image is reached, then text will flow back to the
left margin. I know that it would be possible to something like this
using tables, but I can't see how to have a generic solution.
There are two examples of this in the demonstration section of the reportlab
site.

If you look at the "minimal" euro python conference brochure, at the end of the
timetable section (page 8), there are adverts for "AdSu" and "O'Reilly". I can
see how the AdSu one might be done generically, but the O'Reilly, unsure...
I guess I'm hoping that I've missed something, and that
it's actually easy to do using platypus.We can do greek letters <greek>mDngG</greek>.

This should be a u with a dieresis on top &lt;unichar code=0xfc/&gt;="<unichar code="0xfc"/>" and this &amp;#xfc;="&#xfc;" and this \\xc3\\xbc="\xc3\xbc". On the other hand this
should be a pound sign &amp;pound;="&pound;" and this an alpha &amp;alpha;="&alpha;".
You can have links in the page <link href="http://www.reportlab.com" color="blue">ReportLab</link> &amp; <a href="http://www.reportlab.org" color="green">ReportLab.org</a>.
Use scheme "pdf:" to indicate an external PDF link, "http:", "https:" to indicate an external link eg something to open in
your browser. If an internal link begins with something that looks like a scheme, precede with "document:".

Empty hrefs should be allowed ie <a href="">&lt;a href=""&gt;test&lt;/a&gt;</a> should be allowed. <strike>This text should have a strike through it.</strike>
This should be a mailto link <a href="mailto:[email protected]"><font color="blue">reportlab-users at lists2.reportlab.com</font></a>.'''
        )

        story.append(
            Paragraph("""Testing the BalancedColumns""",
                      styleSheet['Heading1']))
        first()
        balanced()
        second()
        story.append(PageBreak())
        story.append(
            Paragraph("""Testing the BalancedColumns Breaking""",
                      styleSheet['Heading1']))
        story.append(Spacer(0, 200))
        first()
        balanced(spam=xtra_spam)
        second()
        doc.build(story)
 def __init__(self,value='123456789012',**kw):
     value = str(value) if isinstance(value,int) else asNative(value)
     self.value=max(self._digits-len(value),0)*'0'+value[:self._digits]
     for k, v in kw.items():
         setattr(self, k, v)
 def __init__(self, value='Hello World', human_readable=False):
     # TODO: Add support to set "y" bound.
     self.value = str(value) if isinstance(value, int) else asNative(value)
Example #48
0
 def __init__(self, value='Hello World', **kw):
     value = str(value) if isinstance(value, int) else asNative(value)
     self.value = value
     for k, v in kw.items():
         setattr(self, k, v)
Example #49
0
 def __init__(self,value='01234567094987654321',routing='',**kwd):
     self._init()
     value = str(value) if isinstance(value,int) else asNative(value)
     self._tracking = value
     self._routing = routing
     self._setKeywords(**kwd)