URI rewriting

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
Close
Loading

Analyzing your prompt, please hold on...

An error occurred while retrieving the results. Please refresh the page and try again.