Hello, I’m working on a issue where we need to remove footers and headers from Power Point (PPT) documents and I’m having trouble using Aspose.Slides (7.9.0.0) as well as Aspose.Slides (16.9.0.0).
With the older version:
I’m trying to enumerate the shapes using slide.Shapes and shape.Placeholder is ‘null’, shape.TextFrame.MetaCharacters is null make it difficult to detect whether the give shape is a footer or header.
slide.HeaderFooter.FooterText is always “” even when there is proper footer text in the ppt.
With new version:
Presentation ppt = new Presentation(@“E:\PowerPoint2016.ppt”);
ppt.HeaderFooterManager.SetFooterText("");
ppt.HeaderFooterManager.IsFooterVisible = false;
ppt.HeaderFooterManager.IsDateTimeVisible = false;
ppt.HeaderFooterManager.IsSlideNumberVisible = false;
foreach(ISlide s in ppt.Slides)
{
Console.WriteLine(“Slide Name: {0}”, s.Name);
foreach(IShape sh in s.Shapes)
{
if(sh.Placeholder != null)
{
Console.WriteLine(“Shape Name: {0}, Type: {1}”, sh.Name, sh.Placeholder.Type.ToString());
}
else
{
Console.WriteLine(“Shape Name: {0}, Type: null”, sh.Name);
var tf = ((AutoShape)sh).TextFrame;
}
}
Console.WriteLine("");
}
The above code results into:
Slide Name:
Shape Name: Title 1, Type: CenteredTitle
Shape Name: Subtitle 2, Type: Subtitle
Shape Name: Date Placeholder 3, Type: null
Shape Name: Footer Placeholder 4, Type: null
Shape Name: Slide Number Placeholder 5, Type: null
Slide Name:
Shape Name: Title 1, Type: Title
Shape Name: Date Placeholder 2, Type: null
Shape Name: Footer Placeholder 3, Type: null
Shape Name: Slide Number Placeholder 4, Type: null
Shape Name: Text Placeholder 5, Type: Body
*******************************************
The placeholder type is returned as null.
Note: It seems to work fine for: ppt.Masters, ppt.MasterHandoutSlideManager.MasterHandoutSlide and ppt.MasterNotesSlideManager.MasterNotesSlide. Issue with existing slide only.
Can you please suggest a way to detect the footer and header items in existing slides? Ideally in the older version.
Please let me know if any questions. thank you.