简体   繁体   中英

Java XSL-FO hyphenation in PDF formatting

I have a Java program that generates an XML file, which is rendered in to a PDF. The problem is that I can't seem to get the hyphenation to work.

I've read trough https://www.w3.org/TR/xsl/#d0e26492 briefly but I still don't understand why I can't get my text to hyphenate. I've tried inserting hyphenate="true" in nearly all blocks but strings such as "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA..." still go out of bounds. I've tried to set language and locale too but I don't really care where the hyphenation happens, anywhere would be fine.

Hyphenation is usually based on a hyphenation dictionary and/or an algorithm that matches known sequences of letters and breaks words only where it is allowed. Different languages have different hyphenation conventions, and even US English and British English have differences.

Strings like "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA..." are unlikely to match anything in a hyphenation dictionary, so the implementation doesn't know where to break the "word".

You probably want something like some of the solutions proposed for breaking text in table cells; for example:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM