简体   繁体   English

有没有办法使用 pyfpdf2 用点填充(多)单元格的剩余空间?

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

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 .我目前正在处理一个 Django 项目,在该项目中,客户需要打印报告,其中剩余空间用点动态填充到行尾。 I'm using the PyFpdf2 library for PDF reports.我将 PyFpdf2 库用于 PDF 报告。 The outputs should look like this: This is line 1.................... This is line 2....................输出应如下所示: 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?任何人都可以帮忙吗?

Oh, I got the answer I needed.哦,我得到了我需要的答案。 The python string methods ljust , center and rjust are just what I needed! python 字符串方法ljustcenterrjust正是我所需要的! For instance例如

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

The outputs fills up the remaining spaces with dots like John..........输出用像John..........

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM