Wayne Davis
Wayne Davis

Reputation: 49

Reportlab wordwrap not adding hyphen

I'm using Reportlabs paragraphstyles default wordwrap which, along with   as needed gives me what I want except for one case, when a long word won't fit in a small cell. Currently it's wrapping properly but I want it to insert a hyphen when it wraps. I'm getting:

Gainesvil
le

but want:

Gainesvil-
le

My styling is: ParagraphStyle('events', fontName = "Arial', fontSize=10, parent=styles['Normal'], leading=1.1, alignment= TA_LEFT)

The cell is city name and is narrow. Word wrapping happens when the font is increased too much. This is my first Reportlab project and I can't find what I need in the documentation or anywhere else. I can't use 'splitLongWords = False' because then it overwrites the next column.

Thank you.

Tried wordWrap='CJK' then wordwrap='LTR', couldn't figure out wordwrap options, only found 'LTR' in an example.

Upvotes: 0

Views: 105

Answers (1)

Wayne Davis
Wayne Davis

Reputation: 49

Stumbled across the answer while searching for something else. Apparently Robin Becker solved this:

pip install pyphen

import pyphen

Added to paragraphStyle:

hyphenationLang = 'en',

That's it. It works in paragraphs.

Discussion and solution:

Upvotes: 0

Related Questions