Good Morning,
I need some assistance in regards to the API and how Aspose handles MathML in word Documents.
I have compiled a minimalistic case where the equation I am trying to write into the Document produces a corrupt word file (the equation is not displayed as it should and the document behaviour is erroneous)
static String mathML = "<math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\" alttext=\"\\begin{array}{l}\\displaystyle "
+ "\\sqrt{(\\hat{r'_k)}}\\end{array}\">\n"
+ " <mtable columnalign=\"left\" rowspacing=\"4pt\" columnspacing=\"1em\">\n"
+ " <mtr>\n"
+ " <mtd>\n"
+ " <mstyle displaystyle=\"true\" scriptlevel=\"0\">\n"
+ " <msqrt>\n"
+ " <mo stretchy=\"false\">(</mo>\n"
+ " <mrow class=\"MJX-TeXAtom-ORD\">\n"
+ " <mover>\n"
+ " <mrow>\n"
+ " <msubsup>\n"
+ " <mi>r</mi>\n"
+ " <mi>k</mi>\n"
+ " <mo>′</mo>\n"
+ " </msubsup>\n"
+ " <mo stretchy=\"false\">)</mo>\n"
+ " </mrow>\n"
+ " <mo stretchy=\"false\">^<!-- ^ --></mo>\n"
+ " </mover>\n"
+ " </mrow>\n"
+ " </msqrt>\n"
+ " </mstyle>\n"
+ " </mtd>\n"
+ " </mtr>\n"
+ " </mtable>\n"
+ "</math>";
public static void main(String[] args)
{
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Java
// The path to the documents directory.
String dataDir = "./";
// Load the document.
Document doc = null;
try
{
doc = new Document();
}
catch (Exception e)
{
throw new RuntimeException(e);
}
DocumentBuilder builder = new DocumentBuilder(doc);
builder.write("hello world");
try
{
builder.insertHtml(mathML);
}
catch (Exception e)
{
throw new RuntimeException(e);
}
try
{
doc.save(dataDir + "output.docx");
}
catch (Exception e)
{
throw new RuntimeException(e);
}
}
The Square Root is missing from the equation and if you access the document from production, you can see how the document is corrupted when opening/saving/exiting.
For reference, I have attached the expected equation result as a screenshot :
The latex formula is the following: \sqrt{(\hat{r'_k})}
This is the resulting document in production: Aspose Support-v4-20230419_072251.docx (19.5 KB)