We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Add Header Footer to file pptx

Hi


Is there anyone who can explain me how to add Header footer (slide number) to a power point document 2007?

thanks a lot

An
1 Like

Hi Quang,

Thanks for your interest in Aspose.Slides.

Please use the following code snippet to set the header/footer of a slide. Please visit documentation of
HeaderFooter class. For a list of all members of this class, see HeaderFooter Members.

//Create the presentation
Presentation pres = new Presentation();
//Get first slide
Slide sld = pres.GetSlideByPosition(1);
//Access the Header / Footer of the slide
HeaderFooter hf = sld.HeaderFooter;

hf.PageNumberVisible = true;
hf.FooterVisible = true;
hf.HeaderVisible = true;
hf.DateTimeVisible = true;
hf.DateTimeFormat = DateTimeFormat.DateTime_dMMMMyyyy;
hf.HeaderText = “Header Text”;
hf.FooterText = “Footer Text”;

//Write the presentation to the disk
pres.Write(@“d:\pptx\HeadFoot.ppt”);

Hi

Thanks for your answers, however i was wondering whether that code snippet works also with the version power point 2007.
My application reads a file with extension .pptx
PresentationEx pres = new PresenationEx(‘filepath.pptx’)

Regards,

Hi Quang,

I regret to share that MS PowerPoint
2007 does not add real headers and footers, rather it adds
normal rectangle shapes as headers and footers. So, there is no classes
or properties related to headers and footers in Aspose.Slides.Pptx.

An issue with ID 13855 already exists in our issue tracking system. This thread has also been linked with the same issue, so that you may be automatically notified, once the issue is resolved.

We apologize for your inconvenience


Thanks, it’s working fine. I need to know about how to add a footer text into a specific slide in pptx c#.
Example: Slide2

@Boopathi_Palanisamy,

I suggest you to please try using following sample code using latest Aspose.Slides for .NET 18.6 on your end.

presentation.Slides[0].HeaderFooterManager.SetFooterText("Test");
presentation.Slides[0].HeaderFooterManager.SetFooterVisibility(true);

@mudassir.fayyaz,
Thank’s for your quick response.It working well as of you told.

Can I add footer to all slides?

@Boopathi_Palanisamy,

I suggest you to please try using following sample code.

pres.HeaderFooterManager.SetAllFootersText("Test");
pres.HeaderFooterManager.SetAllFootersVisibility(true);
pres.Save(@"C:\Aspose Data\TestFooter.pptx", Aspose.Slides.Export.SaveFormat.Pptx);

Dear Sir,

I try adding header , but no luck. Am i doing any mistake. Please help me.

i tried following

        pres.HeaderFooterManager.SetAllHeadersText("Adding Header");
        pres.HeaderFooterManager.SetAllHeadersVisibility(true);

@annadatha.rao,

Can you please provide the complete sample code along with source and generated presentations. I assume that you are using the latest version Aspose.Slides for .NET 18.12 on your end.

Dear Sir,

Using version 18.11 , and here is the code , just started learning aspose pptx.

    private void btn_GenerateSlides_Click(object sender, EventArgs e)
    {
        string outputFile = @"G:\CURRENT WORK\work\aspose_word\aspose_word\output\HelloWorld.pptx";

        if (File.Exists(outputFile))
        {
            File.Delete(outputFile);
        }

        // Instantiate Presentation
        Presentation pres = new Presentation();
        //Get the first slide
        ISlide sld = (ISlide)pres.Slides[0];
        //Add an AutoShape of Rectangle type
        IAutoShape ashp = sld.Shapes.AddAutoShape(ShapeType.Rectangle, 150, 75, 150, 50);

        //Add ITextFrame to the Rectangle
        ashp.AddTextFrame("Hello World");


        pres.HeaderFooterManager.SetAllHeadersText("Adding Header");
        pres.HeaderFooterManager.SetAllHeadersVisibility(true);
        pres.HeaderFooterManager.SetAllFootersText("Adding Footer");
        pres.HeaderFooterManager.SetAllFootersVisibility(true);

        //Change the text color to Black (which is White by default)
        ashp.TextFrame.Paragraphs[0].Portions[0].PortionFormat.FillFormat.FillType = FillType.Solid;
        ashp.TextFrame.Paragraphs[0].Portions[0].PortionFormat.FillFormat.SolidFillColor.Color = Color.Black;

        //Change the line color of the rectangle to White
        ashp.ShapeStyle.LineColor.Color = System.Drawing.Color.White;

        //Remove any fill formatting in the shape
        ashp.FillFormat.FillType = FillType.NoFill;

        //Write the presentation to disk
        pres.Save(@"G:\CURRENT WORK\work\aspose_word\aspose_word\output\HelloWorld.pptx", SaveFormat.Pptx);
    }

I HAVE CHANGED TO LATEST VERSION Aspose.Slides for .NET 18.12 ANY SOLUTION MY PROBLEM.

THANK YOU,
ANNADATHA.

@annadatha.rao,

I suggest you to please proceed to following links for how to add headers in slides and in which view they are supported.