ExportImagesToFileSystemStrategy

ExportImagesToFileSystemStrategy class

Saves images to a folder on disk during conversion.

public class ExportImagesToFileSystemStrategy : IImageExportStrategy

Constructors

Name Description
ExportImagesToFileSystemStrategy(string) Initializes a new instance of the ExportImagesToFileSystemStrategy class.

Properties

Name Description
ImagesFolder { get; } Gets the physical folder where images will be saved on disk.
ImagesRelativePath { get; set; } Gets or sets the path used in the Markdown image references. When null or empty, the full ImagesFolder path is used (which may be absolute). Set this to a relative path (e.g. "images") so the Markdown output contains portable references.

Methods

Name Description
GetImageStream(ImageExportContext) Gets a stream for writing the exported image to the file system.

Remarks

By default, the Markdown output references images using the full ImagesFolder path. Set ImagesRelativePath to control the path that appears in the Markdown image links — typically a path relative to the output .md file.

Examples

Save images next to the output file and reference them with a relative path:

var strategy = new ExportImagesToFileSystemStrategy("c:/output/images")
{
    ImagesRelativePath = "images"
};
var options = new ConvertOptions { ImageExportStrategy = strategy };
MarkdownConverter.ToFile("document.docx", "c:/output/doc.md", options);
// Markdown contains: ![](images/img-001.png)
// Image file at:     c:/output/images/img-001.png

See Also