猫史档案馆


Python class :D (pdf + pychart)

用户:Auggie0w0Auggie0w0查看:0 回复:1 评论:0 创建时间:2021-11-07T09:28:15


# from reportlab.platypus import SimpleDocTemplate, Table, TableStyle
from reportlab.lib import colors
from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.ttfonts import TTFont
from reportlab.pdfgen import canvas
import webbrowser
import os

pdfmetrics.registerFont(TTFont('fangzheng', 'fangzheng.TTF'))

c = canvas.Canvas("form.pdf")
c.setFont('fangzheng',15)
c.drawString(298,800, "mail for sentinel")
form = c.acroForm

c.drawCentredString(200,700,"NAME")
form.textfield(x=300,y=700, fillColor= colors.white)
c.drawCentredString(200, 600,"gender")
c.drawCentredString(300, 600, "male")
form.checkbox(x=325, y=595, buttonStyle='check')
c.drawCentredString(370, 600, "female")
form.checkbox(x=400, y=595, buttonStyle='check')
c.drawCentredString(440, 600, "other")
form.checkbox(x=460, y=595, buttonStyle='check')
form.choice(x=300,y=480,value='6',options=[str(i) for i in range(6,19)])

# form.textfield(x=100,y=200, 
#             fieldFlags='multiline', 
#             width=200, height=100,
#             fillColor=colors.blue,
#             textColor=colors.white)
# form.checkbox(x=50, y=300, buttonStyle='check')
# form.choice(x=100, y=300, value='pro', options=('cal','pro','drs'))

c.save()

webbrowser.open("file://" + os.path.realpath("form.pdf"))


回复

上一页1 页 / 共 1下一页
一块数据碎片一块数据碎片

 b ,hd nlchl f

点赞0


评论