带有 iText 7 的 PDF 中的希腊字符

Greek characters in PDF with iText 7

我正在尝试使用 iText 7 为 Java 创建一个带有希腊字符的 pdf。 PDF 中仅显示拉丁字符和数字。

我正在使用此代码加载字体:

PdfFont normalFont = PdfFontFactory.createFont(FontConstants.HELVETICA, "CP1253");

我该怎么办?

这是解决方案:

PdfFont normalFont = PdfFontFactory.createFont("C:\Windows\Fonts\arial.ttf", "Identity-H", true);

您可以使用支持您的语言的任何字体。另外,Identity-H 作为 PDF 文件的编码似乎很重要。