def __list_format(canvas, doc): canvas.saveState() building_style = ParagraphStyle(name='building_title', fontSize=__FONT_SIZE__) t = u'%s<br/>Data afișării: %s<br/>Luna: %s' % (doc.habitam_building.name, doc.habitam_display, doc.habitam_month) p = Paragraph(t, building_style) p.wrapOn(canvas, 5 * cm, 2 * cm) p.drawOn(canvas, .5 * cm, __HEIGHT__ - 1.7 * cm) habitam_brand(canvas, __WIDTH__, __HEIGHT__) canvas.restoreState()
def afterPage(self): """Called after each page has been processed""" # saveState keeps a snapshot of the canvas state, so you don't # mess up any rendering that platypus will do later. self.canv.saveState() # Reset the origin to (0, 0), remember, we can restore the # state of the canvas later, so platypus should be unaffected. self.canv._x = 0 self.canv._y = 0 style = getSampleStyleSheet() p = Paragraph("This is drawn after the page!", style["Normal"]) # Wraps and draws the paragraph onto the canvas # You can change the last 2 parameters (canv, x, y) p.wrapOn(self.canv, 2*inch, 2*inch) p.drawOn(self.canv, 1*inch, 3*inch) # Now we restore the canvas back to the way it was. self.canv.restoreState()