如何使用FontFactory.register中的加载字体以PDF格式编写阿拉伯语文本

时间:2015-07-31 18:34:51

标签: java utf-8 pdf-generation itext arabic

我需要您的帮助,以PDF格式撰写阿拉伯文字。我已经从资源文件夹加载了Arial字体,但不幸的是,PDF显示为空白,并且没有打印文本。所以,请你帮忙。

我的代码如下:

FontFactory.register(System.getProperty("file.separator")+"resources"+System.getProperty("file.separator")+"fonts"+System.getProperty("file.separator")+"arial.‌​ttf", "my_bold_font");

Font myBoldFont = FontFactory.getFont("my_bold_font");


PdfPTable table = new PdfPTable(1);
PdfPCell cell =new PdfPCell(new Paragraph("\u0625\u0644\u0649 \u0645\u0646 \u064a\u0647\u0645\u0647 \u0627\u0644\u0623\u0645\u0631",
                                           myBoldFont));
table.setRunDirection(PdfWriter.RUN_DIRECTION_RTL);
table.getDefaultCell().setBorder(Rectangle.NO_BORDER);
cell.setBorder(Rectangle.NO_BORDER);
table.addCell(cell);
doc.add(table);

0 个答案:

没有答案