Save image as file

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 →

Use ExportImagesToFileSystemStrategy to save images as separate files during conversion. The Markdown output will contain image references pointing to the exported files.

Basic usage

import com.groupdocs.markdown.*;

public class ImageFileBasic {

    public static void main(String[] args) {
        DocumentConvertOptions options = new DocumentConvertOptions();
        options.setImageExportStrategy(new ExportImagesToFileSystemStrategy("output/images"));

        MarkdownConverter.toFile("business-plan.pdf", "output/document.md", options);
    }
}

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

output/document.md (7 KB)
output/images/img-001.jpg (10 KB)
output/images/img-002.jpg (39 KB)
output/images/img-003.jpg (25 KB)
output/images/img-004.jpg (16 KB)
output/images/img-005.jpg (44 KB)
output/images/img-006.jpg (20 KB)
output/images/img-007.jpg (648 bytes)
output/images/img-008.jpg (48 KB)

Download full output

Using a relative image path

By default, image references in the Markdown use the full images-folder path. Call setImagesRelativePath to produce portable, relative image links:

import com.groupdocs.markdown.*;

public class ImageFileRelative {

    public static void main(String[] args) {
        ExportImagesToFileSystemStrategy strategy =
                new ExportImagesToFileSystemStrategy("output/images");
        strategy.setImagesRelativePath("images");

        DocumentConvertOptions options = new DocumentConvertOptions();
        options.setImageExportStrategy(strategy);

        MarkdownConverter.toFile("business-plan.pdf", "output/document.md", options);

        // Markdown output contains: ![](images/img-001.png)
        // Image file saved to:     output/images/img-001.png
    }
}

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

output/document.md (7 KB)
output/images/img-001.jpg (10 KB)
output/images/img-002.jpg (39 KB)
output/images/img-003.jpg (25 KB)
output/images/img-004.jpg (16 KB)
output/images/img-005.jpg (44 KB)
output/images/img-006.jpg (20 KB)
output/images/img-007.jpg (648 bytes)
output/images/img-008.jpg (48 KB)

Download full output