Header or footer is too large


hi all,

when i am trying to run the below code i am getting the following error

Pdf pdf = new Pdf();

Section section = new Section(pdf);
PageSetup ps=new PageSetup();

HeaderFooter hf1 = section.InsertHeader(HeaderFooterType.Both);

section.OddHeader = section.EvenHeader = hf1;
hf1.IsFirstPageOnly = true;
Text text = new Text(hf1);
Segment segment = new Segment(text);
segment.Content = “header for first page”;
for(int i = 1; i<= 6; i++)
Text text1 = new Text(section);
text1.IsFirstParagraph = true;
Segment segment1 = new Segment(text1);
segment1.Content = "page " + i.ToString();


Header or footer is too large.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ApplicationException: Header or footer is too large.

Source Error:

Line 406: segment1.Content = "page " + i.ToString(); Line 407: } Line 408: pdf.Save(“sample”,SaveType.OpenInAcrobat,Response); Line 409: Response.End(); Line 410: 


Dear Venkats,

Thank you for considering Aspose.

I have tested your code have not found this error. Did you use the latest hotfix?

I have changed the code “Section section = new Section(pdf);” to “Section section = pdf.Sections.Add();” to make sure the section be added to the pdf object. Also please note that when using “new PageSetup()”,the page margins are all 0.