用户:
Frances_Rui查看:0 回复:0 评论:0 创建时间:2020-10-16T20:11:57
import webbrowser
import os
from reportlab.lib.styles import getSampleStyleSheet
from reportlab.platypus import SimpleDocTemplate, Paragraph
styles = getSampleStyleSheet() # 获取样式表
doc = SimpleDocTemplate("final.pdf", title="没想到一个好标题", author="Francis",
subject="没想到一个好主题", keywords=["Reportlab", "无标题", "pdf", "文档模板"]) # 使用模板创建文档
content = [] # 内容列表
p = Paragraph("Test", styles['Normal'])
content.append(p)
doc.build(content) # 渲染内容
webbrowser.open("file://" + os.path.realpath("final.pdf"))
祝大家在Reportlab玩的开心~
(第8-9行:可以自己修改属性)