使用 FOP 2.0 的断字问题

Problems with hyphenation using FOP 2.0

我创建了一个小型 Java Swing 应用程序,用于在我的工作场所生成 XML 文件的 PDF。我需要启用断字,因为表格中有一些文本流到单元格边界之外。

我已经下载了 FOP 的 OFFO 编译断字模式,并将 fop-hyph.jar 文件放在我的 fop.jar 旁边,放在我的 "lib" 文件夹中。

当我 运行 应用程序时,出现以下错误:

Jan 20, 2016 2:57:43 PM org.apache.fop.hyphenation.Hyphenator getHyphenationTree
SEVERE: Couldn't find hyphenation pattern for lang="en",country="US".

我正在使用 FOP 2.0 并且在我的 fop.xconf 文件中有以下条目:

<hyphenation-pattern lang="en">en_US</hyphenation-pattern>

这个我也试过了,没什么区别:

<hyphenation-pattern lang="en" country="US">en_US</hyphenation-pattern>

在我输入的 XSL-FO 文件的根目录中:

<fo:root font-family="Helvetica" language="en" country="US" hyphenate="true">

我缺少什么才能让它正常工作?其他一切正常,正确创建 PDF。

根据hyphenation pattern installation instruction,美国英语的模式文件被称为en.xml,所以在配置文件中你应该有:

<hyphenation-pattern lang="en">en</hyphenation-pattern>

顺便说一句,配置文件中的条目仅在您想要不同于默认行为的情况下才需要,因此在这种情况下您可以完全省略它