Java 如何通过iText7配置断字?

Java 如何通过iText7配置断字?,java,itext,itext7,hyphen,hyphenation,Java,Itext,Itext7,Hyphen,Hyphenation,我尝试将字符串与连字号连接。 我使用了示例代码,但它返回null,而不是连字符字符串或连字符对象: Hyphenator h = new Hyphenator("de", "DE", 2, 2); Hyphenation s = h.hyphenate("Leistungsscheinziffer"); System.out.println(s);//this is null and not "Lei-stungs-schein-zif-fer" 我对pom.xml的依赖性是: <dep

我尝试将字符串与连字号连接。
我使用了示例代码,但它返回null,而不是连字符字符串或连字符对象:

Hyphenator h = new Hyphenator("de", "DE", 2, 2);
Hyphenation s = h.hyphenate("Leistungsscheinziffer");
System.out.println(s);//this is null and not "Lei-stungs-schein-zif-fer"
我对pom.xml的依赖性是:

<dependency>
    <groupId>com.itextpdf</groupId>
    <artifactId>layout</artifactId>
    <version>7.1.2</version>
</dependency>
<dependency>
    <groupId>com.itextpdf</groupId>
    <artifactId>hyph</artifactId>
    <version>7.1.2</version>
    <scope>test</scope>
</dependency>

com.itextpdf
布局
7.1.2
com.itextpdf
连字符
7.1.2
测试
有我忘记配置的吗


谢谢你帮我解决这个问题。:)

您将
连字符
作为
测试
依赖项(请参见
)。这意味着,它只在运行测试时添加。如果要在非测试环境中使用
hyf
,请确保依赖项为,例如
compile
(默认值为
compile
):


com.itextpdf
连字符
7.1.2

哦,多么令人尴尬的错误!感谢您提供的快速解决方案。
<dependency>
    <groupId>com.itextpdf</groupId>
    <artifactId>hyph</artifactId>
    <version>7.1.2</version>
</dependency>