ShapeRenderer Class

Provides methods to render an individual Shape or GroupShape 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.3
Syntax
public class ShapeRenderer : NodeRendererBase

The ShapeRenderer type exposes the following members.

Constructors
  NameDescription
Public methodCode exampleShapeRenderer
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 render a shape with a Graphics object.
public void DisplayShapeForm()
{
    // Create a new ShapeForm instance and show it as a dialog box
    ShapeForm shapeForm = new ShapeForm();
    shapeForm.ShowDialog();
}

/// <summary>
/// Windows Form that renders and displays shapes from a document.
/// </summary>
private class ShapeForm : Form
{
    protected override void OnPaint(PaintEventArgs e)
    {
        // Set the size of the Form canvas
        Size = new Size(1000, 800);

        // Open a document and get its first shape, which is a chart
        Document doc = new Document(MyDir + "Various shapes.docx");
        Shape shape = (Shape)doc.GetChild(NodeType.Shape, 1, true);

        // Create a ShapeRenderer instance and a Graphics object
        // The ShapeRenderer will render the shape that is passed during construction over the Graphics object
        // Whatever is rendered on this Graphics object will be displayed on the screen inside this form
        ShapeRenderer renderer = new ShapeRenderer(shape);
        Graphics formGraphics = CreateGraphics();

        // Call this method on the renderer to render the chart in the passed Graphics object,
        // on a specified x/y coordinate and scale
        renderer.RenderToScale(formGraphics, 0, 0, 1.5f);

        // Get another shape from the document, and render it to a specific size instead of a linear scale
        GroupShape groupShape = (GroupShape)doc.GetChild(NodeType.GroupShape, 0, true);
        renderer = new ShapeRenderer(groupShape);
        renderer.RenderToSize(formGraphics, 500, 400, 100, 200);
    }
}
See Also