Adding a Header Slide and Title not being displayed

When creating a new slide with .AddHeaderSlide() I am then attempting to set the text in the Shape that is created using the following code

Slide slide = Pres.AddHeaderSlide();
Paragraph headerPara = new Paragraph();

Portion portion = new Portion(Title);

but the text contained in the Title is not being displayed on the slide. While examining the slide.Shapes[0].TextFrame.Paragraphs collection I am seeing the correct text in the paragraph I created - but when examining the slide.Shapes[0].TextFrame object the Text property is empty, and read only. Can someone please advise what I am doing wrong.


David J

Dear David,

Thanks for considering Aspose.Slides.

Here is a complete code to add a title text. Please see the output presentation generated by this code from the attachment.

You can also use TextFrame to add text, also you can set the font, formatting of paragraphs and portions. For illustration and code example, you should visit this thread.

C# Code

//Create a presentation
Presentation Pres = new Presentation();

//Add a new header slide
Slide slide = Pres.AddHeaderSlide();

//Access the Title Placeholder
TextHolder thld = slide.Shapes[0].Placeholder as TextHolder;

//Get its first paragraph
Paragraph headerPara = thld.Paragraphs[0];

//Get first portion of the first paragraph
Portion portion = headerPara.Portions[0];

//Set the text
portion.Text = "Title Text";

//Place the slide at first position
slide.SlidePosition = 1;

//Write the presentation on disk