简体   繁体   English

PDF 格式中的 Java XSL-FO 断字

[英]Java XSL-FO hyphenation in PDF formatting

I have a Java program that generates an XML file, which is rendered in to a PDF.我有一个生成 XML 文件的 Java 程序,该文件呈现为 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.我已经简要地阅读了https://www.w3.org/TR/xsl/#d0e26492,但我仍然不明白为什么我不能让我的文本连字符。 I've tried inserting hyphenate="true" in nearly all blocks but strings such as "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA..." still go out of bounds.我已经尝试在几乎所有块中插入hyphenate="true"但诸如“AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...”之类的字符串仍然超出范围。 I've tried to set language and locale too but I don't really care where the hyphenation happens, anywhere would be fine.我也尝试设置languagelocale但我并不在乎连字发生的位置,任何地方都可以。

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".像“AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...”这样的字符串不太可能匹配断字字典中的任何内容,因此实现不知道在哪里打破“单词”。

You probably want something like some of the solutions proposed for breaking text in table cells;您可能想要一些类似于为打破表格单元格中的文本而提出的解决方案; for example:例如:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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