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

Free Support Forum - aspose.com

Write text in footer

How i can write in footer ONLY at LAST page?

@azamatik471 There is no built-in way to show footer only on the last page in MS Word documents. However, you can achieve this using conditional IF field. You can insert a field like the following into the footer of your document:
{ IF { NUMPAGES } = { PAGE } "This Footer will be shown only on the last page" "" }
In this case the text will be displayed only when condition pass. here is how this can be done programmatically:

Document doc = new Document(@"C:\Temp\in.docx");
DocumentBuilder builder = new DocumentBuilder(doc);
builder.MoveToDocumentEnd();

// Move to primary footer.
builder.MoveToHeaderFooter(HeaderFooterType.FooterPrimary);
// Construct a conditional field
Field fieldIf = builder.InsertField("IF ");
builder.MoveTo(fieldIf.Separator);
builder.InsertField(FieldType.FieldNumPages, false);
builder.Write(" = ");
builder.InsertField(FieldType.FieldPage, false);
builder.Write(" \"This Footer will be shown only on the last page\" \"\"");

doc.Save(@"C:\Temp\out.docx");

Here are input and output documents: in.docx (12.3 KB) out.docx (10.4 KB)

Please note the code demonstrated the basic idea and it should be adjusted if, for example, your document already have primary footer.