From a1104e8556aec660887d016076c620700c6bf14f Mon Sep 17 00:00:00 2001 From: "Hugh.C" Date: Thu, 24 Oct 2019 10:58:39 +0800 Subject: [PATCH 1/2] =?UTF-8?q?REPORT-23201=20=E3=80=90=E4=B8=93=E9=A2=98?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E3=80=91div=E4=BD=BF=E7=94=A8text-index?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=EF=BC=8C=E4=BD=BF=E7=94=A8em=E5=81=9A?= =?UTF-8?q?=E5=8D=95=E4=BD=8D=E5=AF=BC=E5=87=BA=E6=97=A0=E6=95=88=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/third/v2/lowagie/text/html/Markup.java | 4 +- .../html/simpleparser/FactoryProperties.java | 39 ++++++++++++------- 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/fine-itext/src/com/fr/third/v2/lowagie/text/html/Markup.java b/fine-itext/src/com/fr/third/v2/lowagie/text/html/Markup.java index 763bbde5a..6a9cc97ff 100644 --- a/fine-itext/src/com/fr/third/v2/lowagie/text/html/Markup.java +++ b/fine-itext/src/com/fr/third/v2/lowagie/text/html/Markup.java @@ -209,6 +209,8 @@ public class Markup { /** the CSS tag for the visibility of objects */ public static final String CSS_KEY_VISIBILITY = "visibility"; + public static final String CSS_KEY_TEXTINDENT = "text-indent"; + // CSS values /** @@ -341,7 +343,7 @@ public class Markup { /** * New method contributed by: Lubos Strapko - * + * * @since 2.1.3 */ public static float parseLength(String string, float actualFontSize) { diff --git a/fine-itext/src/com/fr/third/v2/lowagie/text/html/simpleparser/FactoryProperties.java b/fine-itext/src/com/fr/third/v2/lowagie/text/html/simpleparser/FactoryProperties.java index 418bb954f..cf53266c4 100644 --- a/fine-itext/src/com/fr/third/v2/lowagie/text/html/simpleparser/FactoryProperties.java +++ b/fine-itext/src/com/fr/third/v2/lowagie/text/html/simpleparser/FactoryProperties.java @@ -374,14 +374,7 @@ public class FactoryProperties { if (key.equals(Markup.CSS_KEY_FONTFAMILY)) { h.put(ElementTags.FACE, prop.getProperty(key)); } else if (key.equals(Markup.CSS_KEY_FONTSIZE)) { - float actualFontSize = Markup.parseLength(cprops - .getProperty(ElementTags.SIZE), - Markup.DEFAULT_FONT_SIZE); - if (actualFontSize <= 0f) - actualFontSize = Markup.DEFAULT_FONT_SIZE; - h.put(ElementTags.SIZE, Float.toString(Markup.parseLength(prop - .getProperty(key), actualFontSize)) - + "pt"); + dealWithFontSizeOrTextIndent(h, cprops, prop, key); } else if (key.equals(Markup.CSS_KEY_FONTSTYLE)) { String ss = prop.getProperty(key).trim().toLowerCase(); if (ss.equals("italic") || ss.equals("oblique")) @@ -429,14 +422,34 @@ public class FactoryProperties { } else if (key.equals(Markup.CSS_KEY_BGCOLOR)) { String ss = prop.getProperty(key).trim().toLowerCase(); h.put("background", ss); - } - else{ - String ss = prop.getProperty(key).trim(); - h.put(key, ss); - } + } else if (key.equals(Markup.CSS_KEY_TEXTINDENT)) { + dealWithFontSizeOrTextIndent(h, cprops, prop, key); + } else { + String ss = prop.getProperty(key).trim(); + h.put(key, ss); + } } } + /** + * 处理下字号和文本缩进 + * + * @param h 当前标签内的属性Map + * @param cprops 一个list , 从左到右保存着父到子标签中的属性 + * @param prop 当前标签内的style 属性Map + * @param key 当前 prop 中的 k + */ + private static void dealWithFontSizeOrTextIndent(HashMap h, ChainedProperties cprops, Properties prop, String key) { + float actualFontSize = Markup.parseLength(cprops + .getProperty(ElementTags.SIZE), + Markup.DEFAULT_FONT_SIZE); + if (actualFontSize <= 0f) + actualFontSize = Markup.DEFAULT_FONT_SIZE; + h.put(key.equals(Markup.CSS_KEY_FONTSIZE) ? ElementTags.SIZE : key, Float.toString(Markup.parseLength(prop + .getProperty(key), actualFontSize)) + + "pt"); + } + public FontFactoryImp getFontImp() { return fontImp; } From 2781b67b84923bef831795fa0a759441c31d0463 Mon Sep 17 00:00:00 2001 From: "Hugh.C" Date: Thu, 24 Oct 2019 17:47:22 +0800 Subject: [PATCH 2/2] =?UTF-8?q?REPORT-22637=20PDF=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E6=97=B6=E5=88=97=E5=AE=BD=E6=9C=89=E9=97=AE=E9=A2=98=EF=BC=88?= =?UTF-8?q?=E4=BB=A5=E7=AC=AC=E4=B8=80=E8=A1=8C=E4=B8=BA=E5=87=86=EF=BC=8C?= =?UTF-8?q?=E8=80=8C=E4=B8=8D=E6=98=AF=E6=AF=8F=E5=88=97=E7=9A=84=E6=9C=80?= =?UTF-8?q?=E5=A4=A7=E5=80=BC=E4=B8=BA=E5=87=86=EF=BC=89=E3=80=81=E8=A7=A3?= =?UTF-8?q?=E5=86=B3=E9=AA=8C=E6=94=B6=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/third/v2/lowagie/text/html/simpleparser/IncTable.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fine-itext/src/com/fr/third/v2/lowagie/text/html/simpleparser/IncTable.java b/fine-itext/src/com/fr/third/v2/lowagie/text/html/simpleparser/IncTable.java index 52164fdc2..5da1eb4ca 100644 --- a/fine-itext/src/com/fr/third/v2/lowagie/text/html/simpleparser/IncTable.java +++ b/fine-itext/src/com/fr/third/v2/lowagie/text/html/simpleparser/IncTable.java @@ -171,10 +171,11 @@ public class IncTable { ArrayList cols = (ArrayList) rows.get(rowIndex); for (int colIndex = 0; colIndex < cols.size(); colIndex++) { PdfPCell pCell = ((PdfPCell) cols.get(colIndex)); + int cellCols = pCell.getColspan(); float avgWidth = pCell.getStyleWidth() / cellCols; for (int i = 0; i < cellCols && colIndex + i < colCount; i++) { - if (relativeColWidths.get(i) < avgWidth) { + if (relativeColWidths.get(colIndex + i) < avgWidth) { relativeColWidths.set(colIndex + i, avgWidth); } }