Save image as base64

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Markdown MCP server lets your agent work with files on your machine; they are never uploaded. It needs the .NET 10 SDK or Docker.

claude mcp add groupdocs-markdown -- dnx GroupDocs.Markdown.Mcp --yes
Folders, licensing and more →

By default, DocumentConvertOptions uses ExportImagesAsBase64Strategy, which embeds images as Base64 data URIs directly in the Markdown output. This keeps the output self-contained in a single file with no external image dependencies.

Using static method

import com.groupdocs.markdown.*;

public class Base64Static {

    public static void main(String[] args) {
        // Default behavior -- images are embedded as Base64
        MarkdownConverter.toFile("business-plan.pdf", "base64-static.md");
    }
}

business-plan.pdf is a sample file used in this example. Click here to download it.

**Meridian Outdoor Co. — Business Plan**

FY2026 Strategic Plan

![](data:...;base64,[elided])


**Table of Contents**

MeridianOutdoorCo.—BusinessPlan.........................................................................................1
[TRUNCATED]

Download full output

Specifying the strategy explicitly

If you want to be explicit, pass a new ExportImagesAsBase64Strategy to setImageExportStrategy:

import com.groupdocs.markdown.*;

public class Base64Explicit {

    public static void main(String[] args) {
        DocumentConvertOptions options = new DocumentConvertOptions();
        options.setImageExportStrategy(new ExportImagesAsBase64Strategy());

        try (MarkdownConverter converter = new MarkdownConverter("business-plan.pdf")) {
            converter.convert("base64-explicit.md", options);
        }
    }
}

business-plan.pdf is a sample file used in this example. Click here to download it.

**Meridian Outdoor Co. — Business Plan**

FY2026 Strategic Plan

![](data:...;base64,[elided])


**Table of Contents**

MeridianOutdoorCo.—BusinessPlan.........................................................................................1
[TRUNCATED]

Download full output