I have created a small Java Swing application to generate PDFs of XML files here at my workplace. I need to enable hyphenation, as I have some text in tables that flows outside the cell borders.
I have downloaded the OFFO Compiled Hyphenation Patterns for FOP and placed the fop-hyph.jar file alongside my fop.jar in my "lib" folder.
When I run the application I get the following error:
Jan 20, 2016 2:57:43 PM org.apache.fop.hyphenation.Hyphenator getHyphenationTree
SEVERE: Couldn't find hyphenation pattern for lang="en",country="US".
I am using FOP 2.0 and have the following entry in my fop.xconf file:
<hyphenation-pattern lang="en">en_US</hyphenation-pattern>
I have also tried this with no difference:
<hyphenation-pattern lang="en" country="US">en_US</hyphenation-pattern>
On the root of the XSL-FO file I have entered:
<fo:root font-family="Helvetica" language="en" country="US" hyphenate="true">
What am I missing to get this working? Everything else works fine, creates PDFs correctly.
According to the hyphenation pattern installation instruction, the pattern file for American English is called just en.xml
, so in the configuration file you should have:
<hyphenation-pattern lang="en">en</hyphenation-pattern>
By the way, the entries in the configuration file are only needed when you want something different from the default behaviour, so in this case you could omit it completely.