I’m creating a ppt dynamically (no existing ppt). I created a master slide with a header and body placeholders with alternative text.
I clone this master slide and add contents as needed. When I try to access to header shape, I get the reference to it, but the textframe property of the shape returns null. Hence, I’m unable to write text in the header.
Is there a better way to do it? below is my code
Shape shape = FindShape(slide, “Header”);
if (shape != null && shape.TextFrame != null)
Paragraph para = new Paragraph(shape.TextFrame.Paragraphs);
para.Portions.Text = “question text”;
shape.TextFrame.Paragraphs.RemoveAt( 0 );
I fond the shape, but shape.TextFrame returns null
I have observed the code snippet shared by you. Actually, you are trying to access the text frame using shapes. The shapes return the default text frame that is read only. You may please access the placeholders in the slide and use the textholders to add the text. Please use the following code snippet. Hopefully, it will fulfill your requirement.
Presentation pTest = new Presentation();
Slide slide = pTest.AddBodySlide();
//Adding title text
TextHolder thTitle = (TextHolder)slide.Placeholders;
Paragraph pPara = new Paragraph();
Portion pPortion = new Portion("Welcome to Aspose.Slides");
//Adding body text
TextHolder thBody = (TextHolder)slide.Placeholders;
pPara = new Paragraph();
pPortion = new Portion("This is body text");
Thanks and Regards,