package com.itext.test;import java.awt.Color;
import java.awt.Font;
import java.io.FileOutputStream;import com.itextpdf.text.Document;
import com.itextpdf.text.Paragraph;
import com.lowagie.text.rtf.RtfWriter2;
import com.lowagie.text.rtf.style.RtfFont;public class WriteWord {
// rtf
public static void main(String[] args) {
// step 1: 定义     
Document document = new Document();               
try {       
    // step 2:       
    // 建立一个rtf文档       
    RtfWriter2.getInstance(document, new FileOutputStream("F://do.doc"));        // step 3: we open the document       
    document.open();       
    //设置字体  字体名称是中文的,在中间的中文字符前后加空格,       
    //这种写法是实验多次后的结果,直接写在word中体现为 "华?行?楷",这种写法感觉很怪异。       
    //在写字板中打开和word中打开不一样,见图       
    RtfFont font = new RtfFont("华文行楷", 36, Font.BOLD, Color.BLACK);                   
    String text = "这是中文字体测试!this is a test";       
    document.add(new Paragraph(text, font));                    
    System.out.println(font.getFamilyname());       
}       
catch(DocumentException de) {       
    System.err.println(de.getMessage());       
}       
catch(IOException ioe) {       
    System.err.println(ioe.getMessage());       
}finally{       
           
    document.close();       
}       
// step 5: we close the document    
}
}
红色的都是编译不通过的 ??????????????
这是什么原因啊