How to get the position of portion and paragraph on the slide (C# .NET)

I have some existing code that generates a slide with tables, some other textframes in rectangle shapes, etc


I now have a requirement to add an ellipse shape to the left of certain text elements on the page. I see the code to add an Ellipse shape but I am can’t figure out how to determine the position of the various text elements to be able to then put the shape exactly to the left of the text.

I see that I can get X and Y coordinates of shapes, but is there the ability to get the X and Y coordinates of individual items such as:

* Paragraphs within a Textframe ?
* Individual portions within a Paragraph ?

Hi Adam,


Thank you for your interest in Aspose.Slides.

I have observed your comments and like to share with you that the feature to get the position coordinates of Paragraphs and portions is not supported in Aspose.Slides at the moment. A ticket with ID SLIDESNET-36886 has been logged into our issue management system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be automatically notified as soon as the issue will be resolved.

We are sorry for your inconvenience,

how can I see if this is being worked on or if this is any progress around release date?

Hi Adam,


I have verified from our issue tracking system and like to share that the concerned issue is actually a new feature request which is at present unavailable in Aspose.Slides for .NET. However, I have requested our product team to kindly share the updates in terms of road map for implementation and will share that with you as soon as it will be shared by them.

We are sorry for your inconvenience,

Is there any update on expectations here? This request (which seems like a minor change) has now been outstanding for over 6 months

Hi Adam,


I would like to share with you that the ETA for this issue is Aspose.Slides for .NET 16.5.0 whose tentative date of release is the first week of June 2016. We will notify you as soon as the issue will be fixed.

Best Regards,

The issues you have found earlier (filed as SLIDESNET-36886) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.
(5)

@leora1,

We have introduced this long awaited support in API to get actual paragraph and portion position for any text frame on slide. Using following simple API calls, you can access these coordinates.

	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)