cards.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:pretalx 作者: pretalx 项目源码 文件源码
def get(self, request, *args, **kwargs):
        with tempfile.NamedTemporaryFile(suffix=".pdf") as f:
            doc = BaseDocTemplate(
                f.name, pagesize=A4,
                leftMargin=0, rightMargin=0, topMargin=0, bottomMargin=0
            )
            doc.addPageTemplates([
                PageTemplate(
                    id='All',
                    frames=[
                        Frame(
                            0, 0, doc.width / 2, doc.height,
                            leftPadding=0, rightPadding=0, topPadding=0, bottomPadding=0,
                            id='left'
                        ),
                        Frame(
                            doc.width / 2, 0, doc.width / 2, doc.height,
                            leftPadding=0, rightPadding=0, topPadding=0, bottomPadding=0,
                            id='right'
                        )
                    ],
                    pagesize=A4
                )
            ])
            doc.build(self.get_story(doc))
            f.seek(0)
            r = HttpResponse(content_type='application/pdf')
            r.write(f.read())
            return r
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号