I use MathML to create some data blocks and I need to insert it throught OpenXML SDK into docx file. I’ve heard it is possible, but I didn’t manage it. Could somebody help me with this problem?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
As far as I know, the OpenXml SDK does not support presentation MathML out of the box.
Instead, the OpenXml SDK supports Office MathML.
So, to insert presentation MathML into a word document we first have
to transform the presentation MathML into Office MathML.
Fortunately, Microsoft provides a XSL file (called MML2OMML.xsl) to transform presentation MathML
into Office MathML. The file MML2OMML.xsl is located under
%ProgramFiles%\Microsoft Office\Office12.In conjunction with the .Net Framework class
XslCompiledTransformwe are able to transform presentation MathML into Office MathML.The next step is to create a
OfficeMathobject from the transformed MathML.The
OfficeMathclass represents a run containing WordprocessingML which shall be handled as though it was Office Open XML Math.For more info please refer to MSDN.
The presentation MathML does not contain font information. To get a nice result
we must add font information to the created
OfficeMathobject.In the last step we have to add the
OfficeMathobject to our word document.In the example below I simply search for the first
Paragraphin aword document called template.docx and add the
OfficeMathobject to the found paragraph.