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

Free Support Forum - aspose.com

How to draw a flipped line (C# .NET)


Is there any way to draw a Line shape from left bottom point to right upper point?
E.g. from x=50, y=400 to x= 300, y= 300 ?

When I create such line in powerpoint - it opens with FlipV = true. But I cannot set this property when I add shapes via Aspose.Slides.

Is the only solution to set rotation for a line from left top to right bottom? And how to calculate in my example what is the position to drop, since when rotation is applied - X/Y coordinates of the frame are not updated.

Please see attached example. I need to draw a line in Red, but so far I see only a way to create the one in gray, by speciying X/Y and height/Width. To achieve what I need I probably need to use FlipV for grey line, but it is a readonly property

Thank youex1.PNG (3.6 KB)


Please proceed to this documentation link where we have added the samples for adding plain line as well as formatted lines. I hope the shared information will be helpful.

@mudassir.fayyaz, yes, I 've seen that and it is what I described in my initial question.
With that approach I can draw my grey line (please check image attached in first post), but I cannot draw a red line.
There is no possibility to use FlipV for that.
So far I found only one way - to draw it shifted and then use Rotation = 90, but it is confusing a lot and requires precalculation in order to understand where the final rotated line will appear

Is there any other way to draw that red line from my example without rotation?


You can easily manage that by altering the shape frame where you will find properties for flipping vertical or horizontal. Please try using following example and I hope its exactly what you are looking for.

	public static void TestLineFlip()
		String path=@"C:\Aspose Data\";

		Presentation TestPres = new Presentation();

		ISlide slide = TestPres.Slides[0];

		var Line1 = slide.Shapes.AddAutoShape(ShapeType.Line, 100f, 100f, 400f, 400f);

		Line1.LineFormat.EndArrowheadLength = LineArrowheadLength.Long;

		Line1.LineFormat.EndArrowheadStyle = LineArrowheadStyle.Triangle;

		Line1.LineFormat.FillFormat.FillType = FillType.Solid;

		Line1.LineFormat.FillFormat.SolidFillColor.Color = Color.Gray;

		Line1.LineFormat.Width = 5;

		IShapeFrame oldFrame = Line1.Frame;
		var FlipHValue = Line1.Frame.FlipH;

		var Line2 = slide.Shapes.AddClone(Line1);

		Line2.LineFormat.FillFormat.SolidFillColor.Color = Color.Red;

		//Following code snippet will flip the shape horizontally
		Line2.Frame = new ShapeFrame(oldFrame.X, oldFrame.Y, oldFrame.Width, oldFrame.Height, NullableBool.True, oldFrame.FlipV, oldFrame.Rotation);

		var FlipHValue2 = Line1.Frame.FlipH;

		TestPres.Save("C:\\Aspose Data\\Line.pptx",SaveFormat.Pptx);

Line.zip (22.2 KB)