ExportImagesAsBase64Strategy

ExportImagesAsBase64Strategy class

Implements an image export strategy that embeds images as Base64 strings directly in the Markdown.

public class ExportImagesAsBase64Strategy : IImageExportStrategy

Constructors

Name Description
ExportImagesAsBase64Strategy() The default constructor.

Properties

Name Description
ImagesFolder { get; } Gets an empty string as this strategy does not use an images folder.

Methods

Name Description
GetImageStream(ImageExportContext) Returns null to indicate that the image should be embedded as Base64.

Remarks

This strategy converts all images to Base64 format and embeds them directly in the Markdown document using the data URI scheme. This eliminates the need for separate image files, making the Markdown document self-contained. However, this approach increases the size of the Markdown file and may not be supported by all Markdown viewers.

Examples

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

var options = new MarkdownConversionOptions();
options.ImageExportStrategy = new ExportImagesAsBase64Strategy();

// Convert document with embedded Base64 images
var markdown = MarkdownConverter.Convert("document.docx", options);
// The markdown will contain embedded images like:
// ![](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...)

See Also