Add Header and Footer in PowerPoint files using C# and VB.NET

Most slides in a presentation, except maybe the title slide, contain a header and footer with the date and time, a slide number, or some custom text.

With GemBox.Presentation you can easily add headers and footers to your PowerPoint presentations using C# and VB.NET. The HeaderFooter class represents these graphic elements.

The following example shows how to create and customize master-slide and layout-slide headers and footers using the GemBox.Presentation API.

PowerPoint footer created with GemBox.Presentation
Screenshot of PowerPoint footer created with GemBox.Presentation
using GemBox.Presentation;

class Program
    static void Main()
        // If using Professional version, put your serial key below.

        var presentation = new PresentationDocument();

        // Create new master slide.
        var master = presentation.MasterSlides.AddNew();

        // Set "DateTime" and "SlideNumber" placeholders visible on slides.
        master.HeaderFooter.IsDateTimeEnabled = true;
        master.HeaderFooter.IsSlideNumberEnabled = true;

        // Create new slides; will inherit "DateTime" and "SlideNumber" placeholders from master slide.
        var slide = presentation.Slides.AddNew(SlideLayoutType.VerticalTitleAndText);
        slide = presentation.Slides.AddNew(SlideLayoutType.TwoObjects);
        slide = presentation.Slides.AddNew(SlideLayoutType.TwoObjectsAndText);

        presentation.Save("Header and Footer.pptx");
Imports GemBox.Presentation

Module Program

    Sub Main()

        ' If using Professional version, put your serial key below.

        Dim presentation = New PresentationDocument

        ' Create New master slide.
        Dim master = presentation.MasterSlides.AddNew()

        ' Set "DateTime" And "SlideNumber" placeholders visible on slides.
        master.HeaderFooter.IsDateTimeEnabled = True
        master.HeaderFooter.IsSlideNumberEnabled = True

        ' Create New slides; will inherit "DateTime" And "SlideNumber" placeholders from master slide.
        Dim slide = presentation.Slides.AddNew(SlideLayoutType.VerticalTitleAndText)
        slide = presentation.Slides.AddNew(SlideLayoutType.TwoObjects)
        slide = presentation.Slides.AddNew(SlideLayoutType.TwoObjectsAndText)

        presentation.Save("Header and Footer.pptx")
    End Sub
End Module

Want more?

Next example GitHub

Check the next example or select an example from the menu. You can also download our examples from the GitHub.

Like it?

Download Buy

If you want to try the GemBox.Presentation yourself, you can download the free version. It delivers the same performance and set of features as the professional version, but with some operations limited. To remove the limitation, you need to purchase a license.