/**
* 使用jsoup规范化html
*
* @param html html内容
* @return 规范化后的html
*/
private static String formatHtml(String html) {
org.jsoup.nodes.Document doc = Jsoup.parse(html);
//设置导出格式保留空格
doc.outputSettings(new org.jsoup.nodes.Document.OutputSettings().prettyPrint(false));
// 去除过大的宽度
String style = doc.attr("style");
if (StringUtils.isNotEmpty(style) && style.contains("width")) {
doc.attr("style", "");
}
Elements divs = doc.select("div");
for (Element div : divs) {
String divStyle = div.attr("style");
if (StringUtils.isNotEmpty(divStyle) && divStyle.contains("width")) {
div.attr("style", "");
}
//获取文本标签
Elements span = div.select("span");
f
使用jsoup规范化html itext html转PDF 空格丢失问题解决
最新推荐文章于 2024-08-05 17:20:59 发布