online.py 文件源码

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

项目:badge-o-matic 作者: markuslindenberg 项目源码 文件源码
def hello(c, link):
    c.translate(ORIGIN_X, ORIGIN_Y)

    # Draw paragraph
    stylesheet = getSampleStyleSheet()
    style = stylesheet['BodyText']
    style.fontName = 'LeagueGothic'
    style.fontSize = 42
    style.leading = 44

    p = Paragraph('<b>print</b><br/>your<br/><b>badge</b><br/>here', style)
    qr_left = 30*mm
    p_w, p_h = p.wrap(qr_left, HEIGHT)
    p.drawOn(c, 0, 0)


    # Add QR Code
    qr_code = qr.QrCodeWidget(link)
    qr_bounds = qr_code.getBounds()
    qr_width = qr_bounds[2] - qr_bounds[0]
    qr_height = qr_bounds[3] - qr_bounds[1]
    d = Drawing(HEIGHT, HEIGHT, transform=[HEIGHT/qr_width,0,0,HEIGHT/qr_height,0,0])
    d.add(qr_code)
    renderPDF.draw(d, c, qr_left, 0)

    # Draw thin line between text and QR code
    c.line(qr_left, 0, qr_left, HEIGHT)
    c.line(qr_left + HEIGHT, 0, qr_left+HEIGHT, HEIGHT)

    img_left = qr_left + HEIGHT

    # Draw images
    c.drawImage('images/ipv6.jpg', img_left, 0, 20*mm, 1/3 * HEIGHT, mask=None, preserveAspectRatio=True, anchor='c')
    c.drawImage('images/ffrhein_logo_claim_line_rot.png', img_left, 1/3*HEIGHT, 20*mm, 2/3 * HEIGHT, mask=None, preserveAspectRatio=True, anchor='c')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号