本文整理汇总了Python中reportlab.platypus.doctemplate.BaseDocTemplate._startBuild方法的典型用法代码示例。如果您正苦于以下问题:Python BaseDocTemplate._startBuild方法的具体用法?Python BaseDocTemplate._startBuild怎么用?Python BaseDocTemplate._startBuild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类reportlab.platypus.doctemplate.BaseDocTemplate
的用法示例。
在下文中一共展示了BaseDocTemplate._startBuild方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _startBuild
# 需要导入模块: from reportlab.platypus.doctemplate import BaseDocTemplate [as 别名]
# 或者: from reportlab.platypus.doctemplate.BaseDocTemplate import _startBuild [as 别名]
def _startBuild(self, filename=None, canvasmaker=canvas.Canvas):
BaseDocTemplate._startBuild(self, filename=filename, canvasmaker=canvasmaker)
type2lvl = {"chapter": 0, "article": 1, "heading2": 2, "heading3": 3, "heading4": 4}
got_chapter = False
last_lvl = 0
for (bm_id, (bm_title, bm_type)) in enumerate(self.bookmarks):
lvl = type2lvl[bm_type]
if bm_type == "chapter":
got_chapter = True
elif not got_chapter: # outline-lvls can't start above zero
lvl -= 1
lvl = min(lvl, last_lvl + 1)
last_lvl = lvl
self.canv.addOutlineEntry(bm_title, str(bm_id), lvl, bm_type == "article")
示例2: _startBuild
# 需要导入模块: from reportlab.platypus.doctemplate import BaseDocTemplate [as 别名]
# 或者: from reportlab.platypus.doctemplate.BaseDocTemplate import _startBuild [as 别名]
def _startBuild(self, filename=None, canvasmaker=canvas.Canvas):
BaseDocTemplate._startBuild(self, filename=filename, canvasmaker=canvasmaker)
type2lvl = {'chapter': 0,
'article': 1,
'heading2': 2,
'heading3': 3,
'heading4': 4,
'heading5': 5,#new
'heading6': 6,
}
got_chapter = False
last_lvl = 0
for (bm_id, (bm_title, bm_type)) in enumerate(self.bookmarks):
lvl = type2lvl[bm_type]
if bm_type== 'chapter':
got_chapter = True
elif not got_chapter: # outline-lvls can't start above zero
lvl -= 1
lvl = min(lvl, last_lvl + 1)
last_lvl = lvl
self.canv.addOutlineEntry(bm_title, str(bm_id), lvl, bm_type == 'article')