Forum


Replies: 4   Views: 353
Formula inside table
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by ArtemKo  · 19-02-2025 - 03:21

Hello!This code creates a corrupted file. 
What could be the problem? 

require_once 'classes/CreateDocx.php';
$docx = new CreateDocx();
$math = new WordFragment($docx);
$math->addMathEquation(
'<m:oMathPara>
       <m:oMath><m:r><m:t>±∞=~×</m:t></m:r></m:oMath>
   </m:oMathPara>', 'omml'
);
$valuesTable = array(
    array(
        $math,
    )
);
$docx->addTable($valuesTable);
$docx->createDocx('output');

Posted by admin  · 19-02-2025 - 05:56

Hello,

What version and license of phpdocx are you using?

Your username doesn't have any license tied. Please send to contact[at]phpdocx.com the username or email address of the phpdocx account that purchased the license you are using.

Regards.

Posted by ArtemKo  · 20-02-2025 - 04:55

Hello!
I am using version 15 (trial) to explore the product's capabilities.
I do not have a paid subscription yet.

Posted by admin  · 20-02-2025 - 07:03

Hello,

Please note that the trial package doesn't include technical support. Please purchase a license to get technical support, remove trial watermarks, use phpdocx on a production server, and get all available features (https://www.phpdocx.com/features).

Using the current stable version of phpdocx, to add math equations as block WordFragments, you need to add them in a paragraph. For example:

$docx = new CreateDocx();

$math = new WordFragment($docx);
$math->addMathEquation(
    '<m:oMathPara>
        <m:oMath><m:r><m:t>∪±∞=~×</m:t></m:r></m:oMath>
    </m:oMathPara>', 'omml'
);
$textMath = new WordFragment($docx);
$textMath->addText([$math]);

$valuesTable = array(
    array(
        $textMath,
    )
);
$docx->addTable($valuesTable);

$docx->createDocx('output');

The next stable release of phpdocx won't have this requirement and adding math equations as block WordFragments will be possible without using an extra paragraph WordFragment.

Regards.

Posted by ArtemKo  · 20-02-2025 - 07:22

Yes, that works, thanks!
Using an additional WordFragment does seem unnecessary, since links and images now do without it.
Good luck!