We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Can I Import a MathML Equation into Aspose.Slides MathPortion in Java?

Hi there,

Using Aspose.Slides for Java, I am writing a tool to convert fragments of HTML into slides. One issue I am struggling with is the conversion the MathML. I am currently using MathRadical, MathFraction etc for conversion. This proves to be very time consuming as there are many MathML tags and they don’t fit neatly into the Aspose.Slides math model.

I am wondering:

  1. Is there a way to import MathML XML into an Aspose.Slides object?
  2. If not, using the XSLT script included in MS office distribution, I can convert MathML into OfficeMath. Is there a way to import an OfficeMath XML into an Aspose.Slides object?

If none of the above works, is there another way to achieve my goal?


Fan Zeng

Thank you for contacting support and for your questions.

It looks like Aspose.Slides does not provide the features you requested yet. Could you please share some sample data or files that you would like to import into PowerPoint presentations? We will then plan to implement features for your purposes shortly.

Attached please find a sample html file.sample.7z (607 Bytes)

While waiting for possible future enhancements from Aspose, I am writing code to convert MathML to PowerPoint equation. In the APIs in Aspose.Slides, I found partial support for the attributes in MathML tag menclose. Details for the tag can be found at https://www.w3.org/TR/MathML3/chapter3.html#presm.menclose.

I was able to implement “left” , “right” , “top” , “bottom” and “box” and a few "strike"s, how I did not find anything in Aspose for the default “longdiv”, and “roundedbox” and “circle” and a few others.

Did I miss some APIs?

I’ve added a ticket with ID SLIDESJAVA-38946 to our issue tracking system. Our development team will consider importing MathML equations from HTML documents. We will inform you of any progress.

Unfortunately, I have not found such a feature. Could you please also share sample data?

I need more details on this to help you properly.

The details are in the attached word documentmenclose.docx (16.7 KB)

Here is a screenshot of the content
image.png (17.8 KB)

Please share a code example that demonstrates the problem.

The following produces a letter “a” in a square box with open top, as shown in the image. However MathBorderBox does not seem to support a circle or a phasorangle.

       MathBorderBox mathBorderBox = new MathBorderBox(new MathematicalText("a"));

image.png (415 Bytes)

Thank you for the code example.

Could you also specify all the math elements that Aspose.Slides should support for your purposes?

The MathML element is “menclose”. Here is the official spec.

Thank you for the additional information. I’ve added a ticket with ID SLIDESJAVA-38947 to our issue-tracking system. Our developers will consider implementing the remaining features you specified in the menclose element. You will be notified when a new release of Aspose.Slides with a fix is published.

Thank you for the help!

Thank you for using Aspose.Slides.

Our development team has considered using of enclose expressions like “menclose” from MathML. To work with mathematical expressions, PowerPoint uses OMML, which is similar to MathML, but with a number of differences. Unfortunately, OOML has no analogs for “menclose”. You can verify this for yourself by trying to create a similar element using PowerPoint.

Thanks for the update.

The issues you found earlier (filed as SLIDESJAVA-38946) have been fixed in Aspose.Slides for Java 23.1 (JAR).
You can check all fixes on the Release Notes page.
You can also find the latest version of our library on the Product Download page.

Is the issue resolved or still struggling? :thinking:
I have done a little bit of research on it and I found this answer…It does not natively support importing MathML equations into a MathPortion. However, you may be able to convert a MathML equation to a different format (such as a PNG image) and then insert that image into a slide using Aspose.Slides. Alternatively, you can convert MathML to a vector format like SVG and then insert it in the slide as an image.

Thanks for the suggestion.

Because PowerPoint is not a flow document format, it is hard to mix images with text. Math formulas in images can not be part of normal paragraphs. While your suggestions will work in many situations, it does not work for my use case.

I will to test the new release Aspose.Slides for Java 23.1.

Please let us know if you run into any issues again.

I tried out release 23.1 and got mixed results for my use cases.

On the one hand it handles fractions (mfrac), radicals (mroot) and summations (munderover) very well.

On the other hand it does not render arrows(mover + →) and harpoons (mover + ⇀) well. It does not do boxes (menclose) well either. It does not handle delimiters at all (mfenced).

I am attaching the following in a zip file for your reference:

inputMath.xml: MathML fragments. You may view the rendered formula using https://codepen.io/bqlou/pen/yOgbmb
Htmlmport.pptx: PPT generated with IParagraphCollection.addFromHtml(String)
MathApi: PPT generated with the math APIs provided in Aspose.Slides.

forum.zip (79.7 KB)