How can I make the bullet appear directly next to the text of an indented list in the reportlab package for python?

♀尐吖头ヾ 提交于 2019-12-01 18:36:01

Just pass a leftIndent parameter into the ListItem.

my_list = ListFlowable([
    ListItem(Paragraph("Line 1", styles['Normal']),
         leftIndent=35, value='circle',
         bulletColor=CMYKColor(0.81, 0.45, 0.53, 0.23)
    ),
    ListItem(Paragraph("Line 2", styles['Normal']),
         leftIndent=35, value='circle',
         bulletColor=CMYKColor(0.81, 0.45, 0.53, 0.23))
],
bulletType='bullet',
start='circle',
leftIndent=10
)

EDIT: You have to set the leftIndent of the ListFlowable for defining the space between the bullets and the text.

I ended up looking further into it (the ReportLab source code…) to discover how to deal with the bullets not being correctly-aligned vertically, either. I suggest the following additional kwargs for other bulleted-list control freaks:

  • bulletOffsetY +ve to move it up, -ve to move it down
  • bulletFontSize if you ended up with huge bullets by default like I did
  • spaceBefore and spaceAfter to control the vertical gaps between list items
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!