Aspose::Words::Rendering::OfficeMathRenderer Class Reference

Detailed Description

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

Examples

Shows how to measure and scale shapes.

auto doc = MakeObject<Document>(MyDir + u"Office math.docx");
auto officeMath = System::DynamicCast<OfficeMath>(doc->GetChild(NodeType::OfficeMath, 0, true));
auto renderer = MakeObject<OfficeMathRenderer>(officeMath);
// Verify the size of the image that the OfficeMath object will create when we render it.
ASSERT_NEAR(119.0f, renderer->get_SizeInPoints().get_Width(), 0.2f);
ASSERT_NEAR(13.0f, renderer->get_SizeInPoints().get_Height(), 0.1f);
ASSERT_NEAR(119.0f, renderer->get_BoundsInPoints().get_Width(), 0.2f);
ASSERT_NEAR(13.0f, renderer->get_BoundsInPoints().get_Height(), 0.1f);
// Shapes with transparent parts may contain different values in the "OpaqueBoundsInPoints" properties.
ASSERT_NEAR(119.0f, renderer->get_OpaqueBoundsInPoints().get_Width(), 0.2f);
ASSERT_NEAR(14.2f, renderer->get_OpaqueBoundsInPoints().get_Height(), 0.1f);
// Get the shape size in pixels, with linear scaling to a specific DPI.
System::Drawing::Rectangle bounds = renderer->GetBoundsInPixels(1.0f, 96.0f);
ASSERT_EQ(159, bounds.get_Width());
ASSERT_EQ(18, bounds.get_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_EQ(159, bounds.get_Width());
ASSERT_EQ(28, bounds.get_Height());
// The opaque bounds may vary here also.
bounds = renderer->GetOpaqueBoundsInPixels(1.0f, 96.0f);
ASSERT_EQ(159, bounds.get_Width());
ASSERT_EQ(18, bounds.get_Height());
bounds = renderer->GetOpaqueBoundsInPixels(1.0f, 96.0f, 150.0f);
ASSERT_EQ(159, bounds.get_Width());
ASSERT_EQ(30, bounds.get_Height());

#include <Aspose.Words.Cpp/Rendering/OfficeMathRenderer.h>

+ Inheritance diagram for Aspose::Words::Rendering::OfficeMathRenderer:

Public Member Functions

 OfficeMathRenderer (SharedPtr< OfficeMath > math)
 Initializes a new instance of this class. More...
 
virtual const TypeInfoGetType () const override
 
virtual bool Is (const TypeInfo &target) const override
 
- Public Member Functions inherited from NodeRendererBase
 NodeRendererBase ()
 
RectangleF get_BoundsInPoints ()
 Gets the actual bounds of the shape in points. More...
 
RectangleF get_OpaqueBoundsInPoints ()
 Gets the opaque bounds of the shape in points. More...
 
SizeF get_SizeInPoints ()
 Gets the actual size of the shape in points. More...
 
Rectangle GetBoundsInPixels (float scale, float dpi)
 Calculates the bounds of the shape in pixels for a specified zoom factor and resolution. More...
 
Rectangle GetBoundsInPixels (float scale, float horizontalDpi, float verticalDpi)
 Calculates the bounds of the shape in pixels for a specified zoom factor and resolution. More...
 
Rectangle GetOpaqueBoundsInPixels (float scale, float dpi)
 Calculates the opaque bounds of the shape in pixels for a specified zoom factor and resolution. More...
 
Rectangle GetOpaqueBoundsInPixels (float scale, float horizontalDpi, float verticalDpi)
 Calculates the opaque bounds of the shape in pixels for a specified zoom factor and resolution. More...
 
Size GetSizeInPixels (float scale, float dpi)
 Calculates the size of the shape in pixels for a specified zoom factor and resolution. More...
 
Size GetSizeInPixels (float scale, float horizontalDpi, float verticalDpi)
 Calculates the size of the shape in pixels for a specified zoom factor and resolution. More...
 
SizeF RenderToScale (SharedPtr< Graphics > graphics, float x, float y, float scale)
 Renders the shape into a Graphics object to a specified scale. More...
 
float RenderToSize (SharedPtr< Graphics > graphics, float x, float y, float width, float height)
 Renders the shape into a Graphics object to a specified size. More...
 
void Save (SharedPtr< Stream > stream, SharedPtr< ImageSaveOptions > saveOptions)
 Renders the shape into an image and saves into a stream. More...
 
void Save (String fileName, SharedPtr< ImageSaveOptions > saveOptions)
 Renders the shape into an image and saves into a file. More...
 

Static Public Member Functions

static const TypeInfoType ()
 
- Static Public Member Functions inherited from NodeRendererBase
static const TypeInfoType ()
 

Constructor & Destructor Documentation

◆ OfficeMathRenderer()

Aspose::Words::Rendering::OfficeMathRenderer::OfficeMathRenderer ( System::SharedPtr< Aspose::Words::Math::OfficeMath math)

Initializes a new instance of this class.

Parameters
mathThe OfficeMath object that you want to render.
Examples

Shows how to measure and scale shapes.

auto doc = MakeObject<Document>(MyDir + u"Office math.docx");
auto officeMath = System::DynamicCast<OfficeMath>(doc->GetChild(NodeType::OfficeMath, 0, true));
auto renderer = MakeObject<OfficeMathRenderer>(officeMath);
// Verify the size of the image that the OfficeMath object will create when we render it.
ASSERT_NEAR(119.0f, renderer->get_SizeInPoints().get_Width(), 0.2f);
ASSERT_NEAR(13.0f, renderer->get_SizeInPoints().get_Height(), 0.1f);
ASSERT_NEAR(119.0f, renderer->get_BoundsInPoints().get_Width(), 0.2f);
ASSERT_NEAR(13.0f, renderer->get_BoundsInPoints().get_Height(), 0.1f);
// Shapes with transparent parts may contain different values in the "OpaqueBoundsInPoints" properties.
ASSERT_NEAR(119.0f, renderer->get_OpaqueBoundsInPoints().get_Width(), 0.2f);
ASSERT_NEAR(14.2f, renderer->get_OpaqueBoundsInPoints().get_Height(), 0.1f);
// Get the shape size in pixels, with linear scaling to a specific DPI.
System::Drawing::Rectangle bounds = renderer->GetBoundsInPixels(1.0f, 96.0f);
ASSERT_EQ(159, bounds.get_Width());
ASSERT_EQ(18, bounds.get_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_EQ(159, bounds.get_Width());
ASSERT_EQ(28, bounds.get_Height());
// The opaque bounds may vary here also.
bounds = renderer->GetOpaqueBoundsInPixels(1.0f, 96.0f);
ASSERT_EQ(159, bounds.get_Width());
ASSERT_EQ(18, bounds.get_Height());
bounds = renderer->GetOpaqueBoundsInPixels(1.0f, 96.0f, 150.0f);
ASSERT_EQ(159, bounds.get_Width());
ASSERT_EQ(30, bounds.get_Height());

Member Function Documentation

◆ GetType()

virtual const System::TypeInfo& Aspose::Words::Rendering::OfficeMathRenderer::GetType ( ) const
overridevirtual

◆ Is()

virtual bool Aspose::Words::Rendering::OfficeMathRenderer::Is ( const System::TypeInfo target) const
overridevirtual

◆ Type()

static const System::TypeInfo& Aspose::Words::Rendering::OfficeMathRenderer::Type ( )
static