import com.itextpdf.text.BaseColor;
import com.itextpdf.text.Font;
import com.itextpdf.text.pdf.BaseFont;
import com.itextpdf.tool.xml.XMLWorkerFontProvider;
import org.springframework.core.io.ClassPathResource;
/***
* 工具类
*/
public class DefineFontProvider extends XMLWorkerFontProvider {
@Override
public Font getFont(final String fontname, final String encoding, final boolean embedded, final float size,
final int style, final BaseColor color) {
BaseFont bf = null;
try {
//msyh.ttf 是微软雅黑字体,
ClassPathResource resource = new ClassPathResource("msyh.ttf");
bf = BaseFont.createFont(resource.getPath(), BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
} catch (Exception e) {
e.printStackTrace();
}
Font font = new Font(bf, size, style, color);
font.setColor(color);
return font;
}
}
最近下载更多
最近浏览更多
datang123
6月3日
暂无贡献等级
Jacko01 LV8
3月20日
liuyinwan
1月14日
暂无贡献等级
源蝈蝈
2024年12月28日
暂无贡献等级
3334004690 LV11
2024年6月24日
19950118
2024年4月19日
暂无贡献等级
zhos0212 LV19
2024年3月29日
467277 LV13
2024年3月26日
studengaaa
2024年3月17日
暂无贡献等级
a1325922140 LV1
2024年2月19日

