Browse Source

REPORT-11256 html标签之table元素的导出pdf和图片显示不全

research/11.0
kerry 6 years ago
parent
commit
d653a6d642
  1. 13
      fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfPTable.java
  2. 2
      fine-itext/src/com/fr/third/v2/lowagie/text/pdf/TableProperties.java

13
fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfPTable.java

@ -350,12 +350,14 @@ public class PdfPTable implements LargeElement {
return;
float total = 0;
int numCols = getNumberOfColumns();
float cellSpacings = tableProperties.isCollapse() ? 0 : tableProperties.getCellspacing();
float borderWidth = tableProperties.getBorderStyle().getBorderWidth();
BorderStyle borderStyle = tableProperties.getBorderStyle();
float borderWidth = tableProperties.isCollapse() ? borderStyle.getBorderWidth() / 2 : borderStyle.getBorderWidth();
float cellspacing = tableProperties.getCellspacing();
float cellpadding = tableProperties.getCellpadding();
for (int k = 0; k < numCols; ++k)
total += relativeWidths[k];
for (int k = 0; k < numCols; ++k)
absoluteWidths[k] = (totalWidth-(cellSpacings+ borderWidth)*(numCols+1)) * relativeWidths[k] / total;
absoluteWidths[k] = (totalWidth - cellspacing * (numCols + 1) - numCols * 2 * (borderWidth + cellpadding) - 2 * borderWidth) * relativeWidths[k] / total;
}
/**
@ -434,12 +436,13 @@ public class PdfPTable implements LargeElement {
return 0;
totalHeight = 0;
BorderStyle borderStyle = tableProperties.getBorderStyle();
float borderWidth = borderStyle.getBorderWidth();
float borderWidth = tableProperties.isCollapse() ? borderStyle.getBorderWidth() / 2 : borderStyle.getBorderWidth();
float cellspacing = tableProperties.getCellspacing();
float cellpadding = tableProperties.getCellpadding();
for (int k = 0; k < rows.size(); ++k) {
totalHeight += getRowHeight(k, firsttime);
}
totalHeight += (borderWidth + cellspacing) * (rows.size() + 1);
totalHeight += (rows.size() + 1) * 2 * borderWidth + cellpadding * 2 * rows.size() + (rows.size() + 1) * cellspacing;
return totalHeight;
}

2
fine-itext/src/com/fr/third/v2/lowagie/text/pdf/TableProperties.java

@ -19,7 +19,7 @@ public class TableProperties {
}
public float getCellspacing() {
return cellspacing;
return isCollapse() ? 0 : cellspacing;
}
public void setCellspacing(float cellspacing) {

Loading…
Cancel
Save