Ejemplo n.º 1
1
 def draw_footer(self, canvas):
     canvas.saveState()
     footerwidth = self.dina4[0] - (2 * self.left)
     canvas.setFillColorCMYK(1, 0.5, 0, 0)
     canvas.rect(0, 0, width=self.dina4[0], height=50, fill=True)
     canvas.setFillColorCMYK(0, 0, 0, 0)
     canvas.setFont(self.font_bold, 14)
     x = self.dina4[0]/2
     canvas.drawCentredString(x, 25, 'www.imko.de')
     canvas.linkURL('http://www.imko.de', (0, 50, self.dina4[1], 0))
     canvas.restoreState()
Ejemplo n.º 2
0
def colors(canvas):
    from reportlab.lib import colors
    from reportlab.lib.units import inch

    black = colors.black
    y = x = 0
    dy = inch * 3 / 4.0
    dx = inch * 5.5 / 5
    w = h = dy / 2
    rdx = (dx - w) / 2
    rdy = h / 5.0
    texty = h + 2 * rdy
    canvas.setFont("Helvetica", 10)
    for [namedcolor, name] in (
        [colors.lavenderblush, "lavenderblush"],
        [colors.lawngreen, "lawngreen"],
        [colors.lemonchiffon, "lemonchiffon"],
        [colors.lightblue, "lightblue"],
        [colors.lightcoral, "lightcoral"],
    ):
        canvas.setFillColor(namedcolor)
        canvas.rect(x + rdx, y + rdy, w, h, fill=1)
    canvas.setFillColor(black)
    canvas.drawCentredString(x + dx / 2, y + texty, name)
    x = x + dx
    y = y + dy
    x = 0
    for rgb in [(1, 0, 0), (0, 1, 0), (0, 0, 1), (0.5, 0.3, 0.1), (0.4, 0.5, 0.3)]:
        r, g, b = rgb
        canvas.setFillColorRGB(r, g, b)
    canvas.rect(x + rdx, y + rdy, w, h, fill=1)
    canvas.setFillColor(black)
    canvas.drawCentredString(x + dx / 2, y + texty, "r%s g%s b%s" % rgb)
    x = x + dx
    y = y + dy
    x = 0
    for cmyk in [(1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0), (0, 0, 0, 1), (0, 0, 0, 0)]:
        c, m, y1, k = cmyk
        canvas.setFillColorCMYK(c, m, y1, k)
        canvas.rect(x + rdx, y + rdy, w, h, fill=1)
        canvas.setFillColor(black)
        canvas.drawCentredString(x + dx / 2, y + texty, "c%s m%s y%s k%s" % cmyk)
        x = x + dx
        y = y + dy
        x = 0
    for gray in (0.0, 0.25, 0.50, 0.75, 1.0):
        canvas.setFillGray(gray)
        canvas.rect(x + rdx, y + rdy, w, h, fill=1)
Ejemplo n.º 3
0
    def _create_header(self, canvas, doc):
        #Draw the logo in the upper left
        if self.company.lower() == 'dellarobbia thailand':
            path = """https://s3-ap-southeast-1.amazonaws.com/media.dellarobbiathailand.com/logo/form_logo.jpg"""
        else:
            path = "https://s3-ap-southeast-1.amazonaws.com/media.dellarobbiathailand.com/logo/Alinea-Logo_Master.jpg"
        
        # Read image from link
        img = utils.ImageReader(path)
        
        # Get Size
        img_width, img_height = img.getSize()
        new_width = (img_width * logo_height) / img_height
        canvas.drawImage(path, 42, 760, height=logo_height, width=new_width)

        canvas.setFont('Helvetica', 8)
        canvas.setFillColorCMYK(0, 0, 0, 60)
        #Add Company Information in under the logo if dellarobbia
        if self.company.lower() == 'dellarobbia thailand':
            canvas.drawString(42, 760,
                            "78/448 Moo.6 Lam Lukka Rd. Bueng Kham Phroi, Lam Lukka")
            canvas.drawString(42, 750, "Pathum Thani, Thailand, 12150")
            canvas.drawString(42, 740, "+66 2 508 8681")
        else:
            canvas.drawString(42, 760,
                            "78/448 Moo.6 Lam Lukka Rd. Bueng Kham Phroi, Lam Lukka")
            canvas.drawString(42, 750, "Pathum Thani, Thailand, 12150")
            canvas.drawString(42, 740, "+66 2 508 8681")
        #canvas.drawString(42, 730, "www.dellarobbiathailand.com")

        # Create The document type and document number
        canvas.setFont("Helvetica", 16)
        canvas.drawRightString(550, 800, 'Purchase Order')
        canvas.setFont("Helvetica", 12)
        canvas.drawRightString(550, 780, 'PO# : {0}'.format(self.id))

        # Create a barcode from the id
        canvas.setFillColorCMYK(0, 0, 0, 1)
        code = 'PO-{0}'.format(self.id)
        barcode = code128.Code128(code, barHeight=20, barWidth=0.5 * mm)
        x_position = 570 - barcode.width
        # drawOn puts the barcode on the canvas at the specified coordinates
        barcode.drawOn(canvas, x_position, 750)
        
        # Create the revision
        if self.revision:
            if self.revision_date:
                msg = u"Revision: {0}, # {1}"
                revision_str = msg.format(self.revision_date.strftime('%B %d, %Y'),
                                          self.revision)
            else:
                msg = u'Revision: # {0}'
                revision_str = msg.format(self.revision)
                
            canvas.setFillColorCMYK(0, 0, 0, 1)
            canvas.setFont("Helvetica", 12)
            canvas.drawRightString(550, 730, revision_str)
Ejemplo n.º 4
0
def colors2(canvas): 
    from reportlab.lib.units import inch 
    
    x = 0; dx = 0.4*inch 
    for i in range(4): 
        for color in (colors.pink, colors.green, colors.brown): 
            canvas.setFillColor(color) 
            canvas.rect(x,0,dx,3*inch,stroke=0,fill=1) 
            x = x+dx 
    canvas.setFillColor(colors.white) 
    canvas.setStrokeColor(colors.white) 
    canvas.setFont("Helvetica-Bold", 85) 
    canvas.drawCentredString(2.75*inch, 1.3*inch, "OPEN") 
    return
    
    
    textobject = canvas.beginText() 
    textobject.setTextOrigin(inch, 2.5*inch) 
    textobject.setFont("Helvetica-Oblique", 14) 
    for line in lyrics: 
        textobject.textLine(line) 
    textobject.setFillGray(0.4) 
    textobject.textLines(''' 
    With many apologies to the Beach Boys 
    and anyone else who finds this objectionable 
    ''') 
    canvas.drawText(textobject) 
    
    black = colors.black 
    y = x = 0; dy=inch*3/4.0; dx=inch*5.5/5; w=h=dy/2; rdx=(dx-w)/2 
    rdy=h/5.0; texty=h+2*rdy 
    canvas.setFont("Helvetica",10) 
    for [namedcolor, name] in ( 
           [colors.lavenderblush, "lavenderblush"], 
           [colors.lawngreen, "lawngreen"], 
           [colors.lemonchiffon, "lemonchiffon"], 
           [colors.lightblue, "lightblue"], 
           [colors.lightcoral, "lightcoral"]): 
        canvas.setFillColor(namedcolor) 
        canvas.rect(x+rdx, y+rdy, w, h, fill=1) 
        canvas.setFillColor(black) 
        canvas.drawCentredString(x+dx/2, y+texty, name) 
        x = x+dx 
    y = y + dy; x = 0 
    for rgb in [(1,0,0), (0,1,0), (0,0,1), (0.5,0.3,0.1), (0.4,0.5,0.3)]: 
        r,g,b = rgb 
        canvas.setFillColorRGB(r,g,b) 
        canvas.rect(x+rdx, y+rdy, w, h, fill=1) 
        canvas.setFillColor(black) 
        canvas.drawCentredString(x+dx/2, y+texty, "r%s g%s b%s"%rgb) 
        x = x+dx 
    y = y + dy; x = 0 
    for cmyk in [(1,0,0,0), (0,1,0,0), (0,0,1,0), (0,0,0,1), (0,0,0,0)]: 
        c,m,y1,k = cmyk 
        canvas.setFillColorCMYK(c,m,y1,k) 
        canvas.rect(x+rdx, y+rdy, w, h, fill=1) 
        canvas.setFillColor(black) 
        canvas.drawCentredString(x+dx/2, y+texty, "c%s m%s y%s k%s"%cmyk) 
        x = x+dx 
    y = y + dy; x = 0 
    for gray in (0.0, 0.25, 0.50, 0.75, 1.0): 
        canvas.setFillGray(gray) 
        canvas.rect(x+rdx, y+rdy, w, h, fill=1) 
        canvas.setFillColor(black)