目前,我正在使用reportlab TableOfContent类,它正在创建类似以下内容的输出:
这对我来说没关系,但当我尝试使用addEntry()方法添加条目时,它什么也不做,下面是我的代码:
def table_of_content(self):
toc = TableOfContents()
PS = ParagraphStyle
#*************************#
#***Table of Contents***#
self.story.append(Paragraph('<b>Table of Contents</b>', centered))
toc.levelStyles = [
PS(fontName=FONT_NAME, fontSize=14, name='TOCHeading1',
leftIndent=20, firstLineIndent=-20, spaceBefore=5, leading=16),
PS(fontSize=12, name='TOCHeading2', fontName=FONT_NAME,
leftIndent=40, firstLineIndent=-20, spaceBefore=0, leading=12),
PS(fontSize=10, name='TOCHeading3', fontName=FONT_NAME,
leftIndent=60, firstLineIndent=-20, spaceBefore=0, leading=12),
PS(fontSize=10, name='TOCHeading4', fontName=FONT_NAME,
leftIndent=100, firstLineIndent=-20, spaceBefore=0, leading=12),
]
# self.story.append(para)
toc.addEntry(0, "hammad", 1, 3)
self.story.append(toc)
有人能帮我吗?我怎样才能在目录中添加条目?提前谢谢
你试过打电话给
self.notify('TOCEntry', (i, value, self.page))
吗相关问题 更多 >
编程相关推荐