【发布时间】:2017-03-26 11:03:01
【问题描述】:
我需要使用php自动生成带有数学表达式的word文档。 最好使用 Microsoft 方程、MathType 或 word 的 07+ 方程编辑器。 我尝试使用 phpword 的函数 addObject() 将 MathType *.eps 文件作为 OLE 插入,但它的文件类型不支持。 我该怎么做?
$word = new \PhpOffice\PhpWord\PhpWord();
$section = $word->addSection();
$section->addObject('formulas/Eqn1.eps');
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($word, 'Word2007');
$objWriter->save('docs/helloWorld.docx');
错误:PhpOffice\PhpWord\Exception\InvalidObjectException
如果我尝试添加为数学:
$section->addText('
<w:p w:rsidR="00D14CAF" w:rsidRDefault="00A07C15">
<m:oMathPara>
<m:oMath>
<m:r>
<w:rPr>
<w:rFonts w:ascii="Cambria Math" w:hAnsi="Cambria Math"/>
</w:rPr>
<m:t>XXXXXXXXXXXXXX</m:t>
</m:r>
</m:oMath>
</m:oMathPara>
<w:bookmarkStart w:id="0" w:name="_GoBack"/>
<w:bookmarkEnd w:id="0"/>
</w:p>
');
*.docx 无法打开(错误)
【问题讨论】:
-
请向我们展示您迄今为止尝试过的内容,即发布相关代码。
标签: math docx equation phpword mathtype