Section Class
Represents a group of Paragraphs and other Block derived elements that have a specific set of properties used to define the pages on which the text will appear, as well as other section-level properties.
public sealed class Section : Element, IContentElement
Public NotInheritable Class Section
Inherits Element
Implements IContentElement
- Inheritance:
- System.ObjectSection
Implements
Remarks
Section elements are contained directly under the root element - DocumentModel and can be accessed with Sections property.
Except holding the main document content, through Blocks property, Section can also contain HeaderFooters, that are repeated on a header or a footer of a pages showing the Section's content.
Page setup properties, like page layout and printing options, can be customized with a PageSetup property.
Constructors
Section(DocumentModel)
Initializes a new instance of the Section class.
Parameters
document
- DocumentModel
The owner document.
Section(DocumentModel, Block[])
Initializes a new instance of the Section class.
public Section(DocumentModel document, params Block[] items)
Public Sub New(document As DocumentModel, ParamArray items As Block())
Parameters
document
- DocumentModel
The owner document.
items
- Block[]
The section items.
Section(DocumentModel, IEnumerable<Block>)
Initializes a new instance of the Section class.
public Section(DocumentModel document, IEnumerable<Block> items)
Public Sub New(document As DocumentModel, items As IEnumerable(Of Block))
Parameters
document
- DocumentModel
The owner document.
items
- System.Collections.Generic.IEnumerable<Block>
The section items.
Properties
Blocks
Gets the Section's blocks.
Property Value
The Section's blocks.
Remarks
Supports all Block derived elements: Paragraph, Table and TableOfEntries.
ElementType
Gets the ElementType of this Element instance.
public override ElementType ElementType { get; }
Public Overrides ReadOnly Property ElementType As ElementType
Property Value
The ElementType of this Element instance.
Overrides
EndnoteSettings
Gets the endnote settings.
public NoteSettings EndnoteSettings { get; }
Public ReadOnly Property EndnoteSettings As NoteSettings
Property Value
The endnote settings.
Remarks
Note can be configured using NoteSettings on a document level (Footnote and Endnote) or on a section level (FootnoteSettings and EndnoteSettings. Document level settings are cloned when new Section is added to the DocumentModel.
PDF format has the following limitations:
- Footnotes are always rendered on the same page as their references.
- Footnotes that don't fit on a single page are clipped.
- Note numbering setting RestartEachPage is not supported.
HTML and TXT formats have the following limitations:
- All footnotes and then endnotes are exported at the end of the document.
- Note numbering setting RestartEachPage is not supported.
FootnoteSettings
Gets the footnote settings.
public NoteSettings FootnoteSettings { get; }
Public ReadOnly Property FootnoteSettings As NoteSettings
Property Value
The footnote settings.
Remarks
Note can be configured using NoteSettings on a document level (Footnote and Endnote) or on a section level (FootnoteSettings and EndnoteSettings. Document level settings are cloned when new Section is added to the DocumentModel.
PDF format has the following limitations:
- Footnotes are always rendered on the same page as their references.
- Footnotes that don't fit on a single page are clipped.
- Note numbering setting RestartEachPage is not supported.
HTML and TXT formats have the following limitations:
- All footnotes and then endnotes are exported at the end of the document.
- Note numbering setting RestartEachPage is not supported.
HeadersFooters
Gets the Section's headers / footers.
public HeaderFooterCollection HeadersFooters { get; }
Public ReadOnly Property HeadersFooters As HeaderFooterCollection
Property Value
The Section's headers / footers.
Remarks
Since HeaderFooter class is sealed, only supported element in this collection is HeaderFooter.
HeaderFooterCollection cannot contain multiple HeaderFooter elements with equal HeaderFooterType.
Following rules apply for HeaderFooterType headers / footers contained in a collection:
- HeaderDefault / FooterDefault - header / footer will be applied to every page in a section.
- HeaderEven / FooterEven - header / footer will be applied to only even pages in a section. Overrides HeaderDefault / FooterDefault on even pages, if also contained in a collection.
- HeaderFirst / FooterFirst - header / footer will be applied to only first page in a section. Overrides both HeaderDefault / FooterDefault and HeaderEven / FooterEven on first page, if also contained in a collection.
See Also
PageSetup
Gets or sets the page setup.
Property Value
The page setup.
Parent
Gets the parent DocumentModel of this Section instance.
Property Value
The parent DocumentModel of this Section instance.
ParentCollection
Gets the SectionCollection that contains this Section instance.
public SectionCollection ParentCollection { get; }
Public ReadOnly Property ParentCollection As SectionCollection
Property Value
The SectionCollection that contains this Section instance.
ProtectedForForms
When true, the Section will be protected when the document is protected for forms.
Property Value
- System.Boolean
true if the Section will be protected when the document is protected for forms; otherwise, false.
Remarks
When a section is protected for forms, you can select and modify text only in form fields.
SectionPropertiesRevision
Gets or sets the revision information for the section properties.
public SectionPropertiesRevision SectionPropertiesRevision { get; set; }
Public Property SectionPropertiesRevision As SectionPropertiesRevision
Property Value
The revision information for the section properties.
Methods
Clone(Boolean)
Clones this Section instance.
public Section Clone(bool cloneDescendants)
Public Function Clone(cloneDescendants As Boolean) As Section
Parameters
cloneDescendants
- System.Boolean
If set to true clone all descendants recursively; otherwise clone only current Section.
Returns
Remarks
Document content element instance can exist only in a one place in the document.
If you want to insert document content element into some other part of the same document, then clone the element and insert its clone.
If you want to insert document content element into another document, then you should first import it into another document with Import<T>(T, Boolean, Boolean) method and then insert the imported element.
For more information, see cloning example.
Inherited Properties
Content | Gets the content of the current Element. (Inherited from Element) |
Document | Gets the owner document. (Inherited from Element) |
Inherited Methods
GetChildElements(System.Boolean) | Gets the child elements. (Inherited from Element) |
GetChildElements(System.Boolean, ElementType[]) | Gets the child elements filtered by ElementType. (Inherited from Element) |
GetParentElements() | Gets the parent elements. (Inherited from Element) |
GetParentElements(ElementType[]) | Gets the parent elements. (Inherited from Element) |