Each section in a document can have up to three headers and up to three footers (for first, even and odd pages). If you want to delete all footers in a document you need to loop through all sections and remove every footer node.
Example RemoveFooters
Deletes all footers from all sections, but leaves headers intact.
[C#]
Document doc = new Document(MyDir + "HeaderFooter.RemoveFooters.doc");
foreach (Section section in doc)
{
// Up to three different footers are possible in a section (for first, even and odd pages).
// We check and delete all of them.
HeaderFooter footer;
footer = section.HeadersFooters[HeaderFooterType.FooterFirst];
if (footer != null)
footer.Remove();
// Primary footer is the footer used for odd pages.
footer = section.HeadersFooters[HeaderFooterType.FooterPrimary];
if (footer != null)
footer.Remove();
footer = section.HeadersFooters[HeaderFooterType.FooterEven];
if (footer != null)
footer.Remove();
}
doc.Save(MyDir + "HeaderFooter.RemoveFooters Out.doc");
[Visual Basic]
Dim doc As Document = New Document(MyDir & "HeaderFooter.RemoveFooters.doc")
For Each section As Section In doc
' Up to three different footers are possible in a section (for first, even and odd pages).
' We check and delete all of them.
Dim footer As HeaderFooter
footer = section.HeadersFooters(HeaderFooterType.FooterFirst)
If Not footer Is Nothing Then
footer.Remove()
End If
' Primary footer is the footer used for odd pages.
footer = section.HeadersFooters(HeaderFooterType.FooterPrimary)
If Not footer Is Nothing Then
footer.Remove()
End If
footer = section.HeadersFooters(HeaderFooterType.FooterEven)
If Not footer Is Nothing Then
footer.Remove()
End If
Next section
doc.Save(MyDir & "HeaderFooter.RemoveFooters Out.doc")
[Java]
Document doc = new Document(getMyDir() + "HeaderFooter.RemoveFooters.doc");
for (Node sectionNode : doc)
{
Section section = (Section)sectionNode;
// Up to three different footers are possible in a section (for first, even and odd pages).
// We check and delete all of them.
HeaderFooter footer;
footer = section.getHeadersFooters().getByHeaderFooterType(HeaderFooterType.FOOTER_FIRST);
if (footer != null)
footer.remove();
// Primary footer is the footer used for odd pages.
footer = section.getHeadersFooters().getByHeaderFooterType(HeaderFooterType.FOOTER_PRIMARY);
if (footer != null)
footer.remove();
footer = section.getHeadersFooters().getByHeaderFooterType(HeaderFooterType.FOOTER_EVEN);
if (footer != null)
footer.remove();
}
doc.save(getMyDir() + "HeaderFooter.RemoveFooters Out.doc");