HtmlSaveOptions.ImageSavingCallback does not trigger when MetafileFormat is set to Svg

Hi,

When converting a DOCX to PDF, we used ImageSavingCallback to record some location information with the image that gets converted.

It worked fine when MetafileFormat is the default Png value but it is no longer triggered when the value is set to Svg.

Code:

var doc = new Document(@".\test.docx");
var htmlSaveOptions = new HtmlSaveOptions
{
    ImageSavingCallback = new HtmlImageSavingCallback(), // my callback class is provided below
    MetafileFormat = HtmlMetafileFormat.Svg // worked find if I changed to .Png
};
doc.Save(@".\out.html", htmlSaveOptions);

and my callback class is

public class HtmlImageSavingCallback : IImageSavingCallback
{
    /// <summary>
    ///     Called when Aspose.Words saves an image to HTML.
    /// </summary>
    public void ImageSaving(ImageSavingArgs args)
    {
        NameToFileNameDictionary[args.CurrentShape.Name] = args.ImageFileName;

        var tag = args.CurrentShape.ParentNode as StructuredDocumentTag;
        if (tag == null)
        {
            tag = args.CurrentShape.ParentNode.ParentNode as StructuredDocumentTag;
            if (tag == null)
            {
                tag = args.CurrentShape.ParentNode.ParentNode.ParentNode as StructuredDocumentTag;
                if (tag == null)
                    return;
            }
        }

        string imageId = tag.Tag.GetTag("LinkedId_", MatchingMethod.StartsWith);
        if (!string.IsNullOrEmpty(imageId))
            imageId = imageId.Substring(9);
        else
            imageId = tag.Id.ToString();

        TagIdToFileNameDictionary[imageId] = args.ImageFileName;
    }

    public Dictionary<string, string> TagIdToFileNameDictionary { get; } = new Dictionary<string, string>();

    public Dictionary<string, string> NameToFileNameDictionary { get; } = new Dictionary<string, string>();
}

The callback retrieves some tags of the content control that contains the EMF image after rendering, and we use the data for some additional processing.

I’ve attached an example docx file for your reference. Can we also trigger the callback when the images are saved as SVG?

test.docx (17.9 KB)

Thanks,

@ServerSide527
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-25299

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.

@ServerSide527 We have completed analysis of the issue. This is not a bug. HtmlSaveOptions.ImageSavingCallback is invoked only when external image resources are written but SVG images can only be embedded into HTML documents as inline code at the moment. It will be possible to save SVG to external files after WORDSNET-16387 issue is closed.

Hi @alexey.noskov

Thanks for the information.

Tracking the image rendering event is an important part of our software workflow and if the SVG event cannot be tracked the behaviour is inconsistent across different images and we cannot use the SVG rendering feature because of that.

Could you please link WORDSNET-16387 to this post, so we can get a notification when this is available?

Thanks,

@ServerSide527 I have linked the topic to WORDSNET-16387.