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

Free Support Forum - aspose.com

Adding image on header Footer

Hii,

Can any one help me how to add image and some text to Header and footer for a slide.

Thanks in advance,
Gangadhar.

Hi Gangadhar,


I have worked over the requirements shared by you. You can add new text and image either to header or footer shape. All you need is to identify the shape in the slide. The easiest method is to identify the shape by using Alternative Text property. You can set the user defined name to the header or footer shape that you want to modify by setting Alternative text property. Then in code you can search that shape on the basis of Alternative text property and carry out the desired operation. Another hard way to identify the desired shape is on the basis of its position. You can traverse through all shapes and select the shape on the basis of the position. For your kind reference, I have shared the sample code snippet along with source and generated presentations.

Presentation pres=new Presentation(“D:/Aspose Data/Footer1.ppt”);

Slide slide=pres.getSlideByPosition(1);

Shape shape;
for(int i=0;i<slide.getShapes().size(); i++)
{
shape=slide.getShapes().get(i);
if(shape.getAlternativeText().equals(“Footer”))
{
shape.getFillFormat().setType(FillType.PICTURE);
//Creating a stream to hold the image file
InputStream iStream = new BufferedInputStream(new FileInputStream(“C:/Users/Public/Pictures/Sample Pictures/Tulips.jpg”));
//Creating a picture object that will be used to fill the ellipse
Picture pic = new com.aspose.slides.Picture(pres, iStream);
//Adding the picture object to pictures collection of the presentation
//After the picture object is added, the picture is given a uniqe picture Id
int picId = pres.getPictures().add(pic);
//Setting the picture Id of the shape fill to the Id of the picture object
shape.getFillFormat().setPictureId(picId);
TextFrame tf=shape.getTextFrame();
tf.setText(“This is new Text”);
}
}

pres.write(“D:/Aspose Data/Footer.ppt”);


Many Thanks,