From 9af2eff20f661c86a2db9ccf417b1b5789dbfc2a Mon Sep 17 00:00:00 2001 From: "Hugh.C" Date: Wed, 17 Jun 2020 15:54:18 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-33819=3F=20a=E6=A0=87=E7=AD=BE=E8=AE=BE?= =?UTF-8?q?=E7=BD=AEtext-decoration=EF=BC=8C=E5=89=8D=E5=8F=B0=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E4=B8=8B=E5=88=92=E7=BA=BF=E4=BD=86=E6=98=AF=E5=AF=BC?= =?UTF-8?q?=E5=87=BA=E6=9C=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../html/simpleparser/FactoryProperties.java | 26 ------------------- .../text/html/simpleparser/HTMLWorker.java | 4 +++ 2 files changed, 4 insertions(+), 26 deletions(-) diff --git a/fine-itext/src/main/java/com/fr/third/v2/lowagie/text/html/simpleparser/FactoryProperties.java b/fine-itext/src/main/java/com/fr/third/v2/lowagie/text/html/simpleparser/FactoryProperties.java index 39b06af14..5e68ef341 100644 --- a/fine-itext/src/main/java/com/fr/third/v2/lowagie/text/html/simpleparser/FactoryProperties.java +++ b/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) { Font font = getFont(props); - dealHyperlinkfont( font, props); float size = font.getSize(); size /= 3; Chunk ck = new Chunk(text, font); @@ -107,31 +106,6 @@ public class FactoryProperties { 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 是继承的颜色(标签不需要继承颜色,只使用自身的颜色)时,使用默认的蓝色(超链接) - 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) { if (leading == null) { p.setLeading(0, 1.5f); diff --git a/fine-itext/src/main/java/com/fr/third/v2/lowagie/text/html/simpleparser/HTMLWorker.java b/fine-itext/src/main/java/com/fr/third/v2/lowagie/text/html/simpleparser/HTMLWorker.java index a1a9da464..9bce7242f 100644 --- a/fine-itext/src/main/java/com/fr/third/v2/lowagie/text/html/simpleparser/HTMLWorker.java +++ b/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")) { h.put("b", null); } + if (tag.equals(HtmlTags.ANCHOR)) { + h.put("u", null); + h.put("color", "blue"); + } String follow = (String) FactoryProperties.followTags.get(tag); if (follow != null) { HashMap prop = new HashMap();