猫史档案馆


刚做的《源码表格》

用户:Y-SJiaoY-SJiao查看:0 回复:0 评论:0 创建时间:2022-01-08T23:41:25


from reportlab.platypus import SimpleDocTemplate as site
from reportlab.platypus import Table as tbl
from reportlab.platypus import TableStyle as TDS
from reportlab.lib import colors as cl
from reportlab.pdfbase.ttfonts import TTFont as tf
from reportlab.pdfbase.pdfmetrics import registerFont as rf
import webbrowser as wr
import os

dt = [["中文", "测", "试"], ["编", "程", "猫"]]
c = []
d = site("源码表格.pdf")
t = tbl(dt, colWidths=100, rowHeights=100)
rf(tf('clw', 'clw.TTF'))
t.setStyle(TDS([
        ('TEXTCOLOR', (1, 1), (1, 1), cl.red),
        ('TEXTCOLOR', (0, 0), (2, 1), cl.blue),
        ('INNERGRID', (0, 0), (-1, -1), 2, cl.black),
        ('BOX', (0, 0), (-1, -1), 2, cl.black),
        ('ALIGH', (0, 0), (-1, -1), 'CENTER'),
        ('VALIGH', (0, 0), (-1, -1), 'MIDDLE'),
        ('FONTSIZE', (0, 0), (-1, -1), 15),
        ('FONTNAME', (0, 0), (-1, -1), "clw")
]))

c.append(t)
d.build(c)
wr.open("file://" + os.path.realpath("源码表格.pdf"))


回复

上一页1 页 / 共 0下一页