Search code examples
djangoreportlab

Invisible table borders ReportLab


I need to display some information on a ReportLab PDF that will be side by side. For example, below is a little pretend PDF. I have to have Thing 1 and Thing 2 beside each other with information below them.

--------------------------- | Thing 1: Thing 2: | | A-B-C 1-2-3 | | D-E-F 4-5-6 | | | | | -----------------------------

I used Paragraph to start, but I couldn't find a way to make Thing 1 and Thing 2 line up. So I was thinking about using a table. Is there a way I can have multiple tables on a PDF that all have invisible borders?


Solution

  • I figured out the answer, I just made the table borders and cells to the colour white.

    pdf_table.setStyle(TableStyle([('INNERGRID', (0, 0), (-1, -1), 0.25, colors.white), ('BOX', (0, 0), (-1, -1), 0.25, colors.white)]))


    Imports needed:

    from reportlab.lib import colors
    from reportlab.platypus.tables import TableStyle
    

    Further reading about tables here.