URI rewriting

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 →

DocumentConvertOptions.setUriExportStrategy controls the URIs written into the Markdown output for exported resources. This is useful when images are served from a CDN or a different path than where they’re saved.

Note
URI rewriting works with file-based image strategies (ExportImagesToFileSystemStrategy or CustomImagesStrategy). It has no effect when images are embedded as Base64, which is the default.

Default behaviour

Without an explicit strategy the library uses DefaultUriExportStrategy, which writes the relative path configured on the image strategy:

ExportImagesToFileSystemStrategy imageStrategy =
        new ExportImagesToFileSystemStrategy("output/images");
imageStrategy.setImagesRelativePath("images");
// Markdown references: ![](images/img-001.png)

For most cases, setting setImagesRelativePath on the image strategy is all the URI control you need — see Save image as file.

Custom URI strategies

Warning

CustomUriExportStrategy cannot be used in 26.5. Its only public constructor takes com.groupdocs.markdown.uriexport.a — an obfuscated, package-private type — so it cannot be constructed from user code.

Implementing IUriExportStrategy yourself and passing it to setUriExportStrategy does work. A worked example will be published here once the constructor issue is resolved.

UriExportContext methods

IUriExportStrategy.updateResourceUri receives a UriExportContext:

MethodDescription
getResourceFileName()Default file name generated by the library
getResourceFileUri()Default URI that would appear in the Markdown
setResourceFileName(String)Override the resource file name
setResourceFileUri(String)Override the URI written to the Markdown output