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

Free Support Forum - aspose.com

Remove Header Footer Only from First Page

Hi There,


I want to remove Header Footer Only from First Page but when i try to remove, it removes the header footer from first two pages. Here is my piece of code that i’m using to remove from first page;

HeaderFooter footer;
HeaderFooter header;
footer = doc.Sections[0].HeadersFooters[HeaderFooterType.FooterFirst];
header = doc.Sections[0].HeadersFooters[HeaderFooterType.HeaderFirst];

if (footer != null)
footer.Remove();
if (header != null)
header.Remove();
Please check attached input and output documents.

Hi Ahmed,

Sorry, I do not see any header/footer when I open your HTML in a browser or MS Word. Same is the case with Aspose.Words; there is no header/footer when we convert it to DOC/DOCX. Can you please share the HTML and code you used to generate your output Word document (Testdoc(7).doc)?

Best Regards,

Hi Ijaz,


My html does not contains any header footer so i’m creating header footer using aspose.words for .net. Here is my code to create header footer;

Aspose.Words.Document doc = new Aspose.Words.Document();
DocumentBuilder builder = new DocumentBuilder(doc);
//To set Header and Footer
builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
builder.Write(“Aspose.Words Header/Footer Creation For School City.”);
builder.MoveToHeaderFooter(HeaderFooterType.FooterPrimary);
builder.StartTable();
builder.InsertCell();
builder.Write(“Powered by SchoolCity Inc. | www.schoolcity.com”);
builder.CellFormat.Borders.Left.Color = Color.White;
builder.CellFormat.Borders.Bottom.Color = Color.White;
builder.CellFormat.Borders.Right.Color = Color.White;
builder.InsertCell();
builder.CellFormat.LeftPadding = 190;
builder.CellFormat.PreferredWidth = PreferredWidth.Auto;
builder.CurrentParagraph.ParagraphFormat.Alignment = ParagraphAlignment.Right;
builder.Write(“Page “);
builder.InsertField(“PAGE”, “”);
builder.Write(” of “);
builder.InsertField(“NUMPAGES”, “”);
builder.Write(” .”);
builder.CellFormat.Borders.Left.Color = Color.White;
builder.CellFormat.Borders.Right.Color = Color.White;
builder.CellFormat.Borders.Bottom.Color = Color.White;
builder.EndRow();
builder.EndTable().Alignment = TableAlignment.Center;
builder.MoveToDocumentEnd();

Hi Ahmed,

As you are adding header and footer using Aspose.Words, you can use PageSetup.DifferentFirstPageHeaderFooter to leave first page without any header/footer.

DocumentBuilder builder = new DocumentBuilder(doc);

//To set Header and Footer

PageSetup ps = builder.PageSetup;

ps.DifferentFirstPageHeaderFooter = true;

builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);

builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;

builder.Write("Aspose.Words Header/Footer Creation For School City.");<?xml:namespace prefix = "o" ns = "urn:schemas-microsoft-com:office:office" />

Best Regards,