Namespace for images when converting to HTML

I have a web application that allows users to update word documents which I convert to HTML using Aspose.word.java version 21.8, and re-display in a browser. On the whole I find the conversion to HTML excellent.
The problem I came across is that in the HTML, images in the document are rendered inside svg first as

<svg>
  <defs>
     <image id="image006" xlink:href="data:image/jpeg;base64,...." />
  </defs>...

and then displayed with:

<g>
  <use xlink:href="#image006"  width="200" ... />```
</g>

The issue I have is that if I have two word documents, each with an image in them, they can both render tags sharing the same id (e.g. “image006”). This means that if I render both documents on the browser at the same time, the of the second document references the image from the first document - since they both share the same image id

I am generating my HTML using

HtmlFixedSaveOptions options = new HtmlFixedSaveOptions();
options.setExportGeneratorName(true);
options.setExportEmbeddedCss(true);
options.setExportEmbeddedImages(true);
options.setExportEmbeddedSvg(true);
options.setExportEmbeddedFonts(true);
options.setShowPageBorder(true);
options.setPageMargins(0);
options.setPageHorizontalAlignment(HtmlFixedPageHorizontalAlignment.LEFT);

try (ByteArrayOutputStream bos = new ByteArrayOutputStream()) {
    document.save(bos, options);
    String s = new String(bos.toByteArray(), StandardCharsets.UTF_8);
                out.append(s);
}

What I am looking for is a way to a prefix to the imageids so that the ids for my two document can be isolated from each other - similar I think to HTMLSaveOptions.setCssClassNamePrefix()

Here are two document, which generate imageids that are the same (and thus can’t be displayed on the same webpage)
I am doc 1.docx (100.5 KB)
I am doc 2.docx (75.1 KB)

Thanks,

Mark

@mhill.labvantage Unfortunately, currently there is no way to achieve this.

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): WORDSNET-27277

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

For now, you can postprocess the generated HtmlFixed documents and replace image IDs with prefixed ones.

Hi. I believe we do have paid support. I will check.

In the meantime, regarding the post-processing, can I assume the ids will all be of the format “imagennn”?

Thx.

@mhill.labvantage Yes, images ids are always in imagennn format. Ids for SVG and HtmlFixed are generated by the following code:

public string GenerateId(IdType idType)
{
    return GetPrefix(idType) + (++mIndexes[(int)idType]).ToString("D3", CultureInfo.InvariantCulture);
}

private static string GetPrefix(IdType idType)
{
    switch (idType)
    {
        case IdType.Image:
            return "image";
        case IdType.Font:
            return "font";
        case IdType.Text:
            return "text";
        case IdType.Svg:
            return "svg";
        case IdType.Clip:
            return "clip";
        case IdType.Gradient:
            return "gradient";
        case IdType.Texture:
            return "texture";
        case IdType.Hatch:
            return "hatch";
        default:
            Debug.Fail("Unknown id type");
            return "";
    }
}