Remove Footer from Last Page

Hello,
We have a document which have a signature text in the footer of each page, we would like to show the signature on the footer of each page except the last one, how could we accomplish this scenario?

Note: We have added the signature to the footer because we have a long text which fits to multiple. This is the way we know for repeating something in each page regardless of the page content.

Hi Ahemd,

Thanks for your inquiry. You can use IF field with PAGE and NUMPAGES fields as shown below to get the desired output. PAGE field represents number of current page while NUMPAGES represents the number of pages in document. You can make use of IF field in footer to detect last page e.g.

{ IF "{PAGE}" <> "{NUMPAGES}" "signature text" "" }

Hope this helps you. Please let us know if you have any more queries.

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.MoveToHeaderFooter(HeaderFooterType.FooterPrimary);
// { IF "{PAGE}" <> "{NUMPAGES}" "signature text" "" }
Field field = builder.InsertField("IF \"", null);
builder.MoveTo(field.Start.NextSibling.NextSibling);
builder.InsertField("PAGE", null);
builder.Write("\" <> \"");
builder.InsertField("NUMPAGES", null);
builder.Write("\" \"");
BookmarkStart bmTrue = builder.StartBookmark("bmTrue");
builder.EndBookmark("bmTrue");
builder.Write("\" \"");
BookmarkStart bmFalse = builder.StartBookmark("bmFalse");
builder.EndBookmark("bmFalse");
builder.Write("\" ");
builder.MoveToBookmark("bmTrue", true, true);
builder.Write("signature text");
bmTrue.Bookmark.Remove();
bmFalse.Bookmark.Remove();
builder.MoveToSection(0);
for (int i = 0; i < 4; i++)
{
     builder.InsertBreak(BreakType.PageBreak);
}
doc.UpdateFields();
doc.Save(MyDir + @"17.6.docx");

Hello Tahir,
Thanks alot for your prompt support, I thought about this idea, but the footer isn’t simply a text, it’s a table , can we do that with the formula you suggested ?

Hi Ahemd,

Thanks for your inquiry. Yes, you can use this approach with table also. If you face any issue, please share your input document here for our reference. We will then share the code example according to your requirement.