OfficeMath class

OfficeMath class

Represents an Office Math object such as function, equation, matrix or alike. Can contain child elements including runs of mathematical text, bookmarks, comments, other OfficeMath instances and some other nodes. To learn more, visit the Working with OfficeMath documentation article.

Remarks

In this version of Aspose.Words, OfficeMath nodes do not provide public methods and properties to create or modify a OfficeMath object. In this version you are not able to instantiate aspose.words.math nodes or modify existing except deleting them.

OfficeMath can only be a child of Paragraph.

Inheritance: OfficeMathCompositeNodeNode

Properties

NameDescription
countGets the number of immediate children of this node.
(Inherited from CompositeNode)
custom_node_idSpecifies custom node identifier.
(Inherited from Node)
display_typeGets/sets Office Math display format type which represents whether an equation is displayed inline with the text or displayed on its own line.
documentGets the document to which this node belongs.
(Inherited from Node)
first_childGets the first child of the node.
(Inherited from CompositeNode)
has_child_nodesReturns True if this node has any child nodes.
(Inherited from CompositeNode)
is_compositeReturns True if this node can contain other nodes.
(Inherited from Node)
justificationGets/sets Office Math justification.
last_childGets the last child of the node.
(Inherited from CompositeNode)
math_object_typeGets type OfficeMath.math_object_type of this Office Math object.
next_siblingGets the node immediately following this node.
(Inherited from Node)
node_typeReturns NodeType.OFFICE_MATH.
parent_nodeGets the immediate parent of this node.
(Inherited from Node)
parent_paragraphRetrieves the parent Paragraph of this node.
previous_siblingGets the node immediately preceding this node.
(Inherited from Node)
rangeReturns a Range object that represents the portion of a document that is contained in this node.
(Inherited from Node)

Methods

NameDescription
accept(visitor)Accepts a visitor.
accept_end(visitor)Accepts a visitor for visiting the end of the office math.
accept_start(visitor)Accepts a visitor for visiting the start of the office math.
append_child(new_child)Adds the specified node to the end of the list of child nodes for this node.
(Inherited from CompositeNode)
clone(is_clone_children)Creates a duplicate of the node.
(Inherited from Node)
get_ancestor(ancestor_type)Gets the first ancestor of the specified object type.
(Inherited from Node)
get_ancestor(ancestor_type)Gets the first ancestor of the specified NodeType.
(Inherited from Node)
get_child(node_type, index, is_deep)Returns an Nth child node that matches the specified type.
(Inherited from CompositeNode)
get_child_nodes(node_type, is_deep)Returns a live collection of child nodes that match the specified type.
(Inherited from CompositeNode)
get_math_renderer()Creates and returns an object that can be used to render this equation into an image.
get_text()Gets the text of this node and of all its children.
(Inherited from Node)
index_of(child)Returns the index of the specified child node in the child node array.
(Inherited from CompositeNode)
insert_after(new_child, ref_child)Inserts the specified node immediately after the specified reference node.
(Inherited from CompositeNode)
insert_before(new_child, ref_child)Inserts the specified node immediately before the specified reference node.
(Inherited from CompositeNode)
next_pre_order(root_node)Gets next node according to the pre-order tree traversal algorithm.
(Inherited from Node)
node_type_to_string(node_type)A utility method that converts a node type enum value into a user friendly string.
(Inherited from Node)
prepend_child(new_child)Adds the specified node to the beginning of the list of child nodes for this node.
(Inherited from CompositeNode)
previous_pre_order(root_node)Gets the previous node according to the pre-order tree traversal algorithm.
(Inherited from Node)
remove()Removes itself from the parent.
(Inherited from Node)
remove_all_children()Removes all the child nodes of the current node.
(Inherited from CompositeNode)
remove_child(old_child)Removes the specified child node.
(Inherited from CompositeNode)
remove_smart_tags()Removes all SmartTag descendant nodes of the current node.
(Inherited from CompositeNode)
select_nodes(xpath)Selects a list of nodes matching the XPath expression.
(Inherited from CompositeNode)
select_single_node(xpath)Selects the first Node that matches the XPath expression.
(Inherited from CompositeNode)
to_string(save_format)Exports the content of the node into a string in the specified format.
(Inherited from Node)
to_string(save_options)Exports the content of the node into a string using the specified save options.
(Inherited from Node)

Examples

Shows how to set office math display formatting.

doc = aw.Document(MY_DIR + "Office math.docx")

office_math = doc.get_child(aw.NodeType.OFFICE_MATH, 0, True).as_office_math()

# OfficeMath nodes that are children of other OfficeMath nodes are always inline.
# The node we are working with is the base node to change its location and display type.
self.assertEqual(aw.math.MathObjectType.O_MATH_PARA, office_math.math_object_type)
self.assertEqual(aw.NodeType.OFFICE_MATH, office_math.node_type)
self.assertEqual(office_math.parent_node, office_math.parent_paragraph)

# Change the location and display type of the OfficeMath node.
office_math.display_type = aw.math.OfficeMathDisplayType.DISPLAY
office_math.justification = aw.math.OfficeMathJustification.LEFT

doc.save(ARTIFACTS_DIR + "Shape.office_math.docx")

See Also