Browse Source

Merge pull request #278 in CORE/base-third from release/10.0 to final/10.0

* commit 'd6f6537c35d7267e41ebbb109640bc778b112530':
  REPORT-20433 html片段导出table表格被压缩
final/10.0.3
Kara 5 years ago
parent
commit
b12840df36
  1. 14
      fine-itext/src/com/fr/third/v2/lowagie/text/html/simpleparser/IncTable.java

14
fine-itext/src/com/fr/third/v2/lowagie/text/html/simpleparser/IncTable.java

@ -105,16 +105,24 @@ public class IncTable {
int ncol = 0;
ArrayList c0 = (ArrayList)rows.get(0);
ArrayList<Float> colWidths = new ArrayList<Float>();
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);
}
}
@ -133,7 +141,7 @@ 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);
floats[a] = totalWidth * colWidths.get(a) / widthSum;
}
//解析px数值
table.setTotalWidth(totalWidth);

Loading…
Cancel
Save