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
}
}
红色的都是编译不通过的 ??????????????
这是什么原因啊
解决方案 »
- 利用jsp生成一个随机数的问题,急救~~~
- 急问Window.open()窗口的中文乱码问题
- 救命啊!~ 导入HR项目时候 报的错 高手指点 我搞了2天没搞定
- JSP做的页面,图片在IE浏览时无法显示
- SSH整合时遇到的问题
- java实现htm文件转换为Excel文件
- 急,在线等,立即结分
- servlet如何向jsp传递参数?
- 怎样判断timevalue是为time类型的数据?
- 关于Spring和hibernate整合之后,连接SQLSERVER,对于一个测试类进行Junit,然后报的错误折腾的体无完肤..求助
- ie设置class的时候会引起页面闪烁,有啥办法可以解决吗?
- spring applicationContext.xml模块?
RtfFont font = new RtfFont("华文行楷", 36, Font.BOLD, Color.BLACK);
document.add(new Paragraph(text, font)); 怎么编译不通过我导了包的 高手们帮我看看吧