Aspose::Words::Rendering::NodeRendererBase class

NodeRendererBase class

Base class for ShapeRenderer and OfficeMathRenderer. To learn more, visit the Working with Shapes documentation article.

class NodeRendererBase : public System::Object

Methods

MethodDescription
get_BoundsInPoints() constGets the actual bounds of the shape in points.
get_OpaqueBoundsInPoints()Gets the opaque bounds of the shape in points.
get_SizeInPoints()Gets the actual size of the shape in points.
GetBoundsInPixels(float, float)Calculates the bounds of the shape in pixels for a specified zoom factor and resolution.
GetBoundsInPixels(float, float, float)Calculates the bounds of the shape in pixels for a specified zoom factor and resolution.
GetOpaqueBoundsInPixels(float, float)Calculates the opaque bounds of the shape in pixels for a specified zoom factor and resolution.
GetOpaqueBoundsInPixels(float, float, float)Calculates the opaque bounds of the shape in pixels for a specified zoom factor and resolution.
GetSizeInPixels(float, float)Calculates the size of the shape in pixels for a specified zoom factor and resolution.
GetSizeInPixels(float, float, float)Calculates the size of the shape in pixels for a specified zoom factor and resolution.
GetType() const override
Is(const System::TypeInfo&) const override
NodeRendererBase()
RenderToScale(const System::SharedPtr<System::Drawing::Graphics>&, float, float, float)Renders the shape into a Graphics object to a specified scale.
RenderToSize(const System::SharedPtr<System::Drawing::Graphics>&, float, float, float, float)Renders the shape into a Graphics object to a specified size.
Save(const System::String&, System::SharedPtr<Aspose::Words::Saving::ImageSaveOptions>)Renders the shape into an image and saves into a file.
Save(const System::String&, System::SharedPtr<Aspose::Words::Saving::SvgSaveOptions>)
Save(const System::SharedPtr<System::IO::Stream>&, System::SharedPtr<Aspose::Words::Saving::ImageSaveOptions>)Renders the shape into an image and saves into a stream.
Save(const System::SharedPtr<System::IO::Stream>&, System::SharedPtr<Aspose::Words::Saving::SvgSaveOptions>)
Save(std::basic_ostream<CharType, Traits>&, System::SharedPtr<Aspose::Words::Saving::ImageSaveOptions>)
Save(std::basic_ostream<CharType, Traits>&, System::SharedPtr<Aspose::Words::Saving::SvgSaveOptions>)
static Type()

Examples

Shows how to measure and scale shapes.

auto doc = MakeObject<Document>(MyDir + u"Office math.docx");

auto officeMath = System::ExplicitCast<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());

See Also