Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MathML to Docx #2559

Open
KaioSpa opened this issue Jan 27, 2024 · 0 comments
Open

MathML to Docx #2559

KaioSpa opened this issue Jan 27, 2024 · 0 comments

Comments

@KaioSpa
Copy link

KaioSpa commented Jan 27, 2024

Hey, I'm lost here and really need help. I'm sorry if it's obvious and I'm just blind...

I'm trying to convert MathML formulas to docx. I have seen that a merge was made, but I was not able to implement it.

When I try to convert directly to ODText, the formula does not appear, and it just shows the numbers without the formula (10^20 appears as 1020).

$phpWord = new PhpWord();
    $section = $phpWord->addSection();
    Html::addHtml($section, $html, false, false);

    // Save the resulting document to a temporary file
    $tempDoc = tempnam(sys_get_temp_dir(), 'PHPWord');
    $phpWord->save($tempDoc, 'Word2007');

And when trying to use the Formula class, it just returns empty:

$math = new Formula(new Math($mathML));

An example of my MathML element (I extracted the element to try to use the Formula class):
$mathML=<math xmlns="http://www.w3.org/1998/Math/MathML"><mn>4</mn><mi>x</mi><mo>-</mo><mfrac><mrow><mn>3</mn><mo>-</mo><mi>x</mi></mrow><mn>2</mn></mfrac><mo>=</mo><mn>21</mn><mo>&#160;</mo><mo>&#160;</mo><mo>&#160;</mo><mi>e</mi><mo>&#160;</mo><mo>&#160;</mo><mo>&#160;</mo><mfrac><mrow><mi>y</mi><mo>-</mo><mn>3</mn></mrow><mn>2</mn></mfrac><mo>=</mo><mfrac><mn>1</mn><mrow><mi>y</mi><mo>+</mo><mn>2</mn></mrow></mfrac><mo>+</mo><mfrac><mn>3</mn><mn>2</mn></mfrac></math>

Can someone help?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant