How can I add image into header/footer?


#1

Hi,

is that possible to add an image into the HeaderFooter object ?

Thanks


#2

Hi vpetrov,

Thanks for considering Aspose.

Here are sample codes adding a local image into HeaderFooter Object:

=========================================================

Pdf pdf = new Pdf();
Aspose.Pdf.Section sec1 = pdf.Sections.Add();
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;
pdf.Save(@"E:\NeedToTest\PDF\8.16\test.pdf");

==========================================================