private void addToLine(PdfChunk chunk) { if (chunk.changeLeading) { float f; if (chunk.isImage()) { Image img = chunk.getImage(); f = chunk.getImageHeight() + chunk.getImageOffsetY() + img.getBorderWidthTop() + img.getSpacingBefore(); } else { f = chunk.getLeading(); } if (f > height) height = f; } if (tabStop != null && tabStop.getAlignment() == TabStop.Alignment.ANCHOR && Float.isNaN(tabStopAnchorPosition)) { String value = chunk.toString(); int anchorIndex = value.indexOf(tabStop.getAnchorChar()); if (anchorIndex != -1) { float subWidth = chunk.width(value.substring(anchorIndex, value.length())); tabStopAnchorPosition = originalWidth - width - subWidth; } } line.add(chunk); }
/** * Gets the difference between the "normal" leading and the maximum * size (for instance when there are images in the chunk and the leading * has to be taken into account). * @return an extra leading for images * @since 2.1.5 */ float[] getMaxSize(float fixedLeading, float multipliedLeading) { float normal_leading = 0; float image_leading = -10000; PdfChunk chunk; for (int k = 0; k < line.size(); ++k) { chunk = line.get(k); if (chunk.isImage()) { Image img = chunk.getImage(); if (chunk.changeLeading()) { float height = chunk.getImageHeight() + chunk.getImageOffsetY() + img.getSpacingBefore(); image_leading = Math.max(height, image_leading); } } else { if (chunk.changeLeading()) normal_leading = Math.max(chunk.getLeading(), normal_leading); else normal_leading = Math.max(fixedLeading + multipliedLeading * chunk.font().size(), normal_leading); } } return new float[]{normal_leading > 0 ? normal_leading : fixedLeading, image_leading}; }
private void addToLine(PdfChunk chunk) { if (chunk.changeLeading) { float f; if (chunk.isImage()) { Image img = chunk.getImage(); f = chunk.getImageHeight() + chunk.getImageOffsetY() + img.getBorderWidthTop() + img.getSpacingBefore(); } else { f = chunk.getLeading(); } if (f > height) height = f; } if (tabStop != null && tabStop.getAlignment() == TabStop.Alignment.ANCHOR && Float.isNaN(tabStopAnchorPosition)) { String value = chunk.toString(); int anchorIndex = value.indexOf(tabStop.getAnchorChar()); if (anchorIndex != -1) { float subWidth = chunk.width(value.substring(anchorIndex, value.length())); tabStopAnchorPosition = originalWidth - width - subWidth; } } line.add(chunk); }
/** * Gets the difference between the "normal" leading and the maximum * size (for instance when there are images in the chunk and the leading * has to be taken into account). * @return an extra leading for images * @since 2.1.5 */ float[] getMaxSize(float fixedLeading, float multipliedLeading) { float normal_leading = 0; float image_leading = -10000; PdfChunk chunk; for (int k = 0; k < line.size(); ++k) { chunk = line.get(k); if (chunk.isImage()) { Image img = chunk.getImage(); if (chunk.changeLeading()) { float height = chunk.getImageHeight() + chunk.getImageOffsetY() + img.getSpacingBefore(); image_leading = Math.max(height, image_leading); } } else { if (chunk.changeLeading()) normal_leading = Math.max(chunk.getLeading(), normal_leading); else normal_leading = Math.max(fixedLeading + multipliedLeading * chunk.font().size(), normal_leading); } } return new float[]{normal_leading > 0 ? normal_leading : fixedLeading, image_leading}; }
t.setSpacingBefore(img.getSpacingBefore()); switch (img.getAlignment()) { case Image.LEFT:
t.setSpacingBefore(img.getSpacingBefore()); switch (img.getAlignment()) { case Image.LEFT:
if (ck.isImage() && minY < yLine) { Image img = ck.getImage(); if (img.isScaleToFitHeight() && yLine + 2 * descender - img.getScaledHeight() - ck.getImageOffsetY() - img.getSpacingBefore() < minY) { float scalePercent = (yLine + 2 * descender - ck.getImageOffsetY() - img.getSpacingBefore() - minY) / img.getScaledHeight(); ck.setImageScalePercentage(scalePercent);
if (ck.isImage() && minY < yLine) { Image img = ck.getImage(); if (img.isScaleToFitHeight() && yLine + 2 * descender - img.getScaledHeight() - ck.getImageOffsetY() - img.getSpacingBefore() < minY) { float scalePercent = (yLine + 2 * descender - ck.getImageOffsetY() - img.getSpacingBefore() - minY) / img.getScaledHeight(); ck.setImageScalePercentage(scalePercent);