亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

帶有嵌套項目符號點的 ReportLab 編號

帶有嵌套項目符號點的 ReportLab 編號

慕神8447489 2023-05-23 14:56:21
我在 ReportLab 上苦苦掙扎,我想用它來生成 PDF 作為來自視圖的 Django 的請求。我試著得到一個編號列表,中間有要點文本 1 blabla子彈-blabla子彈-blabla文本 2 blabla但我收到的是:文本 1 blabla子彈-blabla子彈-blabla文本 2 blabla我怎樣才能抑制“2”。在項目符號前面或者我如何跳過該區域?這是我的代碼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')
查看完整描述

3 回答

?
BIG陽

TA貢獻1859條經驗 獲得超6個贊

這是搜索如何在 ReportLab 中制作嵌套列表的人們的最佳結果,

您可以將ListFlowablealist作為其項目之一。如果其中list包含 aParagraph和 another ,它將在同一個項目符號點內ListFlowable呈現嵌套ListFlowable在 the 之后的Paragraph權利。

t = ListFlowable(

? ? [

? ? ? ? Paragraph("Item no. 1", style),

? ? ? ? [

? ? ? ? ? ? Paragraph("Item no. 2", style),

? ? ? ? ? ? ListFlowable(

? ? ? ? ? ? ? ? [

? ? ? ? ? ? ? ? ? ? Paragraph("sublist item 1", style),

? ? ? ? ? ? ? ? ? ? ListItem(Paragraph('sublist item 2', style), bulletColor='red')

? ? ? ? ? ? ? ? ],

? ? ? ? ? ? ? ? bulletType='bullet',

? ? ? ? ? ? ? ? bulletFontSize=5,

? ? ? ? ? ? ? ? start='square',

? ? ? ? ? ? )

? ? ? ? ],

? ? ? ? Paragraph("Item no. 3", style),

? ? ],

? ? bulletType='1',

? ? bulletFormat='%s.',

? ? bulletFontSize=8,

)

不要費心隱藏多余的項目符號,或告訴 ReportLab 不要渲染它然后必須仔細管理value后續的ListItem項目符號。<ul>它與 HTML 中的s 和s完全一樣<ol>。


上面的代碼呈現如下:

http://img4.sycdn.imooc.com/646c64430001ba8a02780158.jpg

查看完整回答
反對 回復 2023-05-23
?
瀟湘沐

TA貢獻1816條經驗 獲得超6個贊

您可以通過將嵌套列表插入 ListItem 并將值參數設置為 0 來關閉一個列表項的編號:ListFlowable([ Paragraph(...), ListItem(ListFlowable(...nested list...), value= 0) ListItem(Paragraph(...), value=2) # 讓列表繼續下去 ])



查看完整回答
反對 回復 2023-05-23
?
汪汪一只貓

TA貢獻1898條經驗 獲得超8個贊

所以我現在想出解決這個問題的方法是將它再次嵌套在另一個 ListFlowable 中,并將 leftIndent 設置為“0”,將 bulletColor 設置為“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)


查看完整回答
反對 回復 2023-05-23
  • 3 回答
  • 0 關注
  • 295 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號