How to handle OLE formula when converting Word to HTML

I want to convert Word to HTML, and the new formula can be created by setting
options. setOfficeMathOutputMode (HtmlOfficeMathOutputMode. MATH_ML);

I can ensure that it is converted to a mathml string, which will enable me to perform formula restoration and editing in the future. But if it is an ole formula, such as a mathtype type formula, it can only be converted to an image. Is there a way to convert this format of formula to mathml as well

@zhengkai

When converting Word documents to HTML, handling OLE formulas, such as those created with MathType, can be challenging. By default, these OLE formulas are converted to images during the conversion process. However, if you want to convert Office Math objects to MathML, you can use the setOfficeMathOutputMode method with the HtmlOfficeMathOutputMode.MATH_ML option.

Unfortunately, OLE objects like MathType formulas do not have a direct conversion path to MathML. They are typically rendered as images because they are embedded objects that do not retain their mathematical structure in a way that can be converted to MathML.

If you need to ensure that all mathematical content, including OLE formulas, is editable in the future, you might consider the following approaches:

  1. Manual Conversion: After converting the document, you could manually replace the images of OLE formulas with MathML representations if you have access to the original mathematical expressions.

  2. Alternative Tools: Explore other libraries or tools that might offer better support for converting OLE objects to MathML, although this may require additional integration work.

  3. Feedback to Aspose: If this is a critical feature for your workflow, consider providing feedback to Aspose regarding the need for better support for OLE formula conversion to MathML.

For your current implementation, ensure you set the HtmlSaveOptions correctly to handle Office Math as follows:

Document doc = new Document("path/to/your/document.docx");
HtmlSaveOptions saveOptions = new HtmlSaveOptions();
saveOptions.setOfficeMathOutputMode(HtmlOfficeMathOutputMode.MATH_ML);
doc.save("output.html", saveOptions);

This will convert Office Math objects to MathML, but keep in mind that OLE objects will still be rendered as images.

If you have further questions or need assistance with specific scenarios, feel free to ask!

@zhengkai No, unfortunately, there is no way to convert OLE formulas to mathml using Aspose.Words.