HeaderFooterCollectionItem Property (HeaderFooterType) |
Namespace: Aspose.Words
// Open the template document, containing obsolete copyright information in the footer Document doc = new Document(MyDir + "Footer.docx"); HeaderFooterCollection headersFooters = doc.FirstSection.HeadersFooters; HeaderFooter footer = headersFooters[HeaderFooterType.FooterPrimary]; FindReplaceOptions options = new FindReplaceOptions { MatchCase = false, FindWholeWordsOnly = false }; int currentYear = System.DateTime.Now.Year; footer.Range.Replace("(C) 2006 Aspose Pty Ltd.", $"Copyright (C) {currentYear} by Aspose Pty Ltd.", options); doc.Save(ArtifactsDir + "HeaderFooter.ReplaceText.doc");
Document doc = new Document(MyDir + "Header and footer types.docx"); foreach (Section section in doc.OfType<Section>()) { // 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 = section.HeadersFooters[HeaderFooterType.FooterFirst]; footer?.Remove(); // Primary footer is the footer used for odd pages footer = section.HeadersFooters[HeaderFooterType.FooterPrimary]; footer?.Remove(); footer = section.HeadersFooters[HeaderFooterType.FooterEven]; footer?.Remove(); } doc.Save(ArtifactsDir + "HeaderFooter.RemoveFooters.docx");