how to group objects in reportlab, so that they stay together across new pages

后端 未结 3 1677
不知归路
不知归路 2021-02-13 13:37

I\'m generating some pdf files using reportlab. I have a certain section that is repeated. It contains of a header and a table:

            Story.append(Paragrap         


        
3条回答
  •  無奈伤痛
    2021-02-13 14:35

    Using a ParagraphStyle might actually be better so i figured i'd add it to this super old answer.

    Found this in their changelog after seeing @memyself's answer.

      * `KeepWithNext` improved:
        Paragraph styles have long had an attribute keepWithNext, but this was 
        buggy when set to True. We believe this is fixed now. keepWithNext is important 
        for widows and orphans control; you typically set it to True on headings, to 
        ensure at least one paragraph appears after the heading and that you don't get 
        headings alone at the bottom of a column. 
    
    header = ParagraphStyle(name='Heading1', parent=normal, fontSize=14, leading=19,
                            spaceAfter=6, keepWithNext=1)
    

提交回复
热议问题