We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Dynamically Generating and Connecting Connectors

I have two sets of (x,y) coordinates. I would like to draw a line going from point a to point b. How do I do this?

Also, in a similar circumstance, I have two dynamically generated shapes. What would be the best way to create a connector shape and attach each end to one of the anchor points on each shape?

Hi Scot,

In case you are looking to draw a line between two points, you can refer to the following documentation link.

Adding Line Shape in Slide

Following code sample shows how to add shapes and connector to them.

//instantiate new presentation object
Presentation pres = new Presentation();

//Get First Slide
ISlide slide = pres.Slides[0];

//Adding Shapes
IAutoShape rectangle1 = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 100, 100, 100, 100);
IAutoShape rectangle2 = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 300, 300, 100, 100);

//Adding Connector
IConnector connector = slide.Shapes.AddConnector(ShapeType.BentConnector3, 150, 150, 250, 250);
connector.StartShapeConnectedTo = rectangle1;
connector.StartShapeConnectionSiteIndex = 1;
connector.EndShapeConnectedTo = rectangle2;
connector.EndShapeConnectionSiteIndex = 2;

//Save the presentation
pres.Save(“D:\Data\AsposeConnectionIssue1.pptx”, Aspose.Slides.Export.SaveFormat.Pptx);

In case you need any further assistance, please feel free to contact support.

Thanks & Regards,