Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
What is this page about?
This page describes how to insert headers and footers into Word documents via Aspose.Words.
Word.Application wordApp = Application;
wordApp.Documents.Open("Add Headers and Footers.doc");
//Add Header
foreach (Word.Section section in this.Application.ActiveDocument.Sections)
{
Word.Range headerRange = section.Headers[Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].Range;
headerRange.Fields.Add(headerRange, Word.WdFieldType.wdFieldPage);
headerRange.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphRight;
}
//Add Footer
foreach (Word.Section wordSection in this.Application.ActiveDocument.Sections)
{
Word.Range footerRange = wordSection.Footers[Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].Range;
footerRange.Font.ColorIndex = Word.WdColorIndex.wdDarkRed;
footerRange.Font.Size = 20;
footerRange.Text = "Confidential";
}
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Create the headers.
builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
builder.Write("Header Text goes here...");
//add footer having current date
builder.MoveToHeaderFooter(HeaderFooterType.FooterPrimary);
builder.InsertField("Date", "");
doc.UpdateFields();
doc.Save("Insert Headers and Footers.doc");
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.