当前位置: 首页>>代码示例>>Python>>正文


Python SimpleDocTemplate.addPageTemplates方法代码示例

本文整理汇总了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
开发者ID:vencax,项目名称:django-invoices,代码行数:36,代码来源:pdfgen.py


注:本文中的reportlab.platypus.doctemplate.SimpleDocTemplate.addPageTemplates方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。