Forum


Replies: 3   Views: 3755
Addmathequation() problem when inserting into list?
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 jiri111  · 27-02-2015 - 17:07

Hi anyone who can help ;-) This SW is very nice, we were considering to buy it but for some reason the crucial feature for us doesn't work :-( Is anyone able to tell me why or what am I missing? Here is what I need to achieve: - put a math equation in a list in order to: a) style it because list can be styled, centered, etc. b) use it in ordered list Simple comparison: - Method addText can be styled too, but this doesn't accept math equations of course. - addMathEquation() works well when only when not used with Word fragment in a list I created following test case, is anyone able to help me? Configuration returned by check.php is as follows: PHP version is 5.4.24 Zip support is enabled. DOM support is enabled. XML support is enabled. Tidy support is enabled. Tried on both Windows and Linux system -> still same result. Test case: --- <?php /* Put your path to phpdocx here */ require_once ('inc/phpdocx/classes/CreateDocx.inc'); $equation = '<math xmlns="http://www.w3.org/1998/Math/MathML"><mfrac><msup><mi>x</mi><mn>3</mn></msup><msup><mi>z</mi><mn>4</mn></msup></mfrac></math>'; $docx = new CreateDocx(); $listOptions = array(); $listOptions[0]['type'] = 'upperLetter'; $listOptions[0]['format'] = '%1.'; $listOptions[0]['font'] = 'Arial'; $docx->createListStyle('ftoptions', $listOptions); $options = array('font' => 'Arial','fontSize' => 14); /* Uncomment following code to see: 1) It doesn't work - equation is not displayed 2) Word says file is broken upon opening $htmlData = new WordFragment ($docx); $htmlData->embedHTML ("Some text"); $htmlData->addMathEquation ($equation); $items[] = $htmlData; $docx->addList ($items,'ftoptions',$options); */ /* Following code works, but: - cannot be styled or put into list (equation is always in center, not using bullet list, etc. - equation is not on the same line as text * Comment this out when you uncomment previous code */ $docx->embedHTML ("Some text"); $docx->addMathEquation ($equation,'mathml'); $docx->createDocxAndDownload ('/tmp/file_test'); ?> --- Cheers for any hint, Jiri

Posted by admin  · 02-03-2015 - 11:16

Hello, To do that you need to use the OMML standard. The MathML is transformed through an XSL that you can change using a paymente license. Regards.

Posted by jiri111  · 02-03-2015 - 17:30

Hi "admin" ;-) Thanks for your answer. So let's say we consider to buy it therefore I have 3 more small questions before proceeding. 1) I assume the XSL file you talk about is the one MML2OMML.XSL in XSL folder, correct? It shouldn't be that hard to change that to a possibility to transform MATH into OMML, correct? Or in other words how long it could take (I didn't check it). Sorry I didn't find this in your documentation at all (with converting OMML to MATHML) therefore better to ask so I know what I can expect :-) 2) You are saying that when MathML is transformed into OMML then equation can be inserted as a line of bullet list in word, using method addList() which accepts WordFragment() subobjects, is this correct please? 3) Is it possible to add an image (using addImage() method) into bullet list as well? 4) Let's say I would like to insert very simple equation like x^2 into a bullet list with HTML code as: <b>Test</b> - here equation follows. Will it be on same line (I experienced some problems like this, but maybe I overlooked something). Thank you, Jiri

Posted by admin  · 03-03-2015 - 07:41

Hello, You need to use OMML tags or 'clean' the output of the MathML, changing the XSL or the string output. About images, yes you can add them in lists. Please read the documentation available on: http://www.phpdocx.com/documentation Regards.