def position(self, c):
"""
Get the appropriate position on the page for the current text given an area.
Args:
c (canvas.Canvas): Page to get the positioning for
Returns:
tuple: the position
"""
if self.area in [Area.TOP_LEFT, Area.TOP_RIGHT]: # top
from_bottom = c._pagesize[1]-15 # 15 down from height of page
elif self.area in [Area.BOTTOM_LEFT, Area.BOTTOM_RIGHT]: # bottom
from_bottom = 15 # 15 up from bottom of page
if self.area in [Area.TOP_LEFT, Area.BOTTOM_LEFT]: # left
from_left = 15
elif self.area in [Area.TOP_RIGHT, Area.BOTTOM_RIGHT]: # right
offset = 15 # initial offset
offset += c.stringWidth(self.text) # offset for text length
from_left = c._pagesize[0]-offset
return from_left, from_bottom
评论列表
文章目录