Using ReportLab, I want to display a block of text with a large font size. Right now, my code puts the text in a paragraph so that it can be wrapped in a word. However, the text is crowded during rendering.
It seems that the height specified for the Paragraph object is not taken into account. Is there an attribute for a paragraph that I can add to fix this?
My code is below:
from reportlab.pdfgen import canvas from reportlab.lib.units import inch from reportlab.platypus import Paragraph from reportlab.lib.styles import ParagraphStyle from reportlab.lib.enums import TA_CENTER doc = canvas.Canvas('test.pdf') p = ParagraphStyle('test') p.textColor = 'black' p.borderColor = 'black' p.borderWidth = 1 p.alignment = TA_CENTER p.fontSize = 100 para = Paragraph("THIS IS A REALLY LONG AND BIG STRING OF TEXT RIGHT HERE!!!!!", p) para.wrapOn(doc,1200,1000) para.drawOn(doc, 0.5*inch, 6*inch) doc.save()
source share