Class ImageResolver

java.lang.Object
pro.verron.docxstamper.preset.resolver.ImageResolver
All Implemented Interfaces:
ObjectResolver

public class ImageResolver extends Object implements ObjectResolver
This ITypeResolver allows context objects to return objects of type Image. An expression that resolves to an Image object will be replaced by an actual image in the resulting .docx document. The image will be put as an inline into the surrounding paragraph of text.
Version:
${version}
Author:
Joseph Verron
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Checks if the given object can be resolved.
    static org.docx4j.wml.R
    createRunWithImage(Integer maxWidth, org.docx4j.openpackaging.parts.WordprocessingML.BinaryPartAbstractImage abstractImage)
    Creates a run containing the given image.
    org.docx4j.wml.R
    resolve(org.docx4j.openpackaging.packages.WordprocessingMLPackage document, String placeholder, Object object)
    Resolves the placeholder in the given document with the provided object.
    org.docx4j.wml.R
    resolve(org.docx4j.openpackaging.packages.WordprocessingMLPackage document, Image image)
    Resolves an image and adds it to a WordprocessingMLPackage document.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ImageResolver

      public ImageResolver()
  • Method Details

    • createRunWithImage

      public static org.docx4j.wml.R createRunWithImage(Integer maxWidth, org.docx4j.openpackaging.parts.WordprocessingML.BinaryPartAbstractImage abstractImage)
      Creates a run containing the given image.
      Parameters:
      maxWidth - max width of the image
      abstractImage - the image
      Returns:
      the run containing the image
    • resolve

      public org.docx4j.wml.R resolve(org.docx4j.openpackaging.packages.WordprocessingMLPackage document, Image image)
      Resolves an image and adds it to a WordprocessingMLPackage document.
      Parameters:
      document - The WordprocessingMLPackage document
      image - The image to be resolved and added
      Returns:
      The run containing the added image
      Throws:
      DocxStamperException - If an error occurs while adding the image to the document
    • resolve

      public org.docx4j.wml.R resolve(org.docx4j.openpackaging.packages.WordprocessingMLPackage document, String placeholder, Object object)
      Description copied from interface: ObjectResolver
      Resolves the placeholder in the given document with the provided object.
      Specified by:
      resolve in interface ObjectResolver
      Parameters:
      document - the WordprocessingMLPackage document in which to resolve the placeholder
      placeholder - the placeholder value to be replaced
      object - the object to be used for resolving the placeholder
      Returns:
      the resolved value for the placeholder
    • canResolve

      public boolean canResolve(Object object)
      Description copied from interface: ObjectResolver
      Checks if the given object can be resolved.
      Specified by:
      canResolve in interface ObjectResolver
      Parameters:
      object - the object to be resolved
      Returns:
      true if the object can be resolved, false otherwise