Cyrillic Letters Not Displaying In Pdf Generated With Itext In Android
I am tring to generate a PDF in my android application. I use iText and it generates PDF but only letters in english are shown. I found example code for iText working with unicode.
Solution 1:
I used
BaseFontbfComic= BaseFont.createFont("/system/fonts/Comic.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
and it works. You should check the fonts directory on your Android device to make sure.
For Chinese characters I used
BaseFontbfSans= BaseFont.createFont("/system/fonts/DroidSansFallback.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
Make sure you provide a fallback font in the catch() block, for example:
font = new Font(Font.FontFamily.HELVETICA, 24, Font.NORMAL, BaseColor.BLACK);
Please let me know if there is a standard way to get the path of the fonts folder.
Solution 2:
It also depends on the font you use, if the font you use does not support Cyrillic letters, Cyrillic letters will not appear. For example: If you use the font google google_regular.ttf then the Cyrillic letters will not appear in the pdf file
Post a Comment for "Cyrillic Letters Not Displaying In Pdf Generated With Itext In Android"