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

Free Support Forum - aspose.com

How to include a image into pdf header

hi aspose,

Thanks for the previous replies. As i told we are using aspose.pdf. there is a need for me to insert a image into the header of the pdf which iam creating form aspose.words.

can you please tell us how can i insert a image into the header of the pdf.

pdf.BindXML(objMemoryStream, null);

i need to modify the header of the above pdf object and insert a image into it.

Thanks in advance.

Hi,

You can use the following code to add image to header:

Aspose.Pdf.Section sec1 = pdf.Sections[0];
Aspose.Pdf.HeaderFooter hf1 = new Aspose.Pdf.HeaderFooter(sec1);
//Set the header of odd pages of the PDF document
sec1.OddHeader = hf1;
//Set the header of even pages of the PDF document
sec1.EvenHeader = hf1;
//Create an image object in the section
Aspose.Pdf.Image image1 = new Aspose.Pdf.Image(hf1);
//Add image object into the Paragraphs collection of the section
hf1.Paragraphs.Add(image1);
//Set the path of image file
image1.ImageInfo.File = @"E:\NeedToTest\PDF\8.16\asposeBanner.gif";
//Set the type of image using ImageFileType enumeration
image1.ImageInfo.ImageFileType = ImageFileType.Gif;

Repeat the above statements for all sections in pdf.

Thanks.