ExportImagesAsBase64Strategy
Contents
[
Hide
]
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:
// Base64 is the default, but can be set explicitly:
var options = new ConvertOptions
{
ImageExportStrategy = new ExportImagesAsBase64Strategy()
};
string markdown = MarkdownConverter.ToMarkdown("document.docx", options);
See Also
- interface IImageExportStrategy
- namespace GroupDocs.Markdown
- assembly GroupDocs.Markdown