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

Free Support Forum - aspose.com

Add header and footer to PDF file with dynamic length using Aspose.PDF for .NET

Dear Team,

I have to added header and footer to pdf document. I have dymanic content to header and footer.

sample codes are:

HeaderFooter footer = new HeaderFooter();

footer.setMargin(new MarginInfo(10, 20, 20, 20));

Paragraphs p = footer.getParagraphs();

TextFragment tf = new TextFragment("Adding header to document");


PageCollection pageColl = document.getPages();

for(int i=1;i<=pageColl.size();++i){

Page pg = pageColl.get_Item(i);



My query, if the content of header vary, how it will affect page layout(height of page in pdfs).

Will added header overlap existing content of will move pdf content down to add header???

Also, please share code examples to add footer to pdf document.

Hi Ganesh,

Thank for contacting support and sorry for the delayed response.

The Header is added in upper page section and Footer is added at lower page section. In case Header contents are larger, it will overlap page body contents. Please visit the following link for further details on