com.itextpdf.text.Image.getScaledWidth()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(6.3k)|赞(0)|评价(0)|浏览(142)

本文整理了Java中com.itextpdf.text.Image.getScaledWidth()方法的一些代码示例,展示了Image.getScaledWidth()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Image.getScaledWidth()方法的具体详情如下:
包路径:com.itextpdf.text.Image
类名称:Image
方法名:getScaledWidth

Image.getScaledWidth介绍

[英]Gets the scaled width of the image.
[中]获取图像的缩放宽度。

代码示例

代码示例来源:origin: com.itextpdf/itextpdf

float getImageWidth() {
  return image.getScaledWidth() * imageScalePercentage;
}

代码示例来源:origin: com.itextpdf/itextg

float getImageWidth() {
  return image.getScaledWidth() * imageScalePercentage;
}

代码示例来源:origin: com.itextpdf/itextpdf

/**
 * Gets the width of the <CODE>PdfChunk</CODE> taking into account the
 * extra character and word spacing.
 * @param charSpacing the extra character spacing
 * @param wordSpacing the extra word spacing
 * @return the calculated width
 */

  public float getWidthCorrected(float charSpacing, float wordSpacing)
  {
    if (image != null) {
      return image.getScaledWidth() + charSpacing;
    }
    int numberOfSpaces = 0;
    int idx = -1;
    while ((idx = value.indexOf(' ', idx + 1)) >= 0)
      ++numberOfSpaces;
    return font.width(value) + value.length() * charSpacing + numberOfSpaces * wordSpacing;
  }

代码示例来源:origin: com.itextpdf/itextg

/**
 * Gets the width of the <CODE>PdfChunk</CODE> taking into account the
 * extra character and word spacing.
 * @param charSpacing the extra character spacing
 * @param wordSpacing the extra word spacing
 * @return the calculated width
 */

  public float getWidthCorrected(float charSpacing, float wordSpacing)
  {
    if (image != null) {
      return image.getScaledWidth() + charSpacing;
    }
    int numberOfSpaces = 0;
    int idx = -1;
    while ((idx = value.indexOf(' ', idx + 1)) >= 0)
      ++numberOfSpaces;
    return font.width(value) + value.length() * charSpacing + numberOfSpaces * wordSpacing;
  }

代码示例来源:origin: com.itextpdf/itextpdf

/**
 * Scales the image so that it fits a certain width and height.
 *
 * @param fitWidth
 *            the width to fit
 * @param fitHeight
 *            the height to fit
 */
public void scaleToFit(final float fitWidth, final float fitHeight) {
  scalePercent(100);
  float percentX = fitWidth * 100 / getScaledWidth();
  float percentY = fitHeight * 100 / getScaledHeight();
  scalePercent(percentX < percentY ? percentX : percentY);
  setWidthPercentage(0);
}

代码示例来源:origin: com.itextpdf/itextg

/**
 * Scales the image so that it fits a certain width and height.
 *
 * @param fitWidth
 *            the width to fit
 * @param fitHeight
 *            the height to fit
 */
public void scaleToFit(final float fitWidth, final float fitHeight) {
  scalePercent(100);
  float percentX = fitWidth * 100 / getScaledWidth();
  float percentY = fitHeight * 100 / getScaledHeight();
  scalePercent(percentX < percentY ? percentX : percentY);
  setWidthPercentage(0);
}

代码示例来源:origin: Swati4star/Images-to-PDF

(documentRect.getWidth() - image.getScaledWidth()) / 2,
(documentRect.getHeight() - image.getScaledHeight()) / 2);

代码示例来源:origin: com.itextpdf/itextpdf

if (image.getScaledWidth() > width) {

代码示例来源:origin: com.itextpdf/itextg

if (image.getScaledWidth() > width) {

代码示例来源:origin: yeokm1/docs-to-pdf-converter

document.setPageSize(new Rectangle(image.getScaledWidth(), image.getScaledHeight()));
document.newPage();
image.setAbsolutePosition(0, 0);

代码示例来源:origin: com.itextpdf/itextpdf

/**
 * Gets the width of the Chunk in points.
 *
 * @return a width in points
 */
public float getWidthPoint() {
  if (getImage() != null) {
    return getImage().getScaledWidth();
  }
  return font.getCalculatedBaseFont(true).getWidthPoint(getContent(),
      font.getCalculatedSize())
      * getHorizontalScaling();
}

代码示例来源:origin: com.itextpdf/itextg

/**
 * Gets the width of the Chunk in points.
 *
 * @return a width in points
 */
public float getWidthPoint() {
  if (getImage() != null) {
    return getImage().getScaledWidth();
  }
  return font.getCalculatedBaseFont(true).getWidthPoint(getContent(),
      font.getCalculatedSize())
      * getHorizontalScaling();
}

代码示例来源:origin: qaprosoft/carina

document = new Document(PageSize.A4, 10, 10, 10, 10);
if (image.getHeight() > (document.getPageSize().getHeight() - 20)
    || image.getScaledWidth() > (document.getPageSize().getWidth() - 20)) {
  image.scaleToFit(document.getPageSize().getWidth() - 20, document.getPageSize().getHeight() - 20);
document = new Document(new RectangleReadOnly(image.getScaledWidth(), image.getScaledHeight()));

代码示例来源:origin: ekoz/kbase-doc

float w = Math.min(img.getScaledWidth(), 460);
float h = Math.min(img.getScaledHeight(), 300);
for (float f : img.matrix()) {

代码示例来源:origin: Swati4star/Images-to-PDF

image.scaleToFit(pageWidth, pageHeight);
image.setAbsolutePosition(
    (documentRect.getWidth() - image.getScaledWidth()) / 2,
    (documentRect.getHeight() - image.getScaledHeight()) / 2);
document.add(image);

代码示例来源:origin: com.itextpdf/itextg

float mt[] = image.matrix();
float startPosition = indentLeft() - mt[4];
if ((image.getAlignment() & Image.RIGHT) == Image.RIGHT) startPosition = indentRight() - image.getScaledWidth() - mt[4];
if ((image.getAlignment() & Image.MIDDLE) == Image.MIDDLE) startPosition = indentLeft() + (indentRight() - indentLeft() - image.getScaledWidth()) / 2 - mt[4];
if (image.hasAbsoluteX()) startPosition = image.getAbsoluteX();
if (textwrap) {
    indentation.imageIndentRight += image.getScaledWidth() + image.getIndentationLeft();
    indentation.imageIndentLeft += image.getScaledWidth() + image.getIndentationRight();

代码示例来源:origin: com.itextpdf/itextpdf

float mt[] = image.matrix();
float startPosition = indentLeft() - mt[4];
if ((image.getAlignment() & Image.RIGHT) == Image.RIGHT) startPosition = indentRight() - image.getScaledWidth() - mt[4];
if ((image.getAlignment() & Image.MIDDLE) == Image.MIDDLE) startPosition = indentLeft() + (indentRight() - indentLeft() - image.getScaledWidth()) / 2 - mt[4];
if (image.hasAbsoluteX()) startPosition = image.getAbsoluteX();
if (textwrap) {
    indentation.imageIndentRight += image.getScaledWidth() + image.getIndentationLeft();
    indentation.imageIndentLeft += image.getScaledWidth() + image.getIndentationRight();

代码示例来源:origin: com.itextpdf/itextpdf

float w = img.getWidthPercentage();
if (w == 0) {
  t.setTotalWidth(img.getScaledWidth());
  t.setLockedWidth(true);
} else {

代码示例来源:origin: com.itextpdf/itextg

if (img != null) {
  img.scalePercent(100);
  float refWidth = pivoted ? img.getScaledHeight() : img.getScaledWidth();
  float scale = (getRight() - getEffectivePaddingRight()
      - getEffectivePaddingLeft() - getLeft()) / refWidth;
  img.scalePercent(scale * 100);
  float refHeight = pivoted ? img.getScaledWidth() : img.getScaledHeight();
  setBottom(getTop() - getEffectivePaddingTop() - getEffectivePaddingBottom() - refHeight);
} else {

代码示例来源:origin: com.itextpdf/itextpdf

if (img != null) {
  img.scalePercent(100);
  float refWidth = pivoted ? img.getScaledHeight() : img.getScaledWidth();
  float scale = (getRight() - getEffectivePaddingRight()
      - getEffectivePaddingLeft() - getLeft()) / refWidth;
  img.scalePercent(scale * 100);
  float refHeight = pivoted ? img.getScaledWidth() : img.getScaledHeight();
  setBottom(getTop() - getEffectivePaddingTop() - getEffectivePaddingBottom() - refHeight);
} else {

相关文章

微信公众号

最新文章

更多