本文整理汇总了Python中reportlab.platypus.doctemplate.SimpleDocTemplate.addPageTemplates方法的典型用法代码示例。如果您正苦于以下问题:Python SimpleDocTemplate.addPageTemplates方法的具体用法?Python SimpleDocTemplate.addPageTemplates怎么用?Python SimpleDocTemplate.addPageTemplates使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类reportlab.platypus.doctemplate.SimpleDocTemplate
的用法示例。
在下文中一共展示了SimpleDocTemplate.addPageTemplates方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: prepareDoc
# 需要导入模块: from reportlab.platypus.doctemplate import SimpleDocTemplate [as 别名]
# 或者: from reportlab.platypus.doctemplate.SimpleDocTemplate import addPageTemplates [as 别名]
def prepareDoc(self):
rightMargin, leftMargin, topMargin, bottomMargin = 72, 72, 72, 18
doc = SimpleDocTemplate(None, pagesize=A4,
rightMargin=rightMargin, leftMargin=leftMargin,
topMargin=topMargin, bottomMargin=bottomMargin)
frameWidth = doc.width / 2
headerHeight = 50
userInfoHeight = 228
itemsFrameHeight = doc.height - userInfoHeight - headerHeight
header = Frame(leftMargin, doc.height, doc.width, headerHeight)
column1 = Frame(leftMargin, doc.height - userInfoHeight,
frameWidth, userInfoHeight)
column2 = Frame(leftMargin + frameWidth, doc.height - userInfoHeight,
frameWidth, userInfoHeight)
items = Frame(leftMargin,
doc.height - userInfoHeight - itemsFrameHeight,
doc.width, itemsFrameHeight)
template = PageTemplate(frames=[header, column1, column2, items])
doc.addPageTemplates(template)
half = doc.width / 2
self.columnWidths = (half / 2, half / 2)
self.itemColumnWidths = (
(float(2) / 3) * doc.width,
(float(1) / 3) * doc.width * (float(1) / 3),
(float(1) / 3) * doc.width * (float(2) / 3)
)
return doc