Browse Source

Merge pull request #295 in CORE/base-third from ~HUGH.C/base-third:bugfix/10.0 to bugfix/10.0

* commit 'de740d5754cab495e6d8ccd894f33b5fffb2cf77':
  REPORT-23453 html切割时,丢失<br> 标签
bugfix/10.0
neil 5 years ago
parent
commit
1af790c5ac
  1. 19
      fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfChunk.java
  2. 8
      fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfLine.java

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

@ -88,6 +88,12 @@ public class PdfChunk {
private static final float FONT_SCALE = 100f;
private static final String BREAK = "\n";
private static final String BREAK_TAG = "<br>";
private boolean breakTag = false;
public float getHeight() {
return height;
}
@ -200,6 +206,7 @@ public class PdfChunk {
PdfChunk(String string, PdfChunk other) {
thisChunk[0] = this;
value = string;
updateBreakTag();
this.font = other.font;
this.attributes = other.attributes;
this.noStroke = other.noStroke;
@ -228,7 +235,7 @@ public class PdfChunk {
public PdfChunk(Chunk chunk, PdfAction action) {
thisChunk[0] = this;
value = chunk.getContent();
updateBreakTag();
Font f = chunk.getFont();
float size = f.getSize();
if (size == Font.UNDEFINED)
@ -798,7 +805,7 @@ public class PdfChunk {
htmlString.append("<span style='");
htmlString.append(getStyleAttributes()).append("'");
htmlString.append(">");
htmlString.append(value);
htmlString.append(breakTag ? BREAK_TAG : value);
htmlString.append("</span>");
return htmlString.toString();
}
@ -856,4 +863,12 @@ public class PdfChunk {
return indent.getLeft();
}
private void updateBreakTag() {
breakTag = BREAK.equals(value);
}
public boolean isBreakTag() {
return breakTag;
}
}

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

@ -94,6 +94,8 @@ public class PdfLine {
protected boolean isRTL = false;
public float getHeight() {
return height;
}
@ -157,6 +159,12 @@ public class PdfLine {
if (chunk == null || chunk.toString().equals("")) {
return null;
}
// add to line if the chunk is break tag ("\n")
if (chunk.isBreakTag()) {
addToLine(chunk);
width = 0;
return null;
}
// we split the chunk to be added
PdfChunk overflow = chunk.split(width);

Loading…
Cancel
Save