Class ImageResolver
java.lang.Object
pro.verron.docxstamper.preset.resolver.ImageResolver
- All Implemented Interfaces:
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 -
Method Summary
Modifier and TypeMethodDescriptionbooleancanResolve(Object object) Checks if the given object can be resolved.static org.docx4j.wml.RcreateRunWithImage(Integer maxWidth, org.docx4j.openpackaging.parts.WordprocessingML.BinaryPartAbstractImage abstractImage) Creates a run containing the given image.org.docx4j.wml.Rresolve(org.docx4j.openpackaging.packages.WordprocessingMLPackage document, String placeholder, Object object) Resolves the placeholder in the given document with the provided object.org.docx4j.wml.RResolves an image and adds it to a WordprocessingMLPackage document.
-
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 imageabstractImage- 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 documentimage- 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:ObjectResolverResolves the placeholder in the given document with the provided object.- Specified by:
resolvein interfaceObjectResolver- Parameters:
document- theWordprocessingMLPackagedocument in which to resolve the placeholderplaceholder- the placeholder value to be replacedobject- the object to be used for resolving the placeholder- Returns:
- the resolved value for the placeholder
-
canResolve
Description copied from interface:ObjectResolverChecks if the given object can be resolved.- Specified by:
canResolvein interfaceObjectResolver- Parameters:
object- the object to be resolved- Returns:
- true if the object can be resolved, false otherwise
-