Word Math element append

I’m trying to append some elements to a word document in code. I need to append a math element, and I can’t find any good examples of how to do that. My goal is to use the IReplacingCallback to find math placeholders text elements in the document and replace them somehow with Aspose.Words.Math.OfficeMath elements. Any help would be greatly appreciated.

Hi James,

Thanks for your query. Equations in your document are represented by OfficeMath objects in DOM. You can try overriding the following methods.

VisitOfficeMathStart Method
VisitOfficeMathEnd Method

You can also use following code snippet for your requirement.

Document doc = new Document(MyDir + "Sample .docx");
NodeCollection nodes = doc.GetChildNodes(NodeType.OfficeMath, true);
foreach (OfficeMath math in nodes)
{
    foreach (Run run in math.GetChildNodes(NodeType.Run, true))
    {
        // Your code
    }
}

Please let us know if you have any more queries.

Let’s assume that the document has no existing child nodes of type OfficeMath. How then can I insert a new OfficeMath element into a document using Aspose.Words?

Thanks,
-James

Hi James,

Thanks for your query. Unfortunately, Aspose.Words does not support the requested feature at the moment. However, I have logged this feature request as WORDSNET-6987 in our issue tracking system. You will be notified via this forum thread once this feature is available.

Please read following documentation link for your kind reference.
https://reference.aspose.com/words/net/aspose.words.math/officemath/

We apologize for your inconvenience.