我正在尝试使用iText将阿拉伯语文本写入PDF 我已经实现了阿拉伯语的例子,它在垂直纸上工作而不是景观
首先它没有显示任何字母,然后我切换了数字,文字像一列一样出现在彼此的顶部。
这些是setSimpleColumn(llx,lly,urx,ury)
的参数,但它是哪个以及它是如何工作的?
代码
public static final String FONT = "C:/Users/Hanoofi/Documents/projects/NotoNaskhArabic-Regular.ttf";
public static final String DEST = "C:/Users/Hanoofi/Documents/NetBeansProjects/quranGrades";
public static final String Sentence1 = "\u0627\u0644\u062d\u0645\u062f \u0644\u0644\u0647 \u0627\u0644\u0630\u064a \u0623\u0639\u0632 \u0645\u0646 \u062a\u0645\u0633\u0643 \u0628\u0643\u062a\u0627\u0628\u0647 \u0648\u0627\u0644\u0635\u0644\u0627\u0629 \u0648\u0627\u0644\u0633\u0644\u0627\u0645 \u0639\u0644\u0649 \u0631\u0633\u0648\u0644 \u0627\u0644\u0644\u0647 \u0627\u0644\u0642\u0627\u0626\u0644\u003a \u0028\u062e\u064a\u0631\u0643\u0645 \u0645\u0646 \u062a\u0639\u0644\u0645 \u0627\u0644\u0642\u0631\u0622\u0646 \u0648 \u0639\u0644\u0645\u0647\u0029 \u0648\u0628\u0639\u062f\u003a \u062a\u0634\u0647\u062f \u0625\u062f\u0627\u0631\u0629 \u0645\u062f\u0631\u0633\u0629 ";
public static final String Sentence2 = "\u0634\u0647\u0627\u062f\u0629 \u062a\u0642\u062f\u064a\u0631";
public static final String Sentence3 = "\u0634\u0647\u0627\u062f\u0629 \u062a\u0642\u062f\u064a\u0631";
public static final String Sentence4 = "\u0634\u0647\u0627\u062f\u0629 \u062a\u0642\u062f\u064a\u0631";
public static final String Sentence5 = "\u0634\u0647\u0627\u062f\u0629 \u062a\u0642\u062f\u064a\u0631";
public static final String Sentence6 = "\u0634\u0647\u0627\u062f\u0629 \u062a\u0642\u062f\u064a\u0631";
public void ArabicExample() throws FileNotFoundException, DocumentException {
Document document = new Document(PageSize.A4.rotate());
PdfWriter writer = PdfWriter.getInstance(document,
new FileOutputStream("Ara.pdf"));
document.open();
Font f = FontFactory.getFont(FONT,BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
Phrase p = new Phrase(new Chunk(Sentence1,f)) ;
ColumnText canvas = new ColumnText(writer.getDirectContent());
// canvas.setSimpleColumn(36, 750, 559, 780);
canvas.setSimpleColumn(750,36,780,559);
canvas.setRunDirection(PdfWriter.RUN_DIRECTION_LTR);
canvas.addElement(p);
canvas.go();
document.close();
}