I am trying to wrap long text in paragraph and have its container to fit it.
The sample code I am using is the following but the result is not what I am expecting. As you can see, the last word is not wrapped within the container. However, if you manually open the result and toggle "Resize shape to fit the text" + "Wrap text in shape" it will fit properly.
Strange thing is that those 2 properties are already set but somehow they don't have any effect until you manually toggle them (disable then re enable)
- Code: Select all
Presentation ppt = new Presentation();
ppt.LoadFromFile(@"test.pptx");
var finalPpt = new Presentation();
finalPpt.Slides.RemoveAt(0);
finalPpt.SlideSize.Type = ppt.SlideSize.Type;
var generatedSlide = ppt.Slides[0];
var shape = generatedSlide.Shapes[0] as IAutoShape;
shape.TextFrame.Paragraphs[0].Text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin vel molestie orci, non pharetra felis. Donec accumsan facilisis magna, in interdum enim porttitor sed. Suspendisse lectus tortor, dictum nec enim et, vehicula commodo nisi. Proin lacinia tellus eu congue fermentum. Etiam id aliquam urna. Nunc viverra, ligula sed porttitor vulputate, nisl leo iaculis purus, in feugiat felis justo a nulla. Curabitur sollicitudin leo nec nisi pulvinar consectetur. Nullam at bibendum turpis. Integer elementum ante mi, ac elementum sapien vulputate ut. Cras sagittis nisi in elit sagittis tempus. Nulla et dui sed purus ultrices suscipit. Mauris sed nisl sapien. Sed lacinia consectetur nisi, ut elementum odio sodales ut. Praesent sagittis lacus sit amet elementum consectetur. Cras eleifend tristique lorem, id cursus mauris sollicitudin ut. Ut molestie venenatis ligula id laoreet.";
finalPpt.Slides.Append(generatedSlide);
finalPpt.SaveToFile(@"C:\temp\out.pptx", FileFormat.Pptx2013);
Is there any property we need to set on the paragrap before producing the output?
Thanks,
Andrea