You should set Header properties instead. That is odd enough but in PowerPoint Headers are at the bottom of a slide. Also I never saw any presentations with Footer. I think this field is ignored by PowerPoint.
I’d suggest adding simple rectangle with text instead of using header/footer properties. Result will be the same.
Just place created rectangle to the right position. Also please read Aspose.Slides documentation and programmer’s guide for details how to change borders and fill style of the rectangle and how to format the text.
I did additional testing of HeaderFooter functionality.
This code works but not for presentations created in PowerPoint 2007 and 2010.
PowerPoint 2007 doesn’t create HeaderFooter containers at all (although can show old presentations). It just creates rectangles with text on each slide as I suggested in the previous post. Moreover, PowerPoint 2007 removes all information about Footer placeholder from master slide when save a presentation so it’s not possible to add new Footer in Aspose.Slides after that.
I can offer 3 possible solutions.
Create template ppt file in PowerPoint 2003/XP/2000.
Follow the new PowerPoint 2007 practice and create Footer as rectangle with text on each slide.
The same as 2 but add rectangle with text to a master slide to make it visible on all inherited slides.
I would like to know if there’s any update on this situation.
I too need to add a footer automatically, but need to keep that text on the Headers & Footers menu of Office, so when a users opens the file, he can see (and maybe alter) such text.
I'm trying to Add footer text to a master slide in PowerPoint 2003. I'm using the following code;
Slide mstr = pres.MainMaster as Slide; if (mstr != null) {
foreach (Aspose.Slides.Shape shp in mstr.Shapes) { if (shp.TextFrame != null) { TextFrame tf = shp.TextFrame; if (tf.MetaCharacters != null) { MetaCharacterType metaType = tf.MetaCharacters[0]; switch (metaType) { case MetaCharacterType.Footer: tf.Paragraphs[0].Portions[0].Text = "Kathy Footer 23 Nov"; break;
default: break;
} } } } }
I will be working with existing Presentations that may or may not have a master slide. The master slide may or may not have a master footer placholder.
This code doesn't seem to work if the master slide doesn't have a master footer placeholder.
How can I add this master footer placeholder to a master slide?
If I add a rectangle to the master slide how do I assign it as the master footer placeholder so that the MetaCharacterType will be footer?
Footer text of any slide except master slide can be changed using Slide.HeaderFooter.FooterText object. An issue with issue id 11992 has been created to address this problem and a notification will be issued in this thread as soon as it is fixed.
However, there is a workaround to add / update footer text to the master slide. An alternative text can be set to the footer text shape in the master slide through MS Power Point 2003 and that alternative text can be used to add / update the footer text of a master slide. An example is as under:
Presentation pres = new Presentation("headfoot.ppt");
I have a requirement to add a footer to a pptx file. I already have code in place to work with ppt files, this code simply adds a rectangle with text to the master slides.
PPT code
Presentation pres = new Aspose.Slides.Presentation(fileName);
Slides masterSlides = pres.Masters;
foreach (Slide slide in masterSlides) { Aspose.Slides.Shapes shapes = slide.Shapes; Rectangle rect = shapes.AddRectangle(100, 4100, 100, 100 );
rect.LineFormat.ShowLines = false; rect.AddTextFrame("MY FOOTER TEXT HERE " );
Aspose.Slides.Paragraph para = rect.TextFrame.Paragraphs[0]; Portion port = para.Portions[0]; port.FontHeight = 8; }
pres.Write(fileName);
I have tried to modify the code to use the pptx namespace.
PPTX code
PresentationEx presX = new Aspose.Slides.Pptx.PresentationEx(fileName);
I can debug through the code and see that each lines executes without any exceptions although it doesn't work. The rectangle that should be added is not visible.