diff --git a/.gitignore b/.gitignore index 7eefa4456..dfe7ac089 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ *.iml .idea/ -.gradle/ \ No newline at end of file +.gradle/ diff --git a/build.third_step0.gradle b/build.third_step0.gradle index 16e8a5a6e..ac54f3a6e 100644 --- a/build.third_step0.gradle +++ b/build.third_step0.gradle @@ -53,8 +53,7 @@ configurations { } dependencies { - // @branch - 分支信息 - thirdjar "com.fr.third:fine-third:10.0-FEATURE-SNAPSHOT" + thirdjar "com.fr.third:fine-third-base:10.0-BASE-SNAPSHOT" sigar "com.fr.third:sigar:1.6.0" testCompile 'junit:junit:4.12' } 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 2ea2a07f1..c971540a1 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 @@ -72,20 +72,20 @@ public class IncTable { public IncTable(HashMap props) { this.props.putAll(props); } - + public void addCol(PdfPCell cell) { if (cols == null) cols = new ArrayList(); cols.add(cell); } - + public void addCols(ArrayList ncols) { if (cols == null) cols = new ArrayList(ncols); else cols.addAll(ncols); } - + public void endRow(float rowHeight) { rowHeights.add(rowHeight); if (cols != null) { @@ -94,27 +94,35 @@ public class IncTable { cols = null; } } - + public ArrayList getRows() { return rows; } - + public PdfPTable buildTable() { if (rows.isEmpty()) return new PdfPTable(1); int ncol = 0; ArrayList c0 = (ArrayList)rows.get(0); ArrayList colWidths = new ArrayList(); + float widthSum = 0; for (int k = 0; k < c0.size(); ++k) { PdfPCell pCell = ((PdfPCell)c0.get(k)); int cellCols = pCell.getColspan(); ncol += cellCols; + //不取 0 ,后面可能需要求比值 + float styleWidth = pCell.getStyleWidth(); if(cellCols > 1){ + float avgWidth = styleWidth / cellCols; + float width = 0 == avgWidth ? 1 : avgWidth; + widthSum = width * cellCols; for(int a = 0; a < cellCols ; a++){ - colWidths.add(pCell.getStyleWidth()/cellCols); + colWidths.add(width); } }else { - colWidths.add(pCell.getStyleWidth()); + float width = 0 == styleWidth ? 1 : styleWidth; + widthSum += width; + colWidths.add(width); } } @@ -132,8 +140,8 @@ public class IncTable { //解析单元格宽度 float totalWidth = CSSUtils.parseFloat(width); float[] floats = new float[colWidths.size()]; - for (int a = 0; a < colWidths.size(); a++){ - floats[a] = colWidths.get(a); + for (int a = 0; a < colWidths.size(); a++) { + floats[a] = totalWidth * colWidths.get(a) / widthSum; } //解析px数值 table.setTotalWidth(totalWidth); @@ -161,11 +169,11 @@ public class IncTable { return table; } - public void processRowHeight(PdfPTable table){ - Float height = CSSUtils.parseFloat((String)props.get("height")); + public void processRowHeight(PdfPTable table) { + Float height = CSSUtils.parseFloat((String) props.get("height")); Float eachHeight = height / table.getRows().size(); //调整行高 - for(int a = 0; a < rowHeights.size(); a++){ + for (int a = 0; a < rowHeights.size(); a++) { table.getRow(a).setStyleHeight(Math.max(eachHeight, rowHeights.get(a))); } } diff --git a/fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfChunk.java b/fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfChunk.java index 09dce3311..f5b67439a 100644 --- a/fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfChunk.java +++ b/fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfChunk.java @@ -788,10 +788,11 @@ public class PdfChunk { public String toHtmlString() { StringBuffer htmlString = new StringBuffer(); - if(this.isImage()){ - htmlString.append(""); + if (this.isImage()) { + htmlString.append(""); return htmlString.toString(); - } //todo 需要添加其他样式属性 htmlString.append("