Header and Footer

Most of slides, except maybe the title slide, contain some kind of header or footer that can present the date and time, a slide number or custom text.

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

PowerPoint Library for C# / VB.NET Screenshot

See the full code below, use Run Example to execute.

using System;
using System.IO;
using System.Linq;
using GemBox.Presentation;
using GemBox.Presentation.Media;

class Sample
    static void Main(string[] args)
        // If using Professional version, put your serial key below.

        PresentationDocument presentation = new PresentationDocument();

        // Create new master slide.
        MasterSlide 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.
        Slide 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 System.IO
Imports GemBox.Presentation
Imports GemBox.Presentation.Media

Module Samples

    Sub Main()

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

        Dim presentation As PresentationDocument = New PresentationDocument

        ' Create New master slide.
        Dim master As MasterSlide = 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 As 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