2
我正在使用i-text从我的android应用程序中生成pdf
。但它对英文字体运行良好。当我尝试为我的语言环境生成pdf
时,我遇到了一些问题。一些博客得到一些技巧后,我已经得到的方式实现波纹管提到:使用itext为Bangla文本在Android中的一代
String fontName = "Nikosh.ttf";
InputStream is = context.getAssets().open(fontName);
int size = is.available();
byte[] buffer = new byte[size];
int a = is.read(buffer);
BaseFont customFont = BaseFont.createFont(fontName, BaseFont.IDENTITY_H, BaseFont.EMBEDDED, true, buffer, buffer);
Font banglaFont = new Font(customFont, 12);
现在输出看起来是这样的:
这是用孟加拉语字体
为孟加拉文本输出但是输出文本已损坏。而原来一个看起来像这样的:
原文为孟加拉
任何关于如何解决这类问题对于Android的unicode的帮助将得到高度赞赏。 N.B.我正在使用i-text 5.5.x
您正在使用iText 5或更早版本。由于iText 5不支持Bangla文本,因此输出被破坏是正常的。如果你想支持印度语言,你需要升级到iText 7并使用[pdfCalligraph add-on](https://itextpdf.com/itext7/pdfcalligraph)。阅读[pdfCalligraph白皮书](https://developers.itextpdf.com/sites/default/files/attachments/Whitepaper_pdfCalligraph_2017.pdf)了解更多信息。 iText 7与iText 5具有相同的许可证,但pdfCalligraph一直保持关闭源以避免滥用。 –