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

Free Support Forum - aspose.com

Header in pdf files

Is it possible to add a header with table,text and image in a new header on

a existing pdf files using Aspose.pdf?

All existing text and object must be 'moved' down to make Place for the new header.

Thanks in advance.

Hi Hary,

Thanks for your inquiry. You may add header in existing PDF document with table,text and image as following. However if required you have to re-size content of the page using PdfFileEditor to adjust Header/Footer contents. Please check following code snippet for the purpose.

Resize Page Contents of specific Pages in Pdf file.

Document doc = new
Document(myDir + “HellWorld.pdf”);<o:p></o:p>

Aspose.Pdf.HeaderFooter headerr = new Aspose.Pdf.HeaderFooter();

Aspose.Pdf.HeaderFooter footer = new Aspose.Pdf.HeaderFooter();

FileStream fs = new FileStream(myDir + "aspose.pdf_logo.png", FileMode.Open, FileAccess.Read);

Aspose.Pdf.Image image1 = new Aspose.Pdf.Image();

image1.FixWidth = 50;

image1.FixHeight = 50;

//Add the image into paragraphs collection of the section


//Set the ImageStream to a MemoryStream object

image1.ImageStream = fs;

Aspose.Pdf.Text.TextState textState = new Aspose.Pdf.Text.TextState();

textState.Font = FontRepository.FindFont("Helvetica");

textState.FontSize = (float)8;

Aspose.Pdf.Table table = new Aspose.Pdf.Table();

table.ColumnWidths = "200";

table.Rows.Add().Cells.Add("Aspose.pdf for .NET", textState);

table.Rows.Add().Cells.Add("August, 2014", textState);


for (int cnt = 1; cnt <= doc.Pages.Count; cnt++)


doc.Pages[cnt].Header = header;

doc.Pages[cnt].Footer = footer;


doc.Save(myDir + "Output_DOMheaderfooter.pdf");

Please feel free to contact us for any further assistance.

Best Regards,

Hi Harry,

Adding more to Tilal’s comments, the feature to automatically adjust page contents when Header/Footer are added to PDF document is already logged in our issue tracking system as PDFNEWNET-36659. The development team will investigate this requirement in details and will keep you updated on the status
of a correction.

We apologize for your inconvenience.

OK...Thanks for that.

In the mean time, I have places a small textstamp and imagestamp in the bottom.

Most of the times, there is free space on pdf files i the footer.

And it is running well. Thanks in advance.

Hi Harry,

We are glad to hear that your problem is resolved and you have managed to accomplish your requirements. However, as soon as the earlier stated requirement is implemented, we will update you within this forum thread.