Class ImageRenderer

java.lang.Object
com.itextpdf.layout.renderer.AbstractRenderer
com.itextpdf.layout.renderer.ImageRenderer
All Implemented Interfaces:
IPropertyContainer, ILeafElementRenderer, IRenderer

public class ImageRenderer extends AbstractRenderer implements ILeafElementRenderer
  • Field Details

    • fixedXPosition

      protected Float fixedXPosition
    • fixedYPosition

      protected Float fixedYPosition
    • pivotY

      protected float pivotY
    • deltaX

      protected float deltaX
    • imageWidth

      protected float imageWidth
    • imageHeight

      protected float imageHeight
  • Constructor Details

    • ImageRenderer

      public ImageRenderer (Image image)
      Creates an ImageRenderer from its corresponding layout object.
      Parameters:
      image - the Image which this object should manage
  • Method Details

    • layout

      public LayoutResult layout (LayoutContext layoutContext)
      Description copied from interface: IRenderer
      This method simulates positioning of the renderer, including all of its children, and returns the LayoutResult, representing the layout result, including occupied area, status, i.e. if there was enough place to fit the renderer subtree, etc. LayoutResult can be extended to return custom layout results for custom elements, e.g. TextRenderer uses TextLayoutResult as its result. This method can be called standalone to learn how much area the renderer subtree needs, or can be called before IRenderer.draw(DrawContext), to prepare the renderer to be flushed to the output stream.
      Specified by:
      layout in interface IRenderer
      Parameters:
      layoutContext - the description of layout area and any other additional information
      Returns:
      result of the layout process
    • draw

      public void draw (DrawContext drawContext)
      Description copied from class: AbstractRenderer
      Flushes the renderer subtree contents, i.e. draws itself on canvas, adds necessary objects to the PdfDocument etc.
      Specified by:
      draw in interface IRenderer
      Overrides:
      draw in class AbstractRenderer
      Parameters:
      drawContext - contains the PdfDocument to which the renderer subtree if flushed, the PdfCanvas on which the renderer subtree is drawn and other additional parameters needed to perform drawing
    • getNextRenderer

      public IRenderer getNextRenderer()
      Description copied from interface: IRenderer
      Gets a new instance of this class to be used as a next renderer, after this renderer is used, if IRenderer.layout(LayoutContext) is called more than once.
      Specified by:
      getNextRenderer in interface IRenderer
      Returns:
      new renderer instance
    • getBorderAreaBBox

      public Rectangle getBorderAreaBBox()
      Description copied from class: AbstractRenderer
      Gets the border box of a renderer. This is a box used to draw borders.
      Overrides:
      getBorderAreaBBox in class AbstractRenderer
      Returns:
      border box of a renderer
    • getImageWidth

      public float getImageWidth()
      Gets original width of the image, not the width set by Image.setWidth(float) method.
      Returns:
      original image width
    • getImageHeight

      public float getImageHeight()
      Gets original height of the image, not the height set by Image.setHeight(float) method.
      Returns:
      original image height
    • applyPaddings

      protected Rectangle applyPaddings (Rectangle rect, UnitValue[] paddings, boolean reverse)
      Description copied from class: AbstractRenderer
      Applies given paddings on the given rectangle
      Overrides:
      applyPaddings in class AbstractRenderer
      Parameters:
      rect - a rectangle paddings will be applied on.
      paddings - the paddings to be applied on the given rectangle
      reverse - indicates whether paddings will be applied inside (in case of false) or outside (in case of true) the rectangle.
      Returns:
      a border box of the renderer
    • move

      public void move (float dxRight, float dyUp)
      Description copied from class: AbstractRenderer
      Moves the renderer subtree by the specified offset. This method affects occupied area of the renderer.
      Specified by:
      move in interface IRenderer
      Overrides:
      move in class AbstractRenderer
      Parameters:
      dxRight - the x-axis offset in points. Positive value will move the renderer subtree to the right.
      dyUp - the y-axis offset in points. Positive value will move the renderer subtree to the top.
    • getMinMaxWidth

      public MinMaxWidth getMinMaxWidth()
      Description copied from class: AbstractRenderer
      Calculates min and max width values for current renderer.
      Overrides:
      getMinMaxWidth in class AbstractRenderer
      Returns:
      instance of MinMaxWidth
    • autoScale

      protected ImageRenderer autoScale (LayoutArea layoutArea)
    • getAscent

      public float getAscent()
      Description copied from interface: ILeafElementRenderer
      Gets the maximum offset above the base line that this ILeafElementRenderer extends to.
      Specified by:
      getAscent in interface ILeafElementRenderer
      Returns:
      the upwards vertical offset of this ILeafElementRenderer
    • getDescent

      public float getDescent()
      Description copied from interface: ILeafElementRenderer
      Gets the maximum offset below the base line that this ILeafElementRenderer extends to.
      Specified by:
      getDescent in interface ILeafElementRenderer
      Returns:
      the downwards vertical offset of this ILeafElementRenderer