Free Support Forum - aspose.com

OMML and MathML

How do I extract OMML or MathML from an OfficeMath object?

Hi Alex,


Thanks for your inquiry. Equations in your document are represented by OfficeMath objects in DOM. You can extract text of OfficeMath nodes as shown below. If you want to convert OOML or MathML into images, please convert your document into html file format. This workaround converts OOML or MathML into images. It would be great if you please share some more detail about your query. Once we have exact information about your query, we will provide you more information.


<span style=“font-size:
10.0pt;font-family:“Courier New”;color:#2B91AF;mso-no-proof:yes”>Document<span style=“font-size:10.0pt;font-family:“Courier New”;mso-no-proof:yes”> doc = new Document(MyDir

  • “in.docx”);<o:p></o:p>

foreach (OfficeMath om in doc.GetChildNodes(NodeType.OfficeMath, true))

{

Console.Write(om.GetText());

}

doc.Save(MyDir + "out.html");

Hello again Tahir,


That will simply get the text value of the nodes. I am asking for the markup (OMML).

To quote from this wikipedia page: "With Microsoft’s release of Microsoft Office 2007 and the Office Open XML file formats, they introduced a new equation editor which uses a new format, “Office Math Markup Language” (OMML)."

Once I have the OMML, I can use other (non-Aspose) libraries to convert this to MathML, which is what we ultimately need.

Hi Alex,


Thanks for sharing the detail. If I understood you correctly, you want to convert OfficeMath nodes into MathML as shown in attached image file. Please confirm this.

Hi Alex,


Thanks for your inquiry. I am in communication with the development team and will update you as soon as I have information on this.

Best regards,

Hi Awais (or other Aspose support members reading this thread)

How is this enquiry progressing? Identify a way to properly support Math equations converting documents is a high priority feature for us. Exporting to images just won’t cut it unfortunately and is not a solution for us.

Rodney Tamblyn
CEO | OceanBrowser Ltd
http://ob3.cc @ocnb3

Hi Rodney,


Thanks for your inquiry and sorry for the delayed response.

Just to clarify a bit, an OfficeMath object in Word document can be equation, function, matrix or one of other mathematical objects. It can be a collection of mathematical object and also can contain some non-mathematical objects such as runs of text.

When you convert your Word document containing OfficeMath objects to other formats e.g. DOCX, DOC, ODT, RTF, DOCM etc, Aspose.Words preserves the OfficeMath equation in output documents; however, if you open DOC document with Microsoft Word application, it renders OfficeMath equation as a simple image. This is entirely by design and you will not be able to edit the equations in DOC until the document is converted back to a newer file format such as DOCX.

Secondly, regarding your request of having an API for accessing ‘raw XML’ representation (MathML) of an OfficeMath node, I have not heard back from our development team yet. Please spare us a bit more time; our development team will investigate the feasibility of this API and we will keep you posted on the progress here. We apologize for your inconvenience.

Please let me know if I can be of any further assistance.

Best regards,
Hi Rodney,

Thanks for your patience.

I have received response from our development team and regret to share with you that we won't be able to provide access to the raw-XML through Aspose.Words' API. The whole point of Aspose.Words' API is to hide complexities and internals of file formats from end users. However, we strive to include a decent API to create or modify an OfficeMath object sometime in the future. We will inform you as soon as this API is available. We apologize for any inconvenience.

If we can help you with anything else, please feel free to ask.

Best regards,

Hi Awais,


I don’t think accessing a brilliant method of representing complicated mathematical equations such as MathML would fall into the “internal complexities that need to be hidden from end users” class, but okay…

Do you have any solutions for us to use in the meantime? We need to be able to create, read, update and delete these objects, both in documents we are creating using Aspose.Words and in pre-existing documents we are accessing using Aspose.Words. This is one of the reasons we purchased a license. It was quite a shock to realise you don’t support this already.

If the absolute best you can offer us is to save the document in <2007 format to convert the OfficeMath object to an image, please let me know asap.

Cheers

Hi Alex,


Thanks for your inquiry.

In this version of Aspose.Words, OfficeMath nodes do not provide public methods and properties to create or modify a OfficeMath object. In this version you are not able to instantiate Aspose.Words.Math nodes or modify existing except deleting them. For example, please see the following code to delete an OfficeMath node:
Document doc = new Document(“c:\temp\x.docx”);

Node[] equations = doc.getChildNodes(NodeType.OFFICE_MATH, true).toArray();
OfficeMath eq = (OfficeMath)equations[0];
eq.removeAllChildren();
eq.remove();

doc.save(“C:\Temp\out.docx”);

If we can help you with anything else, please feel free to ask.

Best regards,

Could you please ask somebody else to answer my last post? Preferably from your Auckland office?


Thanks

Hi Alex,


Thanks for your request and sorry for the delayed response. We are currently discussing this matter with our development team leader and will get back to you with more information shortly.

Best regards,

The issues you have found earlier (filed as ) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by MuzammilKhan