Header at the top of the org chart?

I am using the following code to set header & footer in a ppt, when I am making an organisation chart layout.

	IShapeCollection sc = pres.getSlides().get_Item(0).getShapes();
	for (int i = 0; i < sc.size(); i++) {
		IShape shape = sc.get_Item(i);
		IPlaceholder pc = ((AutoShape) shape).getPlaceholder();
		if (pc != null && pc.getType() == PlaceholderType.Footer) {
			((AutoShape) shape).setX(((AutoShape) shape).getX() + 200);
			((AutoShape) shape).setWidth(270);
		}
	}

	pres.getHeaderFooterManager().setFooterText(footerText);
	pres.getHeaderFooterManager().setFooterVisible(true);


	IMasterNotesSlide masterNotesSlide = pres.getMasterNotesSlideManager().getMasterNotesSlide();
	if (null != masterNotesSlide) {
		for (IShape shape : masterNotesSlide.getShapes()) {
			if (shape.getPlaceholder() != null) {
				if (shape.getPlaceholder().getType() == PlaceholderType.Header) {
					((IAutoShape) shape).getTextFrame().setText("HI there new header");
				}
			}
		}
	}

The footer code is working, but I’m unable to set the header. See the image below.

Capture.PNG (14.8 KB)

How can I set the header at the top of the slide?

@tanujd_203,

I have observed your requirements for adding header text and suggest you to please visit below link for your convenience.

Hi Mudassir. I tried the mentioned code, but it didn’t work.
Below is the code that I used:

public static void main(String[] args) {


	Presentation presentation = new Presentation();

	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);
	}

	// Save Presentation
	presentation.save("C:\\Users\\v-tanuj_dhaundiyal\\Desktop\\pptxFont2.pptx", SaveFormat.Pptx);

}

public static 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");
		}
	}
}

Is there a trick that I’m missing?

@tanujd_203,

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 this source presentation on your end and you will be able to observe the headers being set in Handout or Notes master of presentation:
https://drive.google.com/file/d/0BzvMFhwg29yEbFpNcl84Y1BNMHM/view?usp=sharing