Class Image

java.lang.Object
pro.verron.officestamper.preset.Image

public final class Image extends Object
This class describes an image, which will be inserted into a document.
Since:
1.0.0
Version:
${version}
Author:
Joseph Verron, Romster
  • Constructor Details

    • Image

      public Image(InputStream in) throws IOException
      Constructor for Image.
      Parameters:
      in -
      • content of the image as InputStream
      Throws:
      IOException - if any.
    • Image

      public Image(byte[] imageBytes)
      Constructor for Image.
      Parameters:
      imageBytes -
      • content of the image as an array of the bytes
    • Image

      public Image(byte[] imageBytes, @Nullable Integer maxWidth)
      Constructor for Image.
      Parameters:
      imageBytes -
      • content of the image as an array of the bytes
      maxWidth -
      • max width of the image in twip
    • Image

      public Image(byte[] imageBytes, @Nullable Integer maxWidth, String filenameHint, String altText)
      Constructor for Image.
      Parameters:
      imageBytes - content of the image as an array of the bytes
      maxWidth - max width of the image in twip
      filenameHint - filename hint for the image.
      altText - alternative text for the image.
    • Image

      public Image(InputStream in, @Nullable Integer maxWidth) throws IOException
      Constructor for Image.
      Parameters:
      in -
      • content of the image as InputStream
      maxWidth -
      • max width of the image in twip
      Throws:
      IOException - if any.
  • Method Details

    • newRun

      public org.docx4j.wml.R newRun(DocxPart part)

      Creates a new run with the provided image and associated metadata.

      TODO: adding the same image twice will put the image twice into the docx-zip file. We should make the second addition of the same image a reference instead.

      Parameters:
      part - The document part where the image will be inserted.
      Returns:
      The created run containing the image.
      Throws:
      OfficeStamperException - If there is an error creating the image part