test_pdf.py 文件源码

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

项目:ZLib 作者: zenist 项目源码 文件源码
def test_06_fontsize(self):
        from reportlab.lib.pagesizes import A4
        from reportlab.pdfgen.canvas import Canvas
        from reportlab.lib.units import inch
        from reportlab.lib.colors import red, magenta
        c = Canvas('demo.pdf', pagesize=A4)
        c.translate(inch, inch)
        c.setFont("Times-Roman", 20)
        c.setFillColor(red)
        c.saveState()
        c.drawCentredString(2.75*inch, 2.5*inch,"Font size excmples")
        c.setFillColor(magenta)
        size = 7
        x = 2.3 * inch
        y = 1.3 * inch
        for line in range(7):
            c.setFont("Helvetica", size)
            c.drawRightString(x, y, "%s points" % size)
            c.drawString(x,y, "test")
            y = y-size*1.2
            size = size+1.5
        c.restoreState()
        c.drawString(0,0, "%s" % c.getAvailableFonts())
        c.showPage()
        c.save()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号