We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Convert OMML (OfficeMath) to MathML XML String

Dear,

We would like to use Aspose.Word product to extract OMML (OfficeMath) from DOCX document and convert to MathML XML in String or Java object. Is there any way to do that?

If this is not the case, if there any possibility to access the OMML “raw XML” representation? This forum thread doesn’t have an answer. I’m asking this because in that case I would be able to perform an XSLT transformation and get the MathML XML String representation.

Just to clarify, I do not want to instantiate nor modify the OfficeMath object nor convert it into image.

If accesing raw xml is not an option too, I understand that in order to retrieve the OMML XML directly using the OfficeMath I will need to iterate through all the node elements and create a tag based on MathObjectType, is that correct?

Many thanks for your support,

David Hernández

@dhernabe,

Thanks for your inquiry. Please use the following code example to convert OfficeMath to MathML. Hope this helps you.

Document doc = new Document(MyDir + "Input.docx");
OfficeMath officeMath = (OfficeMath)doc.getChild(NodeType.OFFICE_MATH,0, true);

HtmlSaveOptions options = new HtmlSaveOptions();
options.setOfficeMathOutputMode(HtmlOfficeMathOutputMode.MATH_ML);

System.out.println(officeMath.toString(options));
1 Like

Thanks you very much for your reply @tahir.manzoor.
It was everything I needed. The result MathML String is contained in tags, as it is intended for HTML. However, this is not a problem as they are easy removable.

@dhernabe,

Thanks for your feedback. It is nice to hear from you that your problem has been resolved. Please let us know if you have any more queries.