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

Free Support Forum - aspose.com

Adding a header

I want to add a header that contains text at the top of every slide. How would I accomplish this?

@ashwin.sundaram,

I have observed your requirements and like to share that normal slides does not possess header inside them. The header is supported inside HandoutMaster, NotesMaster and all Notes slides. So to reflect changes in Header Footer Manger dialog of PowerPoint you need to update header/footer in HandoutMaster, NotesMaster and all Notes slides.

public static void TestHeader
{
        Presentation presentation = new Presentation(path + "handout_header_footer.pptx");

        IMasterHandoutSlide masterHandoutSlide = presentation.getMasterHandoutSlideManager().getMasterHandoutSlide();
        if (masterHandoutSlide != null)
        	updateHeaderFooterText(masterHandoutSlide);

        IMasterNotesSlide masterNotesSlide = presentation.getMasterNotesSlideManager().getMasterNotesSlide();
        if (null != masterNotesSlide)
        	updateHeaderFooterText(masterNotesSlide);
        
        for(ISlide slide : presentation.getSlides())
        {
        	INotesSlide notesSlide = slide.getNotesSlideManager().getNotesSlide();
        	if (null != notesSlide)
        		updateHeaderFooterText(notesSlide);
        }
        
        presentation.save(path + "handout_test_java.pptx", SaveFormat.Pptx);
}

public void updateHeaderFooterText(IBaseSlide master)
{
        for (IShape shape : master.getShapes())
        {
            if (shape.getPlaceholder() != null)
            {
                if (shape.getPlaceholder().getType() == PlaceholderType.Header)
                    ((IAutoShape)shape).getTextFrame().setText("HI there new header");

                if (shape.getPlaceholder().getType() == PlaceholderType.Footer)
                    ((IAutoShape)shape).getTextFrame().setText("HI there new footer");
            }
        }
}

Many Thanks,

Mudassir Fayyaz

@ashwin.sundaram,

I have observed your requirement and like to share that you have used the default empty presentation which does not have master slides for Notes and Handout. Therefore, you are unable to observe the set headers. Please try using the following source presentation on your end and you will be able to observe the headers being set in Handout or Notes master of presentation.

TestNotes.zip (26.4 KB)

Hi,

I am unable to download this file. It leads me to page with following message:

Sorry, this file is private. Only visible to topic owner and staff members.

Can you please re-share?

@tanujd_203,

Please download the requested files from this download link:
https://drive.google.com/file/d/0BzvMFhwg29yEbFpNcl84Y1BNMHM/view?usp=sharing

Thank you Mudassir Fayyaz and sundaram for your great help , i will try and come back to you if i have any doubts.

Annadatha.

Hi Fayyaz,

This seems to be previous versions, can you please point me to .net 13.x version.

Thank you,

Annadatha.

Hi Sir,

Can you please provide a link for .net 13.x on how to work with tables in footer and header of aspose slides, and how to format text in header and footer. For example i need to put a table in footer and align text to left and right after table. This text is after table , any way text is independent of table.

Thank you
Annadatha.

@annadatha.rao,

I like to share that as per Aspose policy the version published over last one year from present date are available for download only. I suggest you to please try using latest Aspose.Slides for .NET 18.12 on your end as share with us if there is still an issue.

Hi Fayyaz,

Documentation reference is for approach problem, where i can found about include table in fotter and align text please.

Thank you,
Annadatha rao…

Hi Fayyaz,

Documentation reference is for table in fotter and align text please.Can you please point the documentation please…

@annadatha.rao,

I have not been able to understand your following requirement. Can you please elaborate in the form of sample presentation and snapshot that what you actually mean be following and I shall look further in to it.