首页>代码>使用jfreechart和itext实现导出报表和表格到pdf文档>/PdDFExportDemo/src/com/ptengine/web/datacenter/csv/ReportFontFactory.java
package com.ptengine.web.datacenter.csv;
import java.io.IOException;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.Font;
import com.itextpdf.text.pdf.BaseFont;
public class ReportFontFactory {
public enum Font_Type{
TITLE,HEADER,CONTENT;
}
private ReportFontFactory(){}
/**
* Function 创建PDF报表字体
* CreateTime 2010年7月8日
* @author li
* @param fontType 字体类型(enum)
* @return Font 字体
* @throws DocumentException
* @throws IOException
*/
public static Font getFontChinese(Font_Type fontType) throws DocumentException, IOException{
BaseFont bfChinese = BaseFont.createFont("c:\\windows\\fonts\\simsun.ttc,1", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
com.itextpdf.text.Font fontChinese=null;
switch (fontType){
case TITLE:
fontChinese= new com.itextpdf.text.Font(bfChinese,12, com.itextpdf.text.Font.NORMAL);
break;
case HEADER:
fontChinese = new com.itextpdf.text.Font(bfChinese,10, com.itextpdf.text.Font.NORMAL);
break;
case CONTENT:
fontChinese = new com.itextpdf.text.Font(bfChinese,8, com.itextpdf.text.Font.NORMAL);
break;
default:
fontChinese = new com.itextpdf.text.Font(bfChinese,8, com.itextpdf.text.Font.NORMAL);
break;
}
return fontChinese;
}
}

最近下载
最近浏览
