OfficeIMO

API Reference

Class

WordHeadersAndFooters

Namespace OfficeIMO.Word
Assembly OfficeIMO.Word
Modifiers static

Helper methods for adding and retrieving headers and footers in Word documents.

Inheritance

  • Object
  • WordHeadersAndFooters

Methods

AddFooterReference(OfficeIMO.Word.WordDocument document, OfficeIMO.Word.WordSection section, DocumentFormat.OpenXml.Wordprocessing.HeaderFooterValues headerFooterValue) #

Creates Footer reference in the document

Parameters

document OfficeIMO.Word.WordDocument required
section OfficeIMO.Word.WordSection required
headerFooterValue DocumentFormat.OpenXml.Wordprocessing.HeaderFooterValues required
AddHeaderReference(OfficeIMO.Word.WordDocument document, OfficeIMO.Word.WordSection section, DocumentFormat.OpenXml.Wordprocessing.HeaderFooterValues headerFooterValue) #

Creates Header reference in the document

Parameters

document OfficeIMO.Word.WordDocument required
section OfficeIMO.Word.WordSection required
headerFooterValue DocumentFormat.OpenXml.Wordprocessing.HeaderFooterValues required
AddHeadersAndFooters 2 overloads
public static Void AddHeadersAndFooters(WordDocument document) #
Returns: Void

Add default header and footers to section. You can control odd/even/first with DifferentOddAndEventPages/DifferentFirstPage properties.

Parameters

section OfficeIMO.Word.WordSection requiredposition: 0
AddHeadersAndFooters(OfficeIMO.Word.WordDocument document) #

Add default header and footers to document (section 0). You can control odd/even/first with DifferentOddAndEventPages/DifferentFirstPage properties.

Parameters

document OfficeIMO.Word.WordDocument required
AddSectionProperties(DocumentFormat.OpenXml.Packaging.WordprocessingDocument wordDocument) #

Add section property to the document

Parameters

wordDocument DocumentFormat.OpenXml.Packaging.WordprocessingDocument required
CreateSectionProperties 2 overloads
CreateSectionProperties() #

Create a new section properties container.

Returns

Empty section properties element with a unique rsid.

CreateSectionProperties(System.Boolean includeDefaultPageSettings) #

Create a new section properties container.

Parameters

includeDefaultPageSettings System.Boolean required
When true, includes default Letter page size and Normal margins.

Returns

Section properties element.

GenerateRevisionId() #

Generate a unique revision id used by InsertedRun and DeletedRun elements.

Returns

Revision identifier as decimal string.

GenerateRsid() #

Generate a unique rsid

GetFooterReference(OfficeIMO.Word.WordDocument document, OfficeIMO.Word.WordSection section, DocumentFormat.OpenXml.Wordprocessing.HeaderFooterValues headerFooterValue) #

Checks for existing footer reference. Allow checking if different odd and even pages are set

Parameters

document OfficeIMO.Word.WordDocument required
section OfficeIMO.Word.WordSection required
headerFooterValue DocumentFormat.OpenXml.Wordprocessing.HeaderFooterValues required
GetHeaderReference(OfficeIMO.Word.WordDocument document, OfficeIMO.Word.WordSection section, DocumentFormat.OpenXml.Wordprocessing.HeaderFooterValues headerFooterValue) #

Checks for existing header reference. Allow checking if different odd and even pages are set

Parameters

document OfficeIMO.Word.WordDocument required
section OfficeIMO.Word.WordSection required
headerFooterValue DocumentFormat.OpenXml.Wordprocessing.HeaderFooterValues required
MakeSureSectionIsValid(DocumentFormat.OpenXml.Wordprocessing.SectionProperties sectionProperties) #

Some documents might not have section properties with proper rsidR. This method will fix that. Due to the nature of the rsidR, it is important to have unique rsidR for each section. Otherwise, comparison of sections will not work properly.

Parameters

sectionProperties DocumentFormat.OpenXml.Wordprocessing.SectionProperties required