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);

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


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.