public class CustomImageSavingArgs extends Object
An instance of this class is passed to the callback registered with CustomImagesStrategy
for each image found in the source document.
Use setOutputImageFileName(String) to change the file name the image is saved under,
or setOutputStream(OutputStream) to redirect the image data to a custom stream.
If neither method is called, the library uses the defaults provided by
imageFileName and outputDirectory.
Example:
CustomImagesStrategy strategy = new CustomImagesStrategy(args -> {
args.setOutputImageFileName("thumb-" + args.getImageFileName());
});
ConvertOptions options = new ConvertOptions();
options.setImageExportStrategy(strategy);
| Constructor and Description |
|---|
CustomImageSavingArgs(String suggestedFileName,
String shapeType,
String outputDirectory) |
| Modifier and Type | Method and Description |
|---|---|
String |
getImageFileName()
Gets the default file name (without path) suggested by the library for this image.
|
String |
getImageFileNameOutput()
Gets the overridden file name, or
null if no override was specified. |
String |
getOutputDirectory()
Gets the output directory where images are being saved.
|
OutputStream |
getOutputStream()
Gets the custom output stream, or
null if not specified. |
InputStream |
getReplacementImageStream()
Gets the replacement image stream, or
null if not specified. |
String |
getShapeType()
Gets the type of the shape that contains the image in the source document
(for example, "Picture" or "Shape").
|
void |
setOutputImageFileName(String fileName)
Overrides the default file name for this image.
|
void |
setOutputStream(OutputStream stream)
Redirects the image data to a custom writable stream instead of file output.
|
void |
setReplacementImage(InputStream imageStream)
Provides a replacement image instead of the original.
|
public String getImageFileName()
public String getShapeType()
public String getOutputDirectory()
public String getImageFileNameOutput()
null if no override was specified.public OutputStream getOutputStream()
null if not specified.public InputStream getReplacementImageStream()
null if not specified.public void setOutputImageFileName(String fileName)
fileName - new file name (without path)public void setOutputStream(OutputStream stream)
stream - writable streamIllegalArgumentException - if stream is nullpublic void setReplacementImage(InputStream imageStream)
imageStream - readable stream with image dataIllegalArgumentException - if stream is nullCopyright © 2026. All rights reserved.