XML API - pdx:addMathEquation

pdx:addMathEquation

Inserts a math equation in OMML or MathML format.

Note

You are reading the XML API documentation. For the PHP API method please go to addMathEquation.

Description

Element definition

6
 
1
<pdx:content>
2
    <pdx:addMathEquation pdx:type="docx|omml|mathml" pdx:wordFragmentName="" pdx:align="left|center|right" pdx:color="" pdx:bold="" pdx:fontSize="" pdx:italic="" pdx:underline="">
3
        <pdx:data pdx:dataId="" pdx:dataType="text">path to docx|<![CDATA[OMML code]]>|<![CDATA[MML code]]></pdx:data>
4
    </pdx:addMathEquation>
5
</pdx:content>
6

Adds a math equation to the DOCX.

Attributes and sub-elements

equation

The OMML equation code.

type

The equation type: docx, omml or mathml.

align

left, center, right

bold

color

ffffff, ff0000...

fontSize

8, 9, 10...

italic

underline

single...

Code samples

Example #1

config.xml

7
 
1
<?xml version="1.0" encoding="UTF-8"?>
2
<pdx:document xmlns:pdx="http://www.phpdocx.com/main">
3
    <pdx:config>
4
        <pdx:output pdx:name="output" pdx:type="docx" />
5
    </pdx:config>
6
</pdx:document>
7

content.xml

14
 
1
<?xml version="1.0" encoding="UTF-8"?>
2
<pdx:document xmlns:pdx="http://www.phpdocx.com/main">
3
    <pdx:content>
4
        <pdx:addText>
5
            <pdx:textRun>
6
                <pdx:data pdx:dataId="" pdx:dataType="text">Extract a math equation from an external Word file:</pdx:data>
7
            </pdx:textRun>
8
        </pdx:addText>
9
        <pdx:addMathEquation pdx:type="docx">
10
            <pdx:data pdx:dataId="" pdx:dataType="text">/var/www/phpdocx/samples/files/math.docx</pdx:data>
11
        </pdx:addMathEquation>
12
    </pdx:content>
13
</pdx:document>
14

settings.xml

6
 
1
<?xml version="1.0" encoding="UTF-8"?>
2
<pdx:document xmlns:pdx="http://www.phpdocx.com/main">
3
    <pdx:settings>
4
    </pdx:settings>
5
</pdx:document>
6

PHP code

x
 
1
require_once 'path_to_phpdocx/classes/CreateDocx.php';
2
3
$docx = new XMLAPI('config.xml');
4
$docx->setDocumentProperties('settings.xml');
5
$docx->addContent('content.xml');
6
7
$docx->render();

The resulting Word document looks like:

­
­