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

Free Support Forum - aspose.com

Multiple lines in shape gets combined to one portion

I am trying to extract text from paragraph. The ppt file contains three lines inside a shape. When i use aspose to get the text, i get a single portion with break statements inbetween. But, i am expecting three portions, each for a line in the pptx file.

var autoShape = pres.Slides[0].Shapes[0] as IAutoShape;
var textFrame = autoShape.TextFrame;
var paragraph = textFrame.Paragraphs[0];
var portion = paragraph.Portions[0];
Console.log("Portion count"+paragraph.Portions.Count);  //expecting 3 but got 1

Please find the attached sample pptx file.
portion_issue.zip (47.1 KB)


Can you please try using latest Aspose.Slides for .NET 20.6 as I am able to observe 3 portions of text using latest API.

	public static void ExtractFontInfo()
		String path = @"C:\Users\mudas\Downloads\portion_issue\";
		Presentation pres = new Presentation(path+"portion_issue.pptx");
		foreach(ISlide slide in pres.Slides)
			foreach(IShape shape in slide.Shapes)
				if(shape is IAutoShape)
					IAutoShape ashp = (IAutoShape)shape;
						ITextFrame textFrame = ashp.TextFrame;
						foreach(IParagraph para in textFrame.Paragraphs)
							foreach(IPortion portion in para.Portions)
								Console.WriteLine("Text is: " + portion.Text);


Now I get three portions but none of these are individual lines of paragraph. For example,
in ppt file
First line has “Engine Mount Load Structural Integrity Analysis”
Second line has “CSS 375T LP5 Beta E2XX AWD”
Third line has “(2017-12-08-12931 )”

But what i get from portions is
First portion has “Engine Mount Load Structural Integrity Analysis\u000bCSS 375T LP5 Beta E2XX AWD\u000b(”
Second portion has “2017-12-08-12931”
Third portion has “)”

How do i get them as above? So that i can reproduce them as of ppt


In your presentation although the text appear in 3 line but ‘\v’ (Soft Enter) has been used to display text in multiple lines. In this case the text is held in a single paragraph. In order to achieve your desired result, you need to hit enter on each line and extract text on Paragraph level rather then portion level. You get a new paragraph where there is enter or new line feed pressed.

In case of portion, you get a new portion of text in a paragraph whenever there is a any change in textual property of the text inside a paragraph. In your case, the first change in textual property occurs when date portion (“2017-12-08-12931”) changed to orange. At this point second portion started. When again the ending bracket appeared in blue, third portion started.