Create header and footer

Hi guys,

I want to create header and footer for all of pages in document.
I just created successful, but I try to insert border top for footer, however I can’t.
Please give me solution for this case.

Thanks,
Hanh

Hi Hanh,

Thanks for your inquiry. Please refer to the following articles:

https://docs.aspose.com/words/net/working-with-headers-and-footers/

Also, could you please attach your “expected document” here for our reference. We will investigate the structure of your expected document as to how you want your final output be generated like. You can create expected document using Microsoft Word. We will then provide you code to achieve the same using Aspose.Words.

Best regards,

Please see my file containing footer is my expect output

Hi Hanh,

Thanks for your inquiry. Please use the following code:

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.MoveToHeaderFooter(HeaderFooterType.FooterPrimary);
Table tab = builder.StartTable();
builder.InsertCell();
builder.Writeln();
builder.InsertCell();
builder.Writeln();
builder.EndRow();
builder.EndTable();
tab.ClearBorders();
foreach (Cell cell in tab.FirstRow)
cell.CellFormat.Borders.Top.LineWidth = 1;
doc.Save(MyDir + @"15.7.0.docx");

I hope, this helps.

Best regards,