Example #1
0
File: invoice.py Project: ses4j/ts
def draw_header(canvas):
    """ Draws the invoice header """
    canvas.setStrokeColorRGB(176/255., 196/255., 222/255.)
    # canvas.setStrokeColorRGB(0.9, 0.5, 0.2)
    canvas.setFillColorRGB(0.2, 0.2, 0.2)
    canvas.setFont('Helvetica', 16)
    canvas.drawString(18 * cm, -1 * cm, 'Invoice')
    if consultant_logo_filename:
        canvas.drawInlineImage(consultant_logo_filename, 1 * cm, -1 * cm, 250, 16)
    canvas.setLineWidth(4)
    canvas.line(0, -1.25 * cm, 21.7 * cm, -1.25 * cm)
 def myFirstPage(canvas, doc): 
     canvas.saveState() 
     canvas.setFont(font_choice,24) 
     canvas.drawCentredString(PAGE_WIDTH/2.0, top_position-0.2*inch, header_text)
     canvas.setFont(font_choice, 14)
     canvas.drawString(0.7*inch+logo_boxsize[0], top_position-0.6*inch, 'Observer: ' + observer_text) 
     canvas.drawString(0.7*inch+logo_boxsize[0], top_position-0.8*inch, 'Instrument: ' + instrument_text)
     canvas.drawString(8.5*inch-(0.7*inch+logo_boxsize[0]), top_position-0.6*inch, 'Date: ' + date_text)
     canvas.drawString(8.5*inch-(0.7*inch+logo_boxsize[0]), top_position-0.8*inch, 'Program: ' + program_text)
     canvas.drawInlineImage(logoimage,0.3*inch,top_position - logo_boxsize[1],width=logo_boxsize[0],
                            height=logo_boxsize[1],preserveAspectRatio=True,anchor='nw')
     canvas.restoreState() 
Example #3
0
def addImage(snbFile,canvas,image,rels,element):
	imgFileName = "snote/"+rels[image.getAttribute("r:id")]
	imgStr = zipRead(snbFile,imgFileName)
	if imgFileName.endswith(".zdib"):
		imgStr = decompress(imgStr)
		width = ord(imgStr[5]) * 256 + ord(imgStr[4])
		height = ord(imgStr[9]) * 256 + ord(imgStr[8])
		img = Image.fromstring("RGBA",(width,height),imgStr[52:])
		canvas.drawInlineImage(alpha_to_color(img),0,0,595.27,841.89)
	else:
		style = imagePoss(element.getElementsByTagName("v:shape")[0].getAttribute("style"))
		img=Image.open(BytesIO(imgStr))
		canvas.drawInlineImage(img,style.left,style.bottom,style.width,style.height)
Example #4
0
def drawMap(canvas, center, pageOrigin=(0,0), pageSize=pagesizes.letter, zoom=18, dpi=300):
    outputTileSize = units.inch * center.size / dpi

    # Calculate the size of the page in tiles, rounding up
    tileGrid = (int(pageSize[0] / outputTileSize + 1),
                int(pageSize[1] / outputTileSize + 1))

    for y in xrange(-tileGrid[1]/2, tileGrid[1]/2+2):
        for x in xrange(-tileGrid[0]/2, tileGrid[0]/2+2):
            tile = center.translate(x, y)
            print "Tile %d,%d" % (x,y)
            canvas.drawInlineImage(tile.getImage(),
                                   pageOrigin[0] + pageSize[0]/2 + x * outputTileSize,
                                   pageOrigin[1] + pageSize[1]/2 - y * outputTileSize,
                                   outputTileSize, outputTileSize)
Example #5
0
def pdf_draw_header(canvas, country):
    dir = os.path.dirname(__file__)
    logo = os.path.join(dir, 'logo.jpg')
    canvas.drawInlineImage(logo, RIGHT_COLUMN, 23.7*cm,
                           width=1*cm, height=1*cm)
    canvas.setFont('Helvetica', 16)
    canvas.drawString(RIGHT_COLUMN + 1.2*cm, 24*cm, u"Browsershots")

    drawStrings(canvas, RIGHT_COLUMN, 23*cm, 12,
                u"Johann C. Rocholl",
                u"PĆ¼tnitzer Str. 12",
                u"18311 Ribnitz-Damgarten")
    if country == 'DE':
        canvas.drawString(RIGHT_COLUMN, 21.5*cm, u"Deutschland")
    else:
        canvas.drawString(RIGHT_COLUMN, 21.5*cm, u"Germany")
    canvas.drawString(RIGHT_COLUMN, 20.5*cm, "johann@browsershots.org")
Example #6
0
def add_image(canvas,title,image,scale=SCALE):
	canvas.drawText(new_textobject(title,canvas,TITLE_X,TITLE_Y))
	w, h = ImageReader(image).getSize()
	canvas.drawInlineImage(image,IMAGE_ORIGIN_X,IMAGE_ORIGIN_Y,w * scale,h * scale)
	canvas.showPage()
from reportlab.pdfgen import canvas

"""
Canvas imagem

canvas.drawImage(self, image, x, y, width=None, height=None, mask=None)
canvas.drawInlineImage(self, image, x, y, width=None, height=None)

There are two similar-sounding ways to draw images. The preferred one is the drawImage method. This implements 
a caching system so you can define an image once and draw it many times; it will only be stored once in the PDF 
file. `drawImage` also exposes one advanced parameter, a transparency mask, and will expose more in future. 
The older technique, `drawInlineImage`, stores bitmaps within the page stream and is thus very inefficient if you
use the same image more than once in a document; but can result in PDFs which render faster if the images are 
very small and not repeated.
"""

canvas = canvas.Canvas("pdfs/extra-011.pdf")

canvas.drawImage("static/python-logo.png", 100,400, width=150, height=150, mask='auto')

canvas.drawInlineImage("static/python-logo.png", 100, 700)

canvas.showPage()

canvas.save()
Example #8
0
 def draw_on(self, canvas):
     canvas.drawInlineImage(self.image, self.draw_x, self.draw_y, self.draw_width, self.draw_height)
Example #9
0
    def draw_club_logo(self, canvas):
        """Draw the club logo. Not a lot of code but nice to do everything in separate methods"""

        canvas.drawInlineImage(os.path.abspath('./club-logo.jpg'), 9.5*cm, 25.5*cm, 3*cm, 3*cm)