标签:
1、解决中文显示:
加上中文字体:
private static final String WIN_FONT_SUN = "C:/Windows/Fonts/simsun.ttc"; private static final String WIN_FONT_HEI = "C:/Windows/Fonts/simhei.ttf"; private static final String LINUX_FONT_SUN = "/usr/share/fonts/my_fonts/simsun.ttc"; private static final String LINUX_FONT_HEI = "/usr/share/fonts/my_fonts/STZHONGS.TTF";
if (isWindows())
{
addFont(fontResolver, WIN_FONT_SUN);
addFont(fontResolver, WIN_FONT_HEI);
}
else
{
addFont(fontResolver, LINUX_FONT_SUN);
addFont(fontResolver, LINUX_FONT_HEI);
}
private static void addFont(ITextFontResolver fontResolver, String font) throws DocumentException, IOException
{
if (new File(font).exists())
{
fontResolver.addFont(font, BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
}
else
{
log.info(font + "===================================不存在");
}
}
2、解决,renderer.setDocument(url);
解决无法跳转导致的,无法加载xml,并且html文件中没有错误,每个标签都正常关闭,对齐。则很可能就是url,被拦截了。
一般是要放到白名单中,或者filter的白名单中
private static final String WIN_FONT_SUN = "C:/Windows/Fonts/simsun.ttc";
private static final String WIN_FONT_HEI = "C:/Windows/Fonts/simhei.ttf";
private static final String LINUX_FONT_SUN = "/usr/share/fonts/my_fonts/simsun.ttc";
private static final String LINUX_FONT_HEI = "/usr/share/fonts/my_fonts/STZHONGS.TTF";
标签:
原文地址:http://www.cnblogs.com/gmq-sh/p/5481063.html