Add Header and Footer for All Slides in PPTX and PPT Files in C#

Hi
I am trying to add header and footer to presentation files. However footer is visible but not header. what is correct way to achieve it,

using (Presentation presentation = new Presentation(strPath))
{
    bool bIsPresent = presentation.DocumentProperties.ContainsCustomProperty("X-GalaxkeyClassification");

    if (bIsPresent == false)
    {
        presentation.DocumentProperties.SetCustomPropertyValue("X-GalaxkeyClassification", watermark);
    }
    else
    {
        presentation.DocumentProperties.GetCustomPropertyValue("X-GalaxkeyClassification", out string _val);
        KHelper.fnCaptureInfoToLogs("Galaxkey classification=" + _val);
    }


    // Get the center of the slide and calculate watermark's position
    PointF center = new PointF(presentation.SlideSize.Size.Width / 2, presentation.SlideSize.Size.Height / 2);
    float width = 300;
    float height = 300;
    float x = center.X - width / 2;
    float y = center.Y - height / 2;


    string strAddWaterText = "Classification:" + watermark + " " + strIdentity;
    // presentation.HeaderFooterManager.SetAllFootersText(strAddWaterText);
    //presentation.HeaderFooterManager.SetAllFootersVisibility(true);

    presentation.HeaderFooterManager.SetAllHeadersText(strAddWaterText);
    presentation.HeaderFooterManager.SetAllHeadersVisibility(true);



    //add watermark to master slide
    {
        IMasterSlide master = presentation.Masters[0];

        IAutoShape watermarkMasterShape = master.Shapes.AddAutoShape(Aspose.Slides.ShapeType.Rectangle, x, y, width, height);

        watermarkMasterShape.Name = watermark;

        // Set fill type
        watermarkMasterShape.FillFormat.FillType = Aspose.Slides.FillType.NoFill;
        watermarkMasterShape.LineFormat.FillFormat.FillType = Aspose.Slides.FillType.NoFill;


        // Lock Shapes from modifying
        watermarkMasterShape.ShapeLock.ShapeTypeLocked = true;
        watermarkMasterShape.ShapeLock.EditPointsLocked = true;
        watermarkMasterShape.ShapeLock.SelectLocked = true;
        watermarkMasterShape.ShapeLock.SizeLocked = true;
        watermarkMasterShape.ShapeLock.TextLocked = true;
        watermarkMasterShape.ShapeLock.PositionLocked = true;
        watermarkMasterShape.ShapeLock.GroupingLocked = true;

        // Set rotation angle
        watermarkMasterShape.Rotation = -45;

        // Set text
        ITextFrame watermarkTextFrame = watermarkMasterShape.AddTextFrame(watermark);
        IPortion watermarkPortion = watermarkTextFrame.Paragraphs[0].Portions[0];

        // Set font size and fill type of the watermark
        watermarkPortion.PortionFormat.FontHeight = 52;
        watermarkPortion.PortionFormat.FillFormat.FillType = Aspose.Slides.FillType.Solid;
        int alpha = 150, red = 200, green = 200, blue = 200;
        watermarkPortion.PortionFormat.FillFormat.SolidFillColor.Color = System.Drawing.Color.LightGray;
    }


    for (var index = 0; index < presentation.Slides.Count; index++)
    {
        // Get reference of the slide
        ISlide slide = presentation.Slides[index];

        // Add watermark shape
        IAutoShape watermarkShape = slide.Shapes.AddAutoShape(Aspose.Slides.ShapeType.Rectangle, x, y, width, height);

        watermarkShape.Name = watermark;
        // Set fill type
        watermarkShape.FillFormat.FillType = Aspose.Slides.FillType.NoFill;
        watermarkShape.LineFormat.FillFormat.FillType = Aspose.Slides.FillType.NoFill;


        // Lock Shapes from modifying
        watermarkShape.ShapeLock.ShapeTypeLocked = true;
        watermarkShape.ShapeLock.EditPointsLocked = true;
        watermarkShape.ShapeLock.SelectLocked = true;
        watermarkShape.ShapeLock.SizeLocked = true;
        watermarkShape.ShapeLock.TextLocked = true;
        watermarkShape.ShapeLock.PositionLocked = true;
        watermarkShape.ShapeLock.GroupingLocked = true;

        // Set rotation angle
        watermarkShape.Rotation = -45;

        // Set text
        ITextFrame watermarkTextFrame = watermarkShape.AddTextFrame(watermark);
        IPortion watermarkPortion = watermarkTextFrame.Paragraphs[0].Portions[0];

        // Set font size and fill type of the watermark
        watermarkPortion.PortionFormat.FontHeight = 52;
        watermarkPortion.PortionFormat.FillFormat.FillType = Aspose.Slides.FillType.Solid;
        watermarkPortion.PortionFormat.FillFormat.SolidFillColor.Color = System.Drawing.Color.LightGray;
    }
    // Save the presentation
    presentation.Save(strRetPath, Aspose.Slides.Export.SaveFormat.Pptx);
    bRet = true;
}

@krushna.barhate,

Could you please zip and attach your input presentation file and output presentation file? Also, if possible, provide a standalone VS.NET console application. Please zip the project with all resource files and provide it to us. This will help us evaluate your issue more precisely and figure it out sooner.

We also recommend you to kindly see the document with examples on Presentation Header and Footer for your complete reference.