Getting X and Y positions for Paragraphs (C# .NET)

I am reading a PowerPoint presentation and I have a TextFrame that contains a few Paragraphs.
Can you please explain how I can obtain the X and Y positions for each of the paragraphs?
A code example would be great.
Thanks.

Dear Aseem,

It is not possible to get X, Y position of individual paragraphs; you can only get X, Y position of TextFrame.


Hi msfaiz,
I do see a reference to a possible solution, but I need more details on how to do this.
The reference is at:
<a href="https://forum.aspose.com/t/110817
Please see if you can elaborate on this solution.
Thanks.

You can only work with that solution, if you know how to work with fonts in using .NET Framework class libraries. You need to search on internet how to work with fonts in C# etc.

@aseem73,

By using latest Aspose.Slides for .NET API, now you can extract any text frame paragraph or its portions X,Y position on slide. The following simple API calls illustrated in example will be used to extract the desired information.

	public static void GetParagraphCoordinates()
	{
		// The path to the documents directory.
		string dataDir = @"C:\Aspose Data\";

		// Instantiate a Presentation object that represents a presentation file
		using (Presentation presentation = new Presentation(dataDir + "TestText.pptx"))
		{
			IAutoShape shape = (IAutoShape)presentation.Slides[0].Shapes[0];
			var textFrame = (ITextFrame)shape.TextFrame;
			RectangleF rect = ((Paragraph)textFrame.Paragraphs[0]).GetRect();
			Console.WriteLine("The following shows the paragraph's actual coordinates on slide");
			Console.WriteLine(String.Format("Paragraph Text: {4} has coordinates (X: {0}, Y: {1}), Width: {2} and Height{3}", rect.X, rect.Y, rect.Width, rect.Height, ((Paragraph)textFrame.Paragraphs[0]).Text));
		}
	}

	public static void GetPortionCoordinates()
	{
		string dataDir = @"C:\Aspose Data\";
		using (Presentation presentation = new Presentation(dataDir + "TestText.pptx"))
		{
			IAutoShape shape = (IAutoShape)presentation.Slides[0].Shapes[0];
			var textFrame = (ITextFrame)shape.TextFrame;

			foreach (var paragraph in textFrame.Paragraphs)
			{
				Console.WriteLine("The following shows the coordinates for all the portions inside paragraph");

				foreach (Portion portion in paragraph.Portions)
				{
					var rect = portion.GetRect();//.GetCoordinates();
					//Console.Write(Environment.NewLine + "Corrdinates X =" + point.X + " Corrdinates Y =" + point.Y);
					Console.WriteLine(String.Format("Portion Text: {4} has coordinates (X: {0}, Y: {1}), Width: {2} and Height{3}", rect.X, rect.Y, rect.Width, rect.Height, portion.Text));
				}
			}
		}
	}

TestText.zip (24.0 KB)