Drawing Classes — Aspose.Slides FOSS for .NET API Reference

This page covers drawing-related classes used for shapes, pictures, and connectors in Aspose.Slides FOSS for .NET.

Package: Aspose.Slides.Foss (net9.0)

using Aspose.Slides.Foss;

AutoShape

An auto shape is a geometry shape that can hold text. It extends GeometryShape.

public class AutoShape : GeometryShape, IAutoShape

Properties

PropertyTypeAccessDescription
ShapeTypeShapeTypeReadGeometry type (Rectangle, Ellipse, etc.).
TextFrameITextFrame?ReadText content of the shape.
IsTextBoxboolReadWhether the shape was created as a text box.

Methods

MethodDescription
AddTextFrame(string? text)Add a text frame with the specified text.

PictureFrame

A shape that displays an embedded image.

public class PictureFrame : GeometryShape, IPictureFrame

Properties

PropertyTypeAccessDescription
ShapeTypeShapeTypeReadShape geometry type.
PictureFrameLockIPictureFrameLock?ReadLock settings for the picture frame.
PictureFormatIPictureFillFormat?ReadPicture fill settings (crop, tile, etc.).
RelativeScaleHeightfloatReadRelative height scale.
RelativeScaleWidthfloatReadRelative width scale.
IsCameoboolReadWhether this is a cameo (profile picture) frame.

PictureFillFormat

Controls how an image fills a shape or background.

public class PictureFillFormat : PVIObject, IPictureFillFormat

Properties

PropertyTypeAccessDescription
DpiintReadImage DPI.
PictureFillModePictureFillModeReadFill mode (Stretch, Tile).
PictureISlidesPictureReadThe embedded picture.
CropLeftfloatReadLeft crop percentage.
CropTopfloatReadTop crop percentage.
CropRightfloatReadRight crop percentage.
CropBottomfloatReadBottom crop percentage.
TileOffsetXfloatReadTile X offset.
TileOffsetYfloatReadTile Y offset.
TileScaleXfloatReadTile X scale.
TileScaleYfloatReadTile Y scale.
TileAlignmentRectangleAlignmentReadTile alignment.
TileFlipTileFlipReadTile flip mode.

Connector

A connector shape that links two shapes.

public class Connector : GeometryShape, IConnector

Properties

PropertyTypeAccessDescription
StartShapeConnectedToIShape?ReadShape at the start of the connector.
EndShapeConnectedToIShape?ReadShape at the end of the connector.
StartShapeConnectionSiteIndexintReadConnection site index on the start shape.
EndShapeConnectionSiteIndexintReadConnection site index on the end shape.
ConnectorLockIConnectorLock?ReadLock settings.

Methods

MethodDescription
Reroute()Recalculate the connector path.

GeometryShape

Base class for shapes with geometry (auto shapes, connectors, picture frames).

public class GeometryShape : Shape, IGeometryShape

Properties

PropertyTypeAccessDescription
ShapeStyleIShapeStyle?ReadTheme style applied to the shape.
ShapeTypeShapeTypeReadGeometry preset type.
AdjustmentsIAdjustValueCollection?ReadGeometry adjustment values.

Usage Examples

Add a Picture Frame

using Aspose.Slides.Foss;
using Aspose.Slides.Foss.Export;

using var prs = new Presentation();
using var imgStream = File.OpenRead("photo.png");
var image = prs.Images.AddImage(imgStream);
var picFrame = prs.Slides[0].Shapes.AddPictureFrame(
    ShapeType.Rectangle, 50, 50, 300, 200, image);

prs.Save("picture.pptx", SaveFormat.Pptx);

Add a Connector

using Aspose.Slides.Foss;
using Aspose.Slides.Foss.Export;

using var prs = new Presentation();
var slide = prs.Slides[0];
var shapeA = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 50, 50, 100, 60);
var shapeB = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 300, 50, 100, 60);
var connector = slide.Shapes.AddConnector(ShapeType.BentConnector3, 150, 80, 150, 80);

prs.Save("connector.pptx", SaveFormat.Pptx);

See Also