public final class Section extends CompositeNode
Section can have one getBody() and maximum one HeaderFooter of each HeaderFooterType. Body and HeaderFooter nodes can be in any order inside Section.
A minimal valid section needs to have Body with one Paragraph.
Each section has its own set of properties that specify page size, orientation, margins etc.
You can create a copy of a section using Node.deepClone(boolean). The copy can be inserted into the same or different document.
To add, insert or remove a whole section including section break and section properties use methods of the Sections object.
To copy and insert just content of the section excluding the section break and section properties use AppendContent and PrependContent methods.
| Constructor and Description |
|---|
Section(DocumentBase doc)
Initializes a new instance of the Section class.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
accept(DocumentVisitor visitor)
Accepts a visitor.
|
void |
appendContent(Section sourceSection)
Inserts a copy of content of the source section at the end of this section.
|
void |
clearContent()
Clears the section.
|
void |
clearHeadersFooters()
Clears the headers and footers of this section.
|
void |
clearSectionAttrs() |
Section |
deepClone()
Creates a duplicate of this section.
|
void |
deleteHeaderFooterShapes()
Deletes all shapes (drawing objects) from the headers and footers of this section.
|
void |
ensureMinimum()
Ensures that the section has Body with one Paragraph.
|
java.lang.Object |
fetchInheritedSectionAttr(int key) |
java.lang.Object |
fetchSectionAttr(int key) |
Body |
getBody()
Returns the Body child node of the section.
|
java.lang.Object |
getDirectSectionAttr(int key) |
HeaderFooterCollection |
getHeadersFooters()
Provides access to the headers and footers nodes of the section.
|
int |
getNodeType()
Returns NodeType.Section.
|
PageSetup |
getPageSetup()
Returns an object that represents page setup and section properties.
|
boolean |
getProtectedForForms()
True if the section is protected for forms.
|
void |
prependContent(Section sourceSection)
Inserts a copy of content of the source section at the beginning of this section.
|
void |
setProtectedForForms(boolean value)
True if the section is protected for forms.
|
void |
setSectionAttr(int key,
java.lang.Object value) |
java.lang.String |
toString() |
acceptChildren, acceptCore, appendChild, coreRemoveSelfOnly, getChild, getChildNodes, getChildNodes, getContainer, getCount, getCurrentNode, getFirstChild, getLastChild, getNextMatchingNode, getText, hasChildNodes, indexOf, insertAfter, insertBefore, isComposite, iterator, prependChild, removeAllChildren, removeChild, removeSmartTags, selectNodes, selectSingleNodedd, deepClone, getAncestor, getAncestor, getCustomNodeId, getDocument, getNextSibling, getParentNode, getPreviousSibling, getRange, memberwiseClone, nextPreOrder, nodeTypeToString, previousPreOrder, remove, setCustomNodeId, toString, toString, visitorActionToBoolpublic Section(DocumentBase doc)
When the section is created, it belongs to the specified document, but is not yet part of the document and ParentNode is null.
To include Section into a document use Document.InsertAfter, Document.InsertBefore or Sections.Add and Section.Insert methods.
doc - The owner document.public final int getNodeType()
getNodeType in class NodeNodeType constants.public final Body getBody()
Body contains main text of the section.
Returns null if the section does not have a Body node among its children.
public final HeaderFooterCollection getHeadersFooters()
HeaderFooterCollection value.public final PageSetup getPageSetup()
public final boolean getProtectedForForms()
boolean value.public final void setProtectedForForms(boolean value)
value - The corresponding boolean value.public final Section deepClone()
public final boolean accept(DocumentVisitor visitor) throws java.lang.Exception
Enumerates over this node and all of its children. Each node calls a corresponding method on DocumentVisitor.
For more info see the Visitor design pattern.
public final void prependContent(Section sourceSection)
Only content of getBody() of the source section is copied, page setup, headers and footers are not copied.
The nodes are automatically imported if the source section belongs to a different document.
No new section is created in the destination document.
sourceSection - The section to copy content from.public final void appendContent(Section sourceSection)
Only content of getBody() of the source section is copied, page setup, headers and footers are not copied.
The nodes are automatically imported if the source section belongs to a different document.
No new section is created in the destination document.
sourceSection - The section to copy content from.public final void clearContent()
The text of getBody() is cleared, only one empty paragraph is left that represents the section break.
The text of all headers and footers is cleared, but HeaderFooter objects themselves are not removed.
public final void clearHeadersFooters()
The text of all headers and footers is cleared, but HeaderFooter objects themselves are not removed.
This makes headers and footers of this section linked to headers and footers of the previous section.
public final void deleteHeaderFooterShapes()
public final void ensureMinimum()
public final java.lang.Object getDirectSectionAttr(int key)
public final java.lang.Object fetchInheritedSectionAttr(int key)
public final java.lang.Object fetchSectionAttr(int key)
public final void setSectionAttr(int key,
java.lang.Object value)
public final void clearSectionAttrs()