Convert FieldEQ to MathML

Is there an API in Words.Java to convert an EQ field to MathML?

eg.

from

eq \f(3x,2)

to

    <math>
      <mfrac>
        <mrow>
          <mn>3</mn>
          <mi>x</mi>
        </mrow>
        <mn>2</mn>
      </mfrac>
    </math>

Here is the Word document containing an EQ field
sample.docx (19.0 KB)

@fzeng2012 Unfortunately, currently, there is no public API that allows converting EQ fields to OfficeMath. I have logged this feature request as WORDSNET-23551 in our defect tracking system. We will keep you informed and let you know once it is available.

Thank you @alexey.noskov

Here is a follow-up question. Is there an API to convert an EQ field to an image?

@fzeng2012 There is not direct way, however, you can do this while conversion to HTML. For example using this code EQ field will be converted to MathML in output HTML:

Document doc = new Document(@"C:\Temp\sample.docx");
HtmlSaveOptions opt = new HtmlSaveOptions();
opt.OfficeMathOutputMode = HtmlOfficeMathOutputMode.MathML;
opt.PrettyFormat = true;
doc.Save(@"C:\Temp\out.html", opt);

and using this code to image:

Document doc = new Document(@"C:\Temp\sample.docx");
HtmlSaveOptions opt = new HtmlSaveOptions();
opt.OfficeMathOutputMode = HtmlOfficeMathOutputMode.Image;
opt.PrettyFormat = true;
doc.Save(@"C:\Temp\out.html", opt);

Thanks @alexey.noskov.

I tried both options. Neither works well for the over-strike(\o) switch of the EQ field.

Comparing with the rendition in Word, the HTML image output is somewhat close but the MathML output is way off. I have attached a test Word doc and the screenshots of the conversion output.

OverStrike.docx (17.7 KB)

image_output.PNG (1.8 KB)
math_ml_output.PNG (1.2 KB)

@fzeng2012 Thank you for reporting the problem to us. It has been logged as WORDSNET-23561. We will keep you informed and let you know once it is resolved.

The issues you have found earlier (filed as WORDSNET-23551) have been fixed in this Aspose.Words for Java 22.9 update also available on Maven.