problem of underlining text

41 views
Skip to first unread message

Vyacheslav Vyacheslav

unread,
Feb 15, 2025, 8:37:55 AMFeb 15
to reportlab-users

Hello! Please help me solve the problem of underlining text. When I use indentation, the underline is displayed incorrectly. How can I solve this? Thank you very much for your help!

from reportlab.lib.colors import (
green,
)
from reportlab.lib.enums import (
TA_LEFT,
)
from reportlab.lib.styles import ParagraphStyle
from reportlab.platypus import (
SimpleDocTemplate,
Paragraph,
)
from reportlab.lib.pagesizes import A4


def create_pdf(
output_file: str,
text: str,
pagesize: tuple[float, float] = A4,
) -> None:
doc = SimpleDocTemplate(
filename=output_file,
pagesize=pagesize,
)

body_style_3 = ParagraphStyle(
name="BodyStyle3",
fontSize=13,
alignment=TA_LEFT,
backColor=green,
leftIndent=60,
rightIndent=60,
)
body_text_3 = Paragraph(text=f'<u>{text}</u>', style=body_style_3)

elements = [
body_text_3,
]

doc.build(flowables=elements)


if __name__ == "__main__":
create_pdf(
output_file='simple_doc_template.pdf',
text='Document text' * 100,
)

Result:


112122121.png

Reply all
Reply to author
Forward
0 new messages