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. 21
      fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfChunk.java
  2. 10
      fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfLine.java

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

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

@ -94,6 +94,8 @@ public class PdfLine {
protected boolean isRTL = false; protected boolean isRTL = false;
public float getHeight() { public float getHeight() {
return height; return height;
} }
@ -155,7 +157,13 @@ public class PdfLine {
public PdfChunk add(PdfChunk chunk) { public PdfChunk add(PdfChunk chunk) {
// nothing happens if the chunk is null. // nothing happens if the chunk is null.
if (chunk == null || chunk.toString().equals("")) { if (chunk == null || chunk.toString().equals("")) {
return null; 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 // we split the chunk to be added

Loading…
Cancel
Save