HeaderFooterManager.SetFooterText

Hi,

I’m using the code below on the pptx file attached to try and update the footer text for the powerpoint file. I followed the steps as detailed here:

I’m currently running up against two issues;

  1. The SetVisibilityOnTitleSlide seems to be over-riding any settings I apply using IsSlideNumberVisible and IsDateTimeVisible so even if those 2 are set to false and I only want the footer displayed, if SetVisibilityOnTitleSlide is true then all 3 parts of the footer are displayed. The rest of the file is rendered correctly with only the specified elements rendered
  2. SetFooterText appears to be doing nothing, I pass in a string value and for the sake of testing, I have hard-coded a value and both times the string seems to be ignored and I’m left with an empty footer container.

Also, in the link above, you appear to be calling a Write method but from what I can tell Version 14.4.0.0 only has the Save method to commit any changes to files?

Presentation pres = new Presentation(path);

pres.UpdateDateTimeFields = true;
pres.UpdateSlideNumberFields = true;
pres.HeaderFooterManager.SetFooterText(“test”);
pres.HeaderFooterManager.IsDateTimeVisible = false;
pres.HeaderFooterManager.IsSlideNumberVisible = false;
pres.HeaderFooterManager.IsFooterVisible = true;
pres.HeaderFooterManager.SetVisibilityOnTitleSlide(true);

pres.Save(path, saveFormat);

Hi Jak,


I have observed the requirements shared by you and have performed my testing using Aspose.Slides for .NET 14.4.0 on my end. I have been able to observe the issue of slide number and date time field getting visible on title slide although their visibility is set to false. An issue with ID SLIDESNET-35477 has been created in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be automatically notified once the issue will be resolved.

For your second issue concerning to setting footer text, I have not been able to observe the issue on my end. For your kind reference, I have attached the source presentation and generated presentation along with used code. Please try using the shared information on your end for further verification. Please share, if I may help you further in this regard.

public static void TestFooter()
{
String path = @“C:\Presentations”;
Presentation pres = new Presentation(path+“TestFooter.pptx”);

pres.UpdateDateTimeFields = true;
pres.UpdateSlideNumberFields = true;
pres.HeaderFooterManager.SetFooterText(“test”);
pres.HeaderFooterManager.IsDateTimeVisible = false;
pres.HeaderFooterManager.IsSlideNumberVisible = false;
pres.HeaderFooterManager.IsFooterVisible = true;
pres.HeaderFooterManager.SetVisibilityOnTitleSlide(true);
pres.Save(path + “TestFooter2.pptx”, SaveFormat.Pptx);
}


Many Thanks,

Hi Mudassir,


Thanks for that, and sorry for my delayed reply.

I’ve taken a look at the code you’ve used and it does indeed work, however there is a subtle difference in my use case and this seems to be where the issue is arising.

When saving the file, you are currently saving it as a new file and when I do that, the footer is applied correctly. The use case I’m looking at is saving the same file back, hence me passing the path in so I can reference the same file, in this instance the footer application fails when I save it back.

Is the saving of the same file not supported or do I need to handle it differently, I can’t create a new file as I have to only act on the files I am passing into the method.

Thanks,
Jak

Hi Jak,


I have observed the requirements shared by you and like to share that there is no difference practically in saving a file with different name or same name. When loaded using Aspose.Slides, the entire presentation is loaded in DOM of Aspose.Slides in memory. Even if you use the source presentation file name for saving, Aspose.Slides will replace the source file with new one. I hope this will clarify the concept to you. Please share, if I may help you further in this regard.

Many Thanks,

Hi Mudassir,


I’m afraid I’m still a little lost then.

This code performs as expected and the footer is indeed visible on the slides;
Presentation pres = new Presentation(path);

FileInfo file = new FileInfo(path);
var ext = file.Extension;
Aspose.Slides.Export.SaveFormat saveFormat = Aspose.Slides.Export.SaveFormat.Pptx;
//Can use an if statement for now since only ppt and pptx files should ever reach this point
if (ext == “.ppt”)
saveFormat = Aspose.Slides.Export.SaveFormat.Ppt;

pres.UpdateDateTimeFields = true;
pres.UpdateSlideNumberFields = true;
pres.HeaderFooterManager.SetFooterText(“Test”);
pres.HeaderFooterManager.IsDateTimeVisible = false;
pres.HeaderFooterManager.IsSlideNumberVisible = false;
pres.HeaderFooterManager.IsFooterVisible = true;
pres.HeaderFooterManager.SetVisibilityOnTitleSlide(false);

pres.Save(@“C:\sandbox\TestDocs\powerpointdocsTest2.pptx”, saveFormat);

However this code, the code that is saving back to the original file is still not working;
Presentation pres = new Presentation(path);

FileInfo file = new FileInfo(path);
var ext = file.Extension;
Aspose.Slides.Export.SaveFormat saveFormat = Aspose.Slides.Export.SaveFormat.Pptx;
//Can use an if statement for now since only ppt and pptx files should ever reach this point
if (ext == “.ppt”)
saveFormat = Aspose.Slides.Export.SaveFormat.Ppt;

pres.UpdateDateTimeFields = true;
pres.UpdateSlideNumberFields = true;
pres.HeaderFooterManager.SetFooterText(“Test”);
pres.HeaderFooterManager.IsDateTimeVisible = false;
pres.HeaderFooterManager.IsSlideNumberVisible = false;
pres.HeaderFooterManager.IsFooterVisible = true;
pres.HeaderFooterManager.SetVisibilityOnTitleSlide(false);

pres.Save(path, saveFormat);

Please also see the attached images for the output from each run through of the code. At this point the only thing I am changing between each run is the save location of the file. Would you be able to investigate and see if there is any issue with the save location and whether or not this is impacting the expected output?

Thanks,
Jak

Hi Jak,


I have worked with the presentation file shared by you using Aspose.Slides for .NET 14.4.0 and have successfully crated a presentation with footer with same code used by you. For your kind reference, I have attached the generated presentation as well. I suggest you to please try using Aspose.Slides for .NET 14.4.0 or latest 14.5.0 on your end. I am hopeful, things will be fine. Please note that I have used Test1.pptx that has been shared by you in very first post of the thread.

Many Thanks,