Footer text not visible

Hi there

I'm using Aspose.slide to add a footer to my exitsing ppt.

for (int i = 1; i <= pres.Slides.LastSlidePosition; i++)
{
Slide slide = pres.GetSlideByPosition(i);
if (slide != null)
{
slide.HeaderFooter.IsPageNumberVisible = true;
slide.HeaderFooter.IsFooterVisible = true;
slide.HeaderFooter.FooterText = "Kathy Footer";
slide.HeaderFooter.IsDateTimeVisible = true;
}
}
pres.Write(fileName);

The code above produces the attached ppt.

The date and page number are both visible in the footer but the footer text is not, can you please advise?

Many thanks,

Kathy

Hello Kathy,

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.

Thanks Alexey,

I have tried to set the header.text as you suggested but this is still not visible on any of the slides.

Is it possible to add a header/footer to Notes page rather than the slide?

You also suggested that I look at adding a rectangle and then text, can you give me some further detail on code to do this?

Thanks,

Kathy

Hello,

It’s not possible to change objects on a Notes page except notes body text.

To add rectangle with text you can use this code:

Slide slide = pres.GetSlideByPosition(1);
Shapes shapes = slide.Shapes;
Rectangle rect = shapes.AddRectangle(100, 100, 2000, 2000);
rect.AddTextFrame(“Hello world”);

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.

Can you confirm if the set method of theHeaderFooter.FooterText works? Is it possible to use the set method as doucmented here?

http://www.aspose.com/documentation/.net-components/aspose.slides-for-.net/aspose.slides.headerfooter.footertext.html

Can you please provide a working example using the set method or advise what is wrong with my code in the original post?

for (int i = 1; i <= pres.Slides.LastSlidePosition; i++)
{
Slide slide = pres.GetSlideByPosition(i);
if (slide != null)
{
slide.HeaderFooter.IsPageNumberVisible = true;
slide.HeaderFooter.IsFooterVisible = true;
slide.HeaderFooter.FooterText = "Kathy Footer";
slide.HeaderFooter.IsDateTimeVisible = true;
}
}
pres.Write(fileName);

Does this code work for you?

Thanks

Hello,

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.
  1. Create template ppt file in PowerPoint 2003/XP/2000.
  2. Follow the new PowerPoint 2007 practice and create Footer as rectangle with text on each slide.
  3. The same as 2 but add rectangle with text to a master slide to make it visible on all inherited slides.

Hi,


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.

Thanks for your time,

Vasco Costa
VPConsulting

Hi Vasco,

It has been fixed in the latest version that can be downloaded here.

Hi,


I’ve just downloaded, and tested, the 4.0 version of Aspose.Slides.

The piece of code I’m using to add a footer is the same as on Powerpoint 2003 files.


Try
Dim lic As Aspose.Slides.License = New Aspose.Slides.License
lic.SetLicense(“Aspose.total.lic”)
’ Open file stream
Dim fs As FileStream
fs = New FileStream(filePath, FileMode.Open, FileAccess.Read)
’ Place stream on the beginning of the file
fs.Position = 0
’ Open presentation contained on that stream
Dim ppt As Aspose.Slides.Presentation = New Aspose.Slides.Presentation(fs)
’ Close stream, we don’t need it anymore
fs.Close()
’ Go through all slides
Dim i As Integer = 1
Do While (i <= ppt.Slides.LastSlidePosition)
’ Get one slide
Dim slide As Slide = ppt.GetSlideByPosition(i)
If (Not (slide) Is Nothing) Then
’ Add footer
slide.HeaderFooter.IsFooterVisible = True
slide.HeaderFooter.FooterText = footer
End If
i = (i + 1)
Loop
’ Save file
ppt.Write(filePath)
toSave = fileName
Catch ex As Exception


But unfortunately it still isn’t working. Does Slides 4.0 uses another way of adding/changing the footer text?

Thanks,

VC

Hi,

It should work, it will not work only in case, your master slide has footer text. Please check, if your master slide has footer text.

Hi,

Yes, the master slide has footer text and the idea is to change it.

So, if my approach doesn't work, is there anyway To do this?

Thanks,

V.

Hi,

Then you don't have to write such code. You just have to set footer text in Master Slide. You can find an example in this thread.

Hi there,

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?

Many thanks for your help,

Kathy

Hi Kathy,

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");

Slide sld = pres.GetSlideByPosition(1);

foreach (Aspose.Slides.Shape shp in msld.Shapes)

if (shp.AlternativeText == "Old Footer Text")

{

shp.TextFrame.Text = "New Footer Text";

}

pres.Write("headfoot2.ppt");

Hi Muhammad,

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);

MasterSlidesEx masterSlidesX = presX.Masters;
foreach (MasterSlideEx slideX in masterSlidesX)
{
Aspose.Slides.Pptx.ShapesEx shapesX = slideX.Shapes;
int shapeIndex = shapesX.AddAutoShape(ShapeTypeEx.Rectangle, 100, 4100, 100, 100);
AutoShapeEx rectX = slideX.Shapes[shapeIndex] as AutoShapeEx;
rectX.AddTextFrame("MY FOOTER TEXT");
rectX.TextFrame.Paragraphs[0].Portions[0].RawFontHeight = 8;

}

presX.Write(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.

Can you please advise were I'm going wrong?

Many Thanks,

Kathy

Hi Kathy,

Just use correct values for parameters of AddAutoShape method as measurement scale for PPTX is different. A better example is as under:

msld.Shapes.AddAutoShape(ShapeTypeEx.Rectangle, 50, 475, 150, 50);