Browse Source

Merge pull request #108 in CORE/base-third from ~KERRY/base-third:feature/10.0 to feature/10.0

* commit 'd653a6d6427964eab575b6f89265a94359b13728':
  REPORT-11256 html标签之table元素的导出pdf和图片显示不全
  REPORT-10262 html大文本精确分页
research/11.0
neil 6 years ago
parent
commit
95321692a5
  1. 4
      fine-itext/src/com/fr/third/v2/lowagie/text/html/Markup.java
  2. 4
      fine-itext/src/com/fr/third/v2/lowagie/text/html/simpleparser/FactoryProperties.java
  3. 2
      fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfChunk.java
  4. 2
      fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfLine.java
  5. 13
      fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfPTable.java
  6. 2
      fine-itext/src/com/fr/third/v2/lowagie/text/pdf/TableProperties.java

4
fine-itext/src/com/fr/third/v2/lowagie/text/html/Markup.java

@ -449,9 +449,9 @@ public class Markup {
if (part.length == 2) {
key = stripDoubleSpacesAndTrim(part[0]).toLowerCase();
value = stripDoubleSpacesAndTrim(part[1]);
if (value.startsWith("\""))
if (value.startsWith("\"") || value.startsWith("\'") )
value = value.substring(1);
if (value.endsWith("\""))
if (value.endsWith("\"") || value.endsWith("\'"))
value = value.substring(0, value.length() - 1);
result.setProperty(key.toLowerCase(), value);
}

4
fine-itext/src/com/fr/third/v2/lowagie/text/html/simpleparser/FactoryProperties.java

@ -137,6 +137,9 @@ public class FactoryProperties {
if(props.hasPropertyInChain("div", "background")){
p.setBackground(props.getPropertyFromChain("div", "background"));
}
if(props.hasProperty("line-height")){
p.setAttribute("line-height", props.getProperty("line-height"));
}
for(String margin : HtmlConstants.MARGIN){
if(props.hasPropertyInChain("div", margin)){
String ss = props.getPropertyFromChain("div", margin);
@ -419,6 +422,7 @@ public class FactoryProperties {
return;
}
h.put("leading", v + ",0");
h.put("line-height", ss);
} else if (key.equals(Markup.CSS_KEY_TEXTALIGN)) {
String ss = prop.getProperty(key).trim().toLowerCase();
h.put("align", ss);

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

@ -394,7 +394,7 @@ public class PdfChunk {
}
// otherwise, the string has to be truncated
String returnValue = value.substring(start);
value = trim(value.substring(0, start));
value = value.substring(0, start);
PdfChunk pc = new PdfChunk(returnValue, this);
return pc;
}

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

@ -176,8 +176,6 @@ public class PdfLine {
}
// if the length of the chunk > 0 we add it to the line
else if (chunk.length() > 0 || chunk.isImage()) {
if (overflow != null)
chunk.trimLastSpace();
width -= chunk.width();
addToLine(chunk);
}

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