如何设置" Latha"使用poi jar编写docx文件时默认使用字体

时间:2015-05-14 04:27:15

标签: java apache-poi

我需要使用apache poi创建一个docx文件,因为我需要将其字体设置为Latha。下面是我的代码,但是当我使用setfontfamily(" Latha")时它不起作用。 Latha是泰米尔语。

    XWPFDocument document = new XWPFDocument();
    FileOutputStream out = null;
    try {
        out = new FileOutputStream(new File("PageCounter.docx"));
    } catch (FileNotFoundException ex) {
        Logger.getLogger(WordDocCreation.class.getName()).log(Level.SEVERE, null, ex);
    }
    try {
        XWPFParagraph paragraph = document.createParagraph();
        XWPFRun run = paragraph.createRun();
        run.setText(replaceAll2);
        run.setFontFamily("Latha");
        run.setFontSize(10);
        document.write(out);
    } catch (IOException ex) {
        Logger.getLogger(WordDocCreation.class.getName()).log(Level.SEVERE, null, ex);
    }
    try {
        out.close();
    } catch (IOException ex) {
        Logger.getLogger(WordDocCreation.class.getName()).log(Level.SEVERE, null, ex);
    }

Systen正在编写文件,但是unicode文本显示为方框。

1 个答案:

答案 0 :(得分:1)