ExportImagesToFileSystemStrategy

ExportImagesToFileSystemStrategy class

Implements an image export strategy that saves images to the file system during document 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 folder where images will be exported.

Methods

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

Remarks

This strategy saves all images from the source document to a specified folder on the file system. The images are saved with their original filenames as provided by the ImageExportContext. If the specified images folder does not exist, it will be created automatically.

Examples

The following example shows how to use ExportImagesToFileSystemStrategy when converting a document:

var options = new MarkdownConversionOptions();
options.ImageExportStrategy = new ExportImagesToFileSystemStrategy("output/images");

// Convert document and save images to the specified folder
var markdown = MarkdownConverter.Convert("document.docx", options);
// Images will be saved to the "output/images" folder
// and referenced in the markdown as ![](images/img-001.png)

See Also