gpt4 book ai didi

java - 我的 PDF 中缺少一些阿拉伯字母

转载 作者:行者123 更新时间:2023-11-30 06:15:42 25 4
gpt4 key购买 nike

我有以下测试代码

Font arabic = FontFactory.getFont("C:\\Windows\\Fonts\\simpo.ttf",BaseFont.IDENTITY_H,16);

try {
Document d=new Document();
PdfWriter writer = PdfWriter.getInstance(d, new FileOutputStream("C:\\Users\\Sana'a\\Downloads\\test.pdf"));
d.open();
PdfPTable table = new PdfPTable(1);
table.setRunDirection(PdfWriter.RUN_DIRECTION_RTL);
PdfPCell cell= new PdfPCell();
cell.setBorder(Rectangle.NO_BORDER);
Paragraph p= new Paragraph(jTextField1.getText(),arabic);
Paragraph p2= new Paragraph("سناء علاء حسين",arabic);
p.setAlignment(PdfPCell.ALIGN_LEFT);
p2.setAlignment(PdfPCell.ALIGN_LEFT);
cell.addElement(p);
cell.addElement(p2);
table.addCell(cell);
d.add(table);
d.close();
}

catch (Exception e) {
System.out.println(e.getMessage());
}

将一些文本打印到 PDF 文件,但 PDF 显示一些缺失的字母。例如:当我在 jtext 中写入 ( 巴巴巴 巴巴巴 ) 时,PDF 显示

بياء عب الله

并且 (Sanna? ? ? ? ? ) 变为

سناء علاء حسي

请提供任何解决方案。

最佳答案

尝试使用涵盖全部阿拉伯字符的字体,例如 Noto Naskh

关于java - 我的 PDF 中缺少一些阿拉伯字母,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49254031/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com