Search code examples
pythondjangopdfreportlabparagraph

Inserting Horizontal Line within Paragraph [ Reportlab ]


I seen a few example code which add a horizontal line using a Table, however I was wondering if there a faster way using the Paragraph instead. I look into the reportlab docs, however I could find anything.

So my question is, is it possible to add a horizontal line using Paragraph instead?


Solution

  • The fastest way is probably using the HRFlowable this flowable attempt to mimic the behavior of the HTML <HR> just to give you an indication, this is how it looks in HTML:


    As this function is not documented the best I can do is refer you to the source code which show all options that are available.

    Below my own attempt of documenting this flowable

    HRFlowable(width="80%", thickness=1, lineCap='round', color=lightgrey, spaceBefore=1, spaceAfter=1, hAlign='CENTER', vAlign='BOTTOM', dash=None)

    width: Width of the horizontal line
    thickness: Height of the horizontal line
    lineCap: Determines whether a terminating line ends in a square exactly at the vertex, a square over the vertex or a half circle over the vertex.
    color: Straight forward
    spaceBefore: ??? Isn't used in the source code
    spaceAfter: ??? Isn't used in the source code
    hAlign: ??? Isn't used in the source code
    vAlign: ??? Isn't used in the source code
    dash: Allows the line to be broken into dots or dashes.