I have a presentation, where I want to edit or add a new shape with a text frame, and specify a paragraph with portions, when I set it I see the correct count of portions in my shape. But when I save the presentation into the MemoryStream and open the presentation via the stream I saved before, my portions of the shape are collapsed into 1, but initially, it was 3 different portions. Why?
Code to reproduce:
var presentation = new Presentation(<path_to_presentation>);
var shape = presentation.Slides[2].Shapes[5];
var textFrame = shape.GetTextFrame();
textFrame.Text = string.Empty;
textFrame.Paragraphs.Clear();
var portions = new string[] { "0X xxxxxxxx x", "xx", "xxxxxxxxxx xx XXXX" };
textFrame.Paragraphs.Add(new Paragraph());
var paragraph = textFrame.Paragraphs[0];
paragraph.Portions.Clear();
for (var j = 0; j < portions.Length; j++)
{
paragraph.Portions.Add(new Portion());
var portion = paragraph.Portions[j];
portion.Text = portions[j];
}
var expectedCount = presentation.Slides[2].Shapes[5].GetTextFrame().Paragraphs[0].Portions.Count; // 3
var memoryStream = new MemoryStream();
presentation.Save(memoryStream, saveFormat);
memoryStream.Seek(0, SeekOrigin.Begin);
var presentation2 = new Presentation(memoryStream);
var actualCount = presentation2 .Slides[2].Shapes[5].GetTextFrame().Paragraphs[0].Portions.Count; // 1
This should be reproducible with all presentations (new or existing, I suggest to you use mine)
00017ab04501425aa4ea8fd85a20d70d.zip (3.4 MB)