Java Itext7 PDF字体编码 - 波兰字符不可见
我正在使用库的最新ITEXT7版本来生成PDF。我已经偶然发现了这个问题的问题,基本上,一些字符缺失,具体取决于我选择的编码。但是似乎没有编码支持的波兰角色。
这是我用来创建字体的代码:
public static final String FONT_BOLD = "src/main/resources/fonts/NunitoSans-Bold.ttf";
public static final String FONT_EXTRA_BOLD = "src/main/resources/fonts/NunitoSans-ExtraBold.ttf";
public static final String FONT_SEMI_BOLD = "src/main/resources/fonts/NunitoSans-SemiBold.ttf";
PdfFont boldFont = PdfFontFactory.createFont(FONT_BOLD, PdfEncodings.CP1250);
PdfFont extraBoldFont = PdfFontFactory.createFont(FONT_EXTRA_BOLD, PdfEncodings.CP1250);
PdfFont semiBoldFont = PdfFontFactory.createFont(FONT_SEMI_BOLD, PdfEncodings.CP1250);
看起来像这样:
但是上面的文本应说“ podsumowaniejadłospisu”。
我尝试了不同的编码-UTF8,Unicode-H,Unicode-big,到目前为止最好的是Winansi(CP1252),但它也没有显示波兰字符,其他一些字符也缺少:
“ adospisu” - 应该是“jadłospisu”
“ niadanie” - 应该是“Śniadanie”
“ dzie” - 应该是“dzień”,
如果您知道如何解决这个问题,请告诉我。
I am using the newest Itext7 version of the library for generating PDF's. I've stumbled upon this problem with fonts, basically some of the characters are missing depending on which encoding I'd choose. But there seems to be no encoding supporting Polish characters.
Here is the code I use to create the fonts:
public static final String FONT_BOLD = "src/main/resources/fonts/NunitoSans-Bold.ttf";
public static final String FONT_EXTRA_BOLD = "src/main/resources/fonts/NunitoSans-ExtraBold.ttf";
public static final String FONT_SEMI_BOLD = "src/main/resources/fonts/NunitoSans-SemiBold.ttf";
PdfFont boldFont = PdfFontFactory.createFont(FONT_BOLD, PdfEncodings.CP1250);
PdfFont extraBoldFont = PdfFontFactory.createFont(FONT_EXTRA_BOLD, PdfEncodings.CP1250);
PdfFont semiBoldFont = PdfFontFactory.createFont(FONT_SEMI_BOLD, PdfEncodings.CP1250);
And it looks like this:
But the above text should say "PODSUMOWANIE JADŁOSPISU".
I tried different encodings - UTF8, Unicode-H, Unicode-BIG, the best one is WINANSI (Cp1252) so far, but it also doesn't show Polish characters and some other characters are missing too:
"adospisu" - should be "Jadłospisu"
"niadanie" - should be "Śniadanie"
"Dzie" - should be "Dzień"
Please if you have any idea how to fix this let me know.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论