ImageExportContext

ImageExportContext class

Represents the context for image handling during document conversion to Markdown. This context is provided by the library during conversion and contains information about the image being processed.

public class ImageExportContext

Constructors

Name Description
ImageExportContext() The default constructor.

Properties

Name Description
ImageFileName { get; set; } Gets or sets the name of the image file. This property contains the default filename generated by the library, which you can modify if needed.

Remarks

During document conversion to Markdown, the library creates an instance of this class for each image found in the source document. You can modify the ImageFileName property if you need to customize the output image filename.

Examples

The following example shows how to handle image conversion in a custom image export handler:

public class CustomImageExportStrategy : IImageExportStrategy
{
    public string ImagesFolder => "images";

    public Stream GetImageStream(ImageExportContext context)
    {
        // Optionally customize the image filename
        context.ImageFileName = "custom-" + context.ImageFileName;
        
        // Create and return a stream for the image
        return File.Create(ImagesFolder + "/" + context.ImageFileName);
    }
}

See Also