I'm creating a software that when you write everything, generate a PDF. I'm using Python, Tkinter and the follows modoles: ParagraphStyle,Paragraph
See My code:
from reportlab.pdfgen import canvas
from reportlab.lib.styles import ParagraphStyle
from reportlab.platypus import Paragraph
from reportlab.lib.pagesizes import A4
my_Style=ParagraphStyle(name='CustomStyle',
parent=getSampleStyleSheet()['Normal'],
spaceAfter=12, # Space after the paragraph
spaceBefore=12, # Space before the paragraph
fontSize=12,
backColor='green',
wordWrap='hyphen',
leading=14,
borderColor='green',
textColor='black',
borderTopStyle='dotted', # Top border line style (e.g., 'solid', 'dashed', 'dotted')
alignment=0) # or 'bottom'
width,height=A4
my_path='my_pdf.pdf'
c = canvas.Canvas(my_path, pagesize=A4)
#O quebra liinha não é feito pelo drwaOn, mas sim pelo o estilo
p1=Paragraph('''começa aqui: \n<b>About this online classes </b><BR/>\
Welcome to our online classes.<BR/> \
You can l \
SQLite and many more \
<font face="times" color="blue">We are creating \
PDF bytLab</font> \
<i>This is part of our Final report.</i>''',my_Style)
#Place our Paragraph on the canvas like this.
p1.wrapOn(c,300,0)
p1.drawOn(c,15,400)
c.save()
import webbrowser
webbrowser.open('my_pdf.pdf')
How can you see, will generate a PDF like the follow first image.enter image description here
So far so good. But, when there are less characters, the break line go up and not down. Look to the second image: enter image description here
Everywhere, when you type, the text goes down. In that case, it goes up. How to make paragraph default?
I've change wordWrap configure,parent,alignment configure and nothing happen.