Aspose.Words Java MathML conversion very slow

I am using the code in the following post to convert math equations in OfficeMath to MathML.

In my sample word doc, each equation takes between a quarter to a half second to convert. For a document with 20 the running time is more than 5 seconds.

Is there a way to speed up the conversion?

All equations are very simple. Here are a few examples in MathML.

<math>
  <mi mathvariant="bold-italic">D</mi>
  <mfenced separators="|">
    <mrow>
      <mn mathvariant="bold-italic">3</mn>
      <mo mathvariant="bold-italic">,</mo>
      <mn mathvariant="bold-italic">10</mn>
    </mrow>
  </mfenced>
</math>

<math>
  <mn>97</mn>
  <mo>.</mo>
  <mn>5</mn>
  <mo>%</mo>
</math>

@fzeng2012,

Have you also tried the latest (21.9) version of Aspose.Words for Java on your end? In case the problem still remains, then please ZIP and upload your source Word document (you are getting this problem with) here for testing. We will then investigate the issue on our end and provide you more information.

Thanks for the quick response. Yes I am already on the latest version 21.9.

I will upload a simple word document with 20 fractions and a Java problem showing the operation I intend to do.

In the Java test, running through the 20 fraction equations takes about 10 seconds.

omath.zip (10.7 KB)

@fzeng2012,

In this case, the problem simply occurs because you are using Aspose.Words for Java in evaluation mode. Please first apply license before you start Document processing:

public class AsposePerfTest extends DocumentVisitor {
    public static void main(String[] args) {
        try {
            License lic = new License();
            lic.setLicense("C:\\temp\\license.lic");
        } catch (Exception ex) {
        }

        InputStream inputStream = AsposePerfTest.class.getResourceAsStream("/OMath2MML.docx");
        long start = System.currentTimeMillis();
        try {
            Document doc = new Document(inputStream);
            ...
            ...

After applying a license the performance issue was resolved. Thank you for the help!

1 Like