我正在使用reportlab生成pdf,我希望我的标题位于中心。但如何实现,找不到解决方案。
这是我的代码:
def add_text(text, style="Normal", fontsize=12):
Story.append(Spacer(1, 12))
ptext = "<font size={}>{}</font>".format(fontsize, text)
Story.append(Paragraph(ptext, styles[style]))
Story.append(Spacer(1, 12))
add_text("Title", style="Heading1", fontsize=24)
Run Code Online (Sandbox Code Playgroud)