IImageExportStrategy

public interface IImageExportStrategy

Defines a strategy for handling image export during document-to-Markdown conversion. Implement this interface to control where and how images extracted from the source document are stored.

The library ships with several built-in strategies:

Implement this interface directly when none of the built-in strategies meet your needs.

Example:


 public class CloudImageExportStrategy implements IImageExportStrategy {

     @Override
     public String getImagesFolder() {
         return "cloud-images";
     }

     @Override
     public OutputStream getImageStream(ImageExportContext context) {
         context.setImageFileName("doc-" + context.getImageFileName());

         return new ByteArrayOutputStream(); // replace with your cloud upload stream
     }
 }
 

Methods

Method Description
getImagesFolder() Gets the folder path where exported images will be stored.
getImageStream(ImageExportContext context) Returns a writable stream for the image described by context .

getImagesFolder()

public abstract String getImagesFolder()

Gets the folder path where exported images will be stored.

Returns: java.lang.String - a relative or absolute folder path. This value is used to construct image URIs in the Markdown output.

getImageStream(ImageExportContext context)

public abstract OutputStream getImageStream(ImageExportContext context)

Returns a writable stream for the image described by context . The library writes the image bytes to this stream during conversion.

Parameters:

Parameter Type Description
context ImageExportContext The image export context containing the default image file name and other metadata. You may modify imageFileName before returning the stream to change the file name that appears in the Markdown output.

Returns: java.io.OutputStream - a writable stream where the image data will be written, or null to use the default behavior