Is there a way to fill up a (multi)cell's remaining space with dots using pyfpdf2?

478 Views Asked by At

I'm currently working on a Django project in which the client needs to print reports where remaining spaces are filled up with dots up to the end of the line dynamically. I'm using the PyFpdf2 library for PDF reports. The outputs should look like this: This is line 1.................... This is line 2....................

I am using basic cells and multicells as:

pdf = FPDF()
pdf.add_page()
pdf.set_font('Arial', '', 12)
pdf.cell(40, 8, 'This is line 1........')

Anyone can help?

1

There are 1 best solutions below

0
On

Oh, I got the answer I needed. The python string methods ljust, center and rjust are just what I needed! For instance

name = 'John'
print(name.ljust(20, '.')

The outputs fills up the remaining spaces with dots like John..........