CustomImagesStrategy
Leave feedback
On this page
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);
| Constructor | Description |
|---|---|
| CustomImagesStrategy(String imagesFolder, IImageSavingHandler handler) | Initializes a new instance of the CustomImagesStrategy class. |
| 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() |
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 |
public String getImagesFolder()
Gets the physical folder where images will be saved on disk.
Returns: java.lang.String
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
public void setImagesRelativePath(String imagesRelativePath)
Parameters:
| Parameter | Type | Description |
|---|---|---|
| imagesRelativePath | java.lang.String |
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
public IImageSavingHandler getCustomHandler()
Returns: IImageSavingHandler
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.