Images inside OMath/OMathPara missed when convert range to EMF

Hi Aspose support,
In our product we have functionality that converts equations’ content to images and replace OMathPara/OMath node with resulted image shape.
Similar to what MS Word do when converts DOCX document with equations into DOC/RTF format.
After testing this approach we were faced with the issue when an Equation has image/OLE object inside OMath/OMathPara node, after conversion the node into EMF images/OLE objects are missed from resulted image.

Please see sample documents and screenshots of the problem:
Images inside OMath:
Equations with images.zip (2.3 MB)
See results:
OMathWithImages.png (133.2 KB)
Converted by Aspose document:
Equations with images_Converted.zip (10.8 KB)

OLE objects inside OMath:
Equations with OLE objects.zip (992.9 KB)

See results:
OMathWithOLE.png (40.6 KB)

Converted by Aspose document:
Equations with OLE objects_Converted.zip (18.4 KB)

Expected behavior for both cases - document should look similar as it looks after resaving DOCX into DOC by Word (Word converts Equations into images).

Codes:

 private void ReplaceFormulas(Document doc, ImageSaveOptions options, DocumentBuilder builder)
        {
            NodeCollection mathCollection = doc.GetChildNodes(NodeType.OfficeMath, true);

            // Loop from last one to first one
            for (int i = mathCollection.Count - 1; i >= 0; i--)
            {
                try
                {
                    OfficeMath math = (OfficeMath)mathCollection[i];

                    // if node is MathPara or node is Inline Math with parent which is not Math Node, then replace with image
                    // Needs to differentiate inline and display formulas
                    if ((math.MathObjectType == MathObjectType.OMathPara) ||
                        ((math.MathObjectType == MathObjectType.OMath) && (math.ParentNode?.NodeType != NodeType.OfficeMath)))
                    {
                        using (MemoryStream stream = new MemoryStream())
                        {
                            math.GetMathRenderer().Save(stream, options);
                            SizeF mathSize = math.GetMathRenderer().SizeInPoints;

                            builder.MoveTo(math);

                            Shape imageShape = builder.InsertImage(stream, mathSize.Width, mathSize.Height);
                           
                            math.Remove();
                        }
                    }
                }
                catch
                {
                    // Ignore exception and continue process math collection
                }
            }
        }


The code which calls this method:
        public void Replace()
        {
            try
            {


                // Save Equations into EMF format as optimal format for them
                ImageSaveOptions optionsEmf = new ImageSaveOptions(SaveFormat.Emf);
                optionsEmf.MetafileRenderingOptions.ScaleWmfFontsToMetafileSize = true;
                optionsEmf.MetafileRenderingOptions.RenderingMode = MetafileRenderingMode.Vector;
                optionsEmf.UseGdiEmfRenderer = false;

                DocumentBuilder builder = new DocumentBuilder(_doc);
                ReplaceFormulas(_doc, optionsEmf, builder);
            }
            catch (Exception e)
            {
                throw new DrawingReplacerException(e.Message);
            }
}

Tested on Aspose.Words.dll v19.8.

Could you help with solving this problem?
The case when an Equation has only Image inside can be solved on our side (by replacing objects), but if there are both and OMath and Shape objects inside equation, we cannot solve it. So, ideally it should be handled in Aspose, as it’s done in MS Word.
Thanks in advance.

@licenses,

You can convert your document to image using Aspose.Words. Could you please share what is your requirement for OfficeMath to image conversion? Please also share your expected output document. We will then provide you more information about your query.

@tahir.manzoor,
Conversion of whole document to image does not work for us.
Required: convert Equation with inner content to image and replace it in document, so instead of Equation object there will be shape image. OfficeMath should be converted to image and should look similar to what MS Word conversion from DOCX to DOC does with OMath.
Please see source document and resulted document with expected result for
Images inside OfficeMath: Equations with images.zip (6.4 MB)
OLE Objects inside OfficeMath:Equations with OLE objects.zip (3.0 MB)

I hope this clarify my request.
Thanks

@licenses,

We have tested the scenario and have managed to reproduce the same issues at our side. For the sake of correction, we have logged these problems in our issue tracking system as WORDSNET-19145 and WORDSNET-19146. You will be notified via this forum thread once these issues are resolved.

We apologize for your inconvenience.

The issues you have found earlier (filed as WORDSNET-19146) have been fixed in this Aspose.Words for .NET 23.5 update also available on NuGet.

The issues you have found earlier (filed as WORDSNET-19145) have been fixed in this Aspose.Words for .NET 23.5 update also available on NuGet.