OfficeMathRenderer Class

Provides methods to render an individual OfficeMath to a raster or vector image or to a Graphics object.

Inheritance Hierarchy

Namespace:  Aspose.Words.Rendering
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.7.0

Syntax

public class OfficeMathRenderer : NodeRendererBase

The OfficeMathRenderer type exposes the following members.

Constructors

  NameDescription
Public methodCode exampleOfficeMathRenderer
Initializes a new instance of this class.

Properties

  NameDescription
Public propertyCode exampleBoundsInPoints
Gets the actual bounds of the shape in points.
(Inherited from NodeRendererBase.)
Public propertyCode exampleOpaqueBoundsInPoints
Gets the opaque bounds of the shape in points.
(Inherited from NodeRendererBase.)
Public propertyCode exampleSizeInPoints
Gets the actual size of the shape in points.
(Inherited from NodeRendererBase.)

Methods

  NameDescription
Public methodEquals (Inherited from Object.)
Public methodCode exampleGetBoundsInPixels(Single, Single)
Calculates the bounds of the shape in pixels for a specified zoom factor and resolution.
(Inherited from NodeRendererBase.)
Public methodCode exampleGetBoundsInPixels(Single, Single, Single)
Calculates the bounds of the shape in pixels for a specified zoom factor and resolution.
(Inherited from NodeRendererBase.)
Public methodGetHashCode (Inherited from Object.)
Public methodCode exampleGetOpaqueBoundsInPixels(Single, Single)
Calculates the opaque bounds of the shape in pixels for a specified zoom factor and resolution.
(Inherited from NodeRendererBase.)
Public methodCode exampleGetOpaqueBoundsInPixels(Single, Single, Single)
Calculates the opaque bounds of the shape in pixels for a specified zoom factor and resolution.
(Inherited from NodeRendererBase.)
Public methodCode exampleGetSizeInPixels(Single, Single)
Calculates the size of the shape in pixels for a specified zoom factor and resolution.
(Inherited from NodeRendererBase.)
Public methodCode exampleGetSizeInPixels(Single, Single, Single)
Calculates the size of the shape in pixels for a specified zoom factor and resolution.
(Inherited from NodeRendererBase.)
Public methodGetType (Inherited from Object.)
Public methodCode exampleRenderToScale
Renders the shape into a Graphics object to a specified scale.
(Inherited from NodeRendererBase.)
Public methodCode exampleRenderToSize
Renders the shape into a Graphics object to a specified size.
(Inherited from NodeRendererBase.)
Public methodCode exampleSave(Stream, ImageSaveOptions)
Renders the shape into an image and saves into a stream.
(Inherited from NodeRendererBase.)
Public methodCode exampleSave(String, ImageSaveOptions)
Renders the shape into an image and saves into a file.
(Inherited from NodeRendererBase.)
Public methodToString (Inherited from Object.)

Examples

Shows how to measure and scale shapes.
// Open a document that contains an OfficeMath object
Document doc = new Document(MyDir + "Office math.docx");

// Create a renderer for the OfficeMath object 
OfficeMath officeMath = (OfficeMath)doc.GetChild(NodeType.OfficeMath, 0, true);
OfficeMathRenderer renderer = new OfficeMathRenderer(officeMath);

// We can measure the size of the image that the OfficeMath object will create when we render it
Assert.AreEqual(119.0f, renderer.SizeInPoints.Width, 0.2f);
Assert.AreEqual(13.0f, renderer.SizeInPoints.Height, 0.1f);

Assert.AreEqual(119.0f, renderer.BoundsInPoints.Width, 0.2f);
Assert.AreEqual(13.0f, renderer.BoundsInPoints.Height, 0.1f);

// Shapes with transparent parts may return different values here
Assert.AreEqual(119.0f, renderer.OpaqueBoundsInPoints.Width, 0.2f);
Assert.AreEqual(14.2f, renderer.OpaqueBoundsInPoints.Height, 0.1f);

// Get the shape size in pixels, with linear scaling to a specific DPI
Rectangle bounds = renderer.GetBoundsInPixels(1.0f, 96.0f);
Assert.AreEqual(159, bounds.Width);
Assert.AreEqual(18, bounds.Height);

// Get the shape size in pixels, but with a different DPI for the horizontal and vertical dimensions
bounds = renderer.GetBoundsInPixels(1.0f, 96.0f, 150.0f);
Assert.AreEqual(159, bounds.Width);
Assert.AreEqual(28, bounds.Height);

// The opaque bounds may vary here also
bounds = renderer.GetOpaqueBoundsInPixels(1.0f, 96.0f);
Assert.AreEqual(159, bounds.Width);
Assert.AreEqual(18, bounds.Height);

bounds = renderer.GetOpaqueBoundsInPixels(1.0f, 96.0f, 150.0f);
Assert.AreEqual(159, bounds.Width);
Assert.AreEqual(30, bounds.Height);

See Also