Browse Source

Pull request #473: REPORT-33819? a标签设置text-decoration,前台没有下划线但是导出有

Merge in CORE/base-third from ~HUGH.C/base-third:release/10.0 to release/10.0

* commit '9af2eff20f661c86a2db9ccf417b1b5789dbfc2a':
  REPORT-33819? a标签设置text-decoration,前台没有下划线但是导出有
release/10.0
Hugh.C 5 years ago
parent
commit
2834df65cd
  1. 26
      fine-itext/src/main/java/com/fr/third/v2/lowagie/text/html/simpleparser/FactoryProperties.java
  2. 4
      fine-itext/src/main/java/com/fr/third/v2/lowagie/text/html/simpleparser/HTMLWorker.java

26
fine-itext/src/main/java/com/fr/third/v2/lowagie/text/html/simpleparser/FactoryProperties.java

@ -86,7 +86,6 @@ public class FactoryProperties {
public Chunk createChunk(String text, ChainedProperties props) { public Chunk createChunk(String text, ChainedProperties props) {
Font font = getFont(props); Font font = getFont(props);
dealHyperlinkfont( font, props);
float size = font.getSize(); float size = font.getSize();
size /= 3; size /= 3;
Chunk ck = new Chunk(text, font); Chunk ck = new Chunk(text, font);
@ -107,31 +106,6 @@ public class FactoryProperties {
return ck; return ck;
} }
/**
* 处理超链接的字体颜色和下划线
*
* @param font
* @param props
*/
private static void dealHyperlinkfont(Font font, ChainedProperties props) {
String tagName = props.getLastTag();
if (null == tagName || tagName.equals("") || !tagName.equals(HtmlTags.ANCHOR)) {
return;
}
int style = font.getStyle();
if (props.hasKvInLastChain(CSS.Property.TEXT_DECORATION, CSS.Value.NONE)) {
//含有 text-decoration 属性,且值为 none时,将下划线属性去掉
font.setStyle(style & (~Font.UNDERLINE));
} else {
//默认是有需要有下划线的
font.setStyle(style | Font.UNDERLINE);
}
//没有指定颜色 or 是继承的颜色(<a>标签不需要继承颜色,只使用自身的颜色)时,使用默认的蓝色(超链接)
if (null == font.getColor() || (!font.getColor().equals(Color.BLUE) && null == props.getLastChainProperty(CSS.Property.COLOR))) {
font.setColor(Color.BLUE);
}
}
private static void setParagraphLeading(Paragraph p, String leading) { private static void setParagraphLeading(Paragraph p, String leading) {
if (leading == null) { if (leading == null) {
p.setLeading(0, 1.5f); p.setLeading(0, 1.5f);

4
fine-itext/src/main/java/com/fr/third/v2/lowagie/text/html/simpleparser/HTMLWorker.java

@ -218,6 +218,10 @@ public class HTMLWorker implements SimpleXMLDocHandler, DocListener {
if (tag.equals("th")) { if (tag.equals("th")) {
h.put("b", null); h.put("b", null);
} }
if (tag.equals(HtmlTags.ANCHOR)) {
h.put("u", null);
h.put("color", "blue");
}
String follow = (String) FactoryProperties.followTags.get(tag); String follow = (String) FactoryProperties.followTags.get(tag);
if (follow != null) { if (follow != null) {
HashMap prop = new HashMap(); HashMap prop = new HashMap();

Loading…
Cancel
Save