I have a design template that forces me to use very large uppercase letters for a headline. If I have a long word that does not fit into one line, I run into expected problems because RL does not have built-in hyphenation – that’s okay. If I have a long compound word, however, that contains a hyphen (e.g. "VVVVEEEERRRRYYYY-LLLLOOOONNNNGGGG"), it is not broken at the hyphen as I would expect.
Expected:
|VVVVEEEERRRRYYYY- |
|LLLLOOOONNNNGGGG |
Actual:
|VVVVEEEERRRRYYYY-LLLLOO|
|OONNNNGGGG |
How can I tell ReportLab to perform a conditional line-break when encountering a hyphen?
BTW, the PDF is generated using Python 3.4 and reportlab 3.1.8 like so:
doc = BaseDocTemplate(fname,
leftMargin=20 * mm, rightMargin=20 * mm,
topMargin=25 * mm, bottomMargin=20 * mm)
story = []
frame_first_page = Frame(doc.leftMargin, doc.bottomMargin, doc.width,
doc.height - 24 * mm,
leftPadding=0, rightPadding=0, id='first')
doc.addPageTemplates([PageTemplate(id='first_page',
frames=frame_first_page,
onPage=_on_first_page),
PageTemplate(id='remaining_pages',
frames=frame_remaining_pages,
onPage=_on_remaining_pages)])
story.append(Paragraph(heading_text.upper(), styles["title"]))
doc.build(story)
` to add a line break. So you could try to add `heading_text.replace('-', '-
')` before appending the `Paragraph` to the doc... But honestly I didn't try it. – jbihan Jan 28 '15 at 18:26