|
|
|
@ -77,6 +77,10 @@ public class PdfLine {
|
|
|
|
|
/** true : 存在常规标签(非上下标) */ |
|
|
|
|
protected boolean existNormalTag; |
|
|
|
|
|
|
|
|
|
protected float maxImgHeight; |
|
|
|
|
|
|
|
|
|
protected float maxTextHeight; |
|
|
|
|
|
|
|
|
|
/** The left indentation of the line. */ |
|
|
|
|
protected float left; |
|
|
|
|
|
|
|
|
@ -225,7 +229,10 @@ public class PdfLine {
|
|
|
|
|
//添加到line上处理计算line高度
|
|
|
|
|
if (chunk.changeLeading && chunk.isImage()) { |
|
|
|
|
float f = chunk.getImage().getScaledHeight() + chunk.getImageOffsetY() + chunk.getImage().getBorderWidthTop(); |
|
|
|
|
if (f > height) height = f; |
|
|
|
|
if (f > height){ |
|
|
|
|
height = f; |
|
|
|
|
} |
|
|
|
|
maxImgHeight = Math.max(maxImgHeight, f); |
|
|
|
|
}else{ |
|
|
|
|
float textRise = chunk.getTextRise(); |
|
|
|
|
if (textRise != 0) { |
|
|
|
@ -234,11 +241,17 @@ public class PdfLine {
|
|
|
|
|
} else { |
|
|
|
|
maxTextDrop = -Math.min(maxTextDrop, textRise); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
//一行中只有上下标时,不需要浮动
|
|
|
|
|
existNormalTag = true; |
|
|
|
|
} |
|
|
|
|
this.height = Math.max(this.height, chunk.getHeight() + (neddRiseOrDrop() ? maxTextRise + maxTextDrop : 0)); |
|
|
|
|
//图片存在且高度足够大,整体高度就不考虑上下标的浮动距离了
|
|
|
|
|
if (chunk.isImage()) { |
|
|
|
|
maxImgHeight = Math.max(maxImgHeight, chunk.getImage().getScaledHeight()); |
|
|
|
|
} else { |
|
|
|
|
maxTextHeight = Math.max(maxTextHeight, chunk.getHeight() + maxTextRise + maxTextDrop); |
|
|
|
|
} |
|
|
|
|
this.height = Math.max(this.height, chunk.getHeight() + (neddRiseOrDrop() && !imgBigThanText() ? maxTextRise + maxTextDrop : 0)); |
|
|
|
|
} |
|
|
|
|
line.add(chunk); |
|
|
|
|
} |
|
|
|
@ -255,6 +268,10 @@ public class PdfLine {
|
|
|
|
|
return existNormalTag && (maxTextRise > 0 || maxTextDrop > 0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public boolean imgBigThanText() { |
|
|
|
|
return maxImgHeight > maxTextHeight; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// methods to retrieve information
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|