使用itext在Android中使用Bangla文本进行PDF生成 [英] Pdf generation using itext for Bangla text in android
问题描述
我正在使用i-text从我的android应用程序生成pdf
.但是对于英文字体来说,它工作得很好.当我尝试为我的语言环境Bangla生成pdf
时,遇到了一些问题.从一些博客获得一些提示后,我已经按照下面提到的方式获得了实现:
I am using i-text for generating pdf
from my android application. But it worked fine for English fonts. When I was trying to generate pdf
for my locale, Bangla, I got some problems. After getting some tips from some blog I have got the implementation in the way mentioned bellow:
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);
现在输出看起来像这样:
Now the output looks like this:
这是使用孟加拉字体的孟加拉文本输出
This is the output for Bangla text using a bangla font
但是输出文本已损坏.原始的看起来像这样:
But the output text is broken. Whereas the original one looks like this one:
孟加拉语的原始文本
任何有关如何解决android中unicode这类问题的帮助将不胜感激. N.B.我正在使用i-text 5.5.x
Any help regarding how to solve this type of problem for unicode in android would be highly appreciated. N.B. I am using i-text 5.5.x
推荐答案
使用此库: 实施'com.uttampanchasara.pdfgenerator:pdfgenerator:1.3'
Use this library : implementation 'com.uttampanchasara.pdfgenerator:pdfgenerator:1.3'
minsdk:
高于21
minsdk :
above 21
这篇关于使用itext在Android中使用Bangla文本进行PDF生成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!