From 1b7727fb69802daa761a73743c156defe3572be9 Mon Sep 17 00:00:00 2001 From: "Hugh.C" Date: Tue, 17 Mar 2020 14:12:48 +0800 Subject: [PATCH 1/3] =?UTF-8?q?REPORT-28245=20=E6=A0=87=E7=AD=BE?= =?UTF-8?q?=E4=B8=8D=E5=B1=9E=E4=BA=8E=E5=9D=97=E7=BA=A7=E5=85=83=E7=B4=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/third/v2/lowagie/text/html/simpleparser/HTMLWorker.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fine-itext/src/com/fr/third/v2/lowagie/text/html/simpleparser/HTMLWorker.java b/fine-itext/src/com/fr/third/v2/lowagie/text/html/simpleparser/HTMLWorker.java index 4ccf4aaff..e8f3f1406 100644 --- a/fine-itext/src/com/fr/third/v2/lowagie/text/html/simpleparser/HTMLWorker.java +++ b/fine-itext/src/com/fr/third/v2/lowagie/text/html/simpleparser/HTMLWorker.java @@ -526,7 +526,7 @@ public class HTMLWorker implements SimpleXMLDocHandler, DocListener { cprops.removeChain(follow); return; } - if (tag.equals("font") || tag.equals("span")) { + if (tag.equals("font") || tag.equals("span") || tag.equals("img")) { cprops.removeChain(tag); return; } From d0dba87ddbbe08164933704ea803021f0f04d29e Mon Sep 17 00:00:00 2001 From: "Hugh.C" Date: Tue, 17 Mar 2020 15:43:18 +0800 Subject: [PATCH 2/3] =?UTF-8?q?REPORT-28245=20=E5=9B=BE=E7=89=87=E4=B8=8E?= =?UTF-8?q?=E6=96=87=E6=9C=AC=E5=9C=A8=E5=90=8C=E4=B8=80=E8=A1=8C=E6=97=B6?= =?UTF-8?q?=E7=BB=98=E5=88=B6=E9=AB=98=E5=BA=A6=E5=92=8C=E4=BD=8D=E7=BD=AE?= =?UTF-8?q?=E4=B8=8D=E5=AF=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/third/v2/lowagie/text/pdf/PdfLine.java | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfLine.java b/fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfLine.java index db519ecc8..f4de25e69 100644 --- a/fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfLine.java +++ b/fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfLine.java @@ -77,6 +77,10 @@ public class PdfLine { /** true : 存在常规标签(非上下标) */ protected boolean existNormalTag; + protected float maxImgHeight; + + protected float maxTextHeight; + /** The left indentation of the line. */ protected float left; @@ -225,7 +229,9 @@ public class PdfLine { //添加到line上处理计算line高度 if (chunk.changeLeading && chunk.isImage()) { float f = chunk.getImage().getScaledHeight() + chunk.getImageOffsetY() + chunk.getImage().getBorderWidthTop(); - if (f > height) height = f; + if (f > height) + height = f; + maxImgHeight = Math.max(maxImgHeight, f); }else{ float textRise = chunk.getTextRise(); if (textRise != 0) { @@ -234,11 +240,17 @@ public class PdfLine { } else { maxTextDrop = -Math.min(maxTextDrop, textRise); } - } else { + //一行中只有上下标时,不需要浮动 existNormalTag = true; } - this.height = Math.max(this.height, chunk.getHeight() + (neddRiseOrDrop() ? maxTextRise + maxTextDrop : 0)); + //图片存在且高度足够大,整体高度就不考虑上下标的浮动距离了 + if (chunk.isImage()) { + maxImgHeight = Math.max(maxImgHeight, chunk.getImage().getScaledHeight()); + } else { + maxTextHeight = Math.max(maxTextHeight, chunk.getHeight() + maxTextRise + maxTextDrop); + } + this.height = Math.max(this.height, chunk.getHeight() + (neddRiseOrDrop() && !imgBigThanText() ? maxTextRise + maxTextDrop : 0)); } line.add(chunk); } @@ -255,6 +267,10 @@ public class PdfLine { return existNormalTag && (maxTextRise > 0 || maxTextDrop > 0); } + public boolean imgBigThanText() { + return maxImgHeight > maxTextHeight; + } + // methods to retrieve information /** From 48c82fc848db6b9b76adcacf31b2610515be30cd Mon Sep 17 00:00:00 2001 From: "Hugh.C" Date: Tue, 17 Mar 2020 16:12:06 +0800 Subject: [PATCH 3/3] =?UTF-8?q?REPORT-28245=20review=20=E6=94=B9=E8=BF=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfLine.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfLine.java b/fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfLine.java index f4de25e69..220ae2c8a 100644 --- a/fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfLine.java +++ b/fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfLine.java @@ -229,8 +229,9 @@ public class PdfLine { //添加到line上处理计算line高度 if (chunk.changeLeading && chunk.isImage()) { float f = chunk.getImage().getScaledHeight() + chunk.getImageOffsetY() + chunk.getImage().getBorderWidthTop(); - if (f > height) + if (f > height){ height = f; + } maxImgHeight = Math.max(maxImgHeight, f); }else{ float textRise = chunk.getTextRise();