2
我正在使用以下代碼在iText中生成希伯來文本。iText中的我的希伯來文本是左對齊的
它很好地工作(創建一個希伯來字體,並使文本從右到左流動),但文本是左對齊的而不是右對齊。
任何人都可以幫助我使它對齊嗎?請注意,我試圖使MultiColumnText右對齊,而段落右對齊 - 但無濟於事!
感謝
static Color darkBlue = new Color(0x2F, 0x36, 0x99);
BaseFont unicode = BaseFont.createFont("c:/windows/fonts/arial.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
Font fontDarkBlueHebrew = new Font(unicode, 12, Font.NORMAL,darkBlue);
MultiColumnText mct=new MultiColumnText();
mct.addSimpleColumn(36, PageSize.A4.width()-36);
mct.setRunDirection(PdfWriter.RUN_DIRECTION_RTL);
mct.setAlignment(Element.ALIGN_RIGHT);
Paragraph section1a = new Paragraph("כותרת 1",fontDarkBlueHebrew);
section1a.setAlignment(Element.ALIGN_RIGHT);
mct.addElement(section1a);
Paragraph section1b = new Paragraph("הטקסט שלע",fontDarkBlueHebrew);
section1b.setAlignment(Element.ALIGN_RIGHT);
mct.addElement(section1b);
document.add(mct);
令人驚歎!非常感謝! – gordon613 2013-04-14 10:03:31
(爲了完整起見,Element.ALIGN_LEFT需要應用於段落而不是MultiColumnText) – gordon613 2013-04-14 10:04:22
(我是你的書的粉絲 - iText IN ACTION) – gordon613 2013-04-14 10:05:57