CustomImagesStrategy

Inheritance: java.lang.Object

All Implemented Interfaces: com.groupdocs.markdown.IImageExportStrategy

public class CustomImagesStrategy implements IImageExportStrategy

Implements an image export strategy that gives you full control over how images are saved during conversion.

Supply an IImageSavingHandler implementation to rename images, redirect them to a custom stream, or apply any other custom logic when each image is encountered.

Example:


 IImageSavingHandler handler = new RenameHandler();

 ConvertOptions options = new ConvertOptions();
 options.setImageExportStrategy(new CustomImagesStrategy("images", handler));

 String markdown = MarkdownConverter.toMarkdown("document.docx", options);
 

Constructors

Constructor Description
CustomImagesStrategy(String imagesFolder, IImageSavingHandler handler) Initializes a new instance of the CustomImagesStrategy class.

Methods

Method Description
getImagesFolder() Gets the physical folder where images will be saved on disk.
getImagesRelativePath() Gets or sets the path used in the Markdown image references.
setImagesRelativePath(String imagesRelativePath)
getImageStream(ImageExportContext context) Gets a stream for writing the exported image to the file system.
getCustomHandler()

CustomImagesStrategy(String imagesFolder, IImageSavingHandler handler)

public CustomImagesStrategy(String imagesFolder, IImageSavingHandler handler)

Initializes a new instance of the CustomImagesStrategy class.

Parameters:

Parameter Type Description
imagesFolder java.lang.String the folder where images will be exported
handler IImageSavingHandler the handler that is called for each image during conversion

getImagesFolder()

public String getImagesFolder()

Gets the physical folder where images will be saved on disk.

Returns: java.lang.String

getImagesRelativePath()

public String getImagesRelativePath()

Gets or sets the path used in the Markdown image references. When null or empty, the full imagesFolder path is used.

Returns: java.lang.String

setImagesRelativePath(String imagesRelativePath)

public void setImagesRelativePath(String imagesRelativePath)

Parameters:

Parameter Type Description
imagesRelativePath java.lang.String

getImageStream(ImageExportContext context)

public OutputStream getImageStream(ImageExportContext context)

Gets a stream for writing the exported image to the file system.

Parameters:

Parameter Type Description
context ImageExportContext

Returns: java.io.OutputStream

getCustomHandler()

public IImageSavingHandler getCustomHandler()

Returns: IImageSavingHandler