'ReportLab numbering with nested bullet points
I'm struggeling with ReportLab which I would like to use to generate a PDF as a request from Django from a view.
I try to get a numbered list with bullet points in between like that
- Text1-blabla
- Bullet-blabla
- Bullet-blabla
- Text2 blabla
But what I receive is:
- Text1-blabla
-
- Bullet-blabla
- Bullet-blabla
- Text2 blabla
How can I suppres the "2." infront of the bullets or how can I skip it for that region?
This is my code
lf = ListFlowable([ ListItem(Paragraph(text1, styles["Normal"])),
ListFlowable([ListItem(Paragraph(text1a, styles["Normal"])),
ListItem(Paragraph(text1b, styles["Normal"])),
ListItem(Paragraph(text1c, styles["Normal"])),
ListItem(Paragraph(text1d, styles["Normal"])),
], bulletType='bullet', bulletFontSize= 5, bulletOffsetY= -2, leftIndent=10, start='circle'),
ListItem(Paragraph(text2, styles["Normal"]))
], bulletType='1')
Thank you!
Solution 1:[1]
So what I figured out now to solve that issue is to nest it againin another ListFlowable and set there the leftIndent to '0' and the bulletColor to 'white'.
lf = ListFlowable([
ListFlowable([
ListItem(Paragraph(text1, styles["Normal"]), spaceAfter=12),
ListFlowable([ListItem(Paragraph(text1a, styles["Normal"])),
ListItem(Paragraph(text1b, styles["Normal"])),t
], bulletType='bullet', bulletFontSize= 5, bulletOffsetY= -2, leftIndent=10, start='circle')], bulletColor='white', leftIndent=0),
ListItem(Paragraph(text2, styles["Normal"]), spaceBefore=12),
], bulletType='1', bulletFontSize= 10)
Solution 2:[2]
You can turn off the numbering for one list item by inserting the nested list into ListItem with value argument set to 0: ListFlowable([ Paragraph(...), ListItem(ListFlowable(...nested list...), value=0) ListItem(Paragraph(...), value=2) # to let the list go on ])
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Kev |
| Solution 2 | Kamil Šrot |
