设置
我正在使用 iText 5.3.0 和 Fedora 17,使用 PDF 阅读器 llpp 和 evince 进行测试。我的 IDE 是 Eclipse Indigo r2。我的终端是 urxvt,其字体与 PDF 中使用的字体相同。
问题
其他 unicode 字符显示得很好。 iText 书中的 list 11.3 显示得很好。但试图得到一个 X̲,X 与 an underline ,例如 "X\u0332"
不会显示在 PDF 上。我可以使用 System.out.println 将字符串记录到终端,它工作得很好。这是我正在尝试的示例:
public static void main(String[] args) throws DocumentException, IOException {
Document document = new Document(PageSize.LETTER);
PdfWriter.getInstance(document, new FileOutputStream("fnord.pdf"));
document.open();
FontFactory.register("fonts/mplus-1mn-regular.ttf", "mplus");
Font font = FontFactory.getFont(
"mplus",
BaseFont.IDENTITY_H,
BaseFont.EMBEDDED,
12
);
String s = "X\u0332";
System.out.println(s);
document.add(new Paragraph(s, font));
document.close();
}
我发现了一个古老的,可能相关的,email from Paulo Soares说“在将文本呈现给 iText 之前必须完成字符组合”。
我不确定这意味着什么,或者如何做,或者它是否仍然相关。
预期/实际
我期望:带有 X 的 PDF,X 下方有一条线,即 X̲。
我得到:带有 X 的 PDF,没有线条。
最佳答案
您的角色是非空格角色,see here
编辑页面说它在左侧和右侧连接,所以我的答案不是很有用:(
关于java - 无法使用 iText 显示 unicode 0x0332,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13387355/