请教iText生成word问题
使用iText生成word,struts2框架,使用iText-2.1.7.jar和iText-rtf-2.1.7.jarimport java.io.*;
import java.awt.Color;
import com.lowagie.text.*;
import com.lowagie.text.rtf.RtfWriter2;
import com.lowagie.text.rtf.headerfooter.*;
import com.lowagie.text.rtf.field.*;
import com.lowagie.text.rtf.table.*;
import com.lowagie.text.rtf.style.RtfFont;
public class RtfClass {
public static String rtf()
{
com.lowagie.text.Document document = new com.lowagie.text.Document();
try {System.out.println("try1");
RtfWriter2.getInstance(document, new
FileOutputStream("C:\rhDocs\testRTFdocument.rtf"));
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
document.open();
try {System.out.println("try2");
document.add(new Paragraph("Hello World!"));
} catch (DocumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
document.close();
return "ok";
}
}
错误如下:
java.lang.NoSuchMethodError: com.lowagie.text.Rectangle.width()F
at com.lowagie.text.rtf.document.RtfPageSetting.rectEquals(Unknown Source)
at com.lowagie.text.rtf.document.RtfPageSetting.guessFormat(Unknown Source)
at com.lowagie.text.rtf.document.RtfPageSetting.setPageSize(Unknown Source)
at com.lowagie.text.rtf.RtfWriter2.setPageSize(Unknown Source)
at com.lowagie.text.Document.open(Unknown Source)
at utilities.RtfClass.rtf(RtfClass.java:23)
--------------------编程问答-------------------- RtfClass.java:23是什么?
是不是itext版本的问题。。。 --------------------编程问答-------------------- 在main函数里执行没问题,放到项目里就出问题了,itext版本应该没问题
补充:Java , Java EE