我用 Java 中的 iText 生成 PDF 文件。我的表格列具有固定的宽度和文本,这对于单元格中的一行来说太长了。但不使用连字符。“Leistungsscheinziffer”一词显示为:Leistungssc //Break here heinziffer
我使用连字符的代码:
final PdfPTable table = new PdfPTable(sumCols);
table.getDefaultCell().setBorder(Rectangle.NO_BORDER);
table.getDefaultCell().setPadding(4f);
table.setWidths(widthsCols);
table.setWidthPercentage(100);
table.setSpacingBefore(0);
table.setSpacingAfter(5);
final Phrase result = new Phrase(text, font);
result.setHyphenation(new HyphenationAuto("de", "DE", 2,2));
final PdfPCell cell = new PdfPCell(table.getDefaultCell());
cell.setPhrase(result);
table.addCell(cell);
...
连字符被激活并且以下测试结果“Lei-stungs-schein-ziff-fer”
Hyphenator h = new Hyphenator("de", "DE", 2, 2);
Hyphenation s = h.hyphenate("Leistungsscheinziffer");
System.out.println(s);
有什么我忘了设置连字符在那里工作的表吗?谢谢你的帮助。如果您需要有关我的代码的更多信息,我会告诉您。