Table of Contents

Class Section

Namespace
iTextSharp.text
Assembly
iTextSharp.LGPLv2.Core.dll

A Section is a part of a Document containing other Sections, Paragraphs, List and/or Tables.

public class Section : List<IElement>, IList<IElement>, ICollection<IElement>, IList, ICollection, IReadOnlyList<IElement>, IReadOnlyCollection<IElement>, IEnumerable<IElement>, IEnumerable, ITextElementArray, ILargeElement, IElement
Inheritance
Section
Implements
Derived
Inherited Members
Extension Methods

Examples

Paragraph title2 = new Paragraph("This is Chapter 2", FontFactory.GetFont(FontFactory.HELVETICA, 18, Font.BOLDITALIC, new Color(0, 0, 255))); Chapter chapter2 = new Chapter(title2, 2); Paragraph someText = new Paragraph("This is some text"); chapter2.Add(someText); Paragraph title21 = new Paragraph("This is Section 1 in Chapter 2", FontFactory.GetFont(FontFactory.HELVETICA, 16, Font.BOLD, new Color(255, 0, 0))); Section section1 = chapter2.AddSection(title21); Paragraph someSectionText = new Paragraph("This is some silly paragraph in a chapter and/or section. It contains some text to test the functionality of Chapters and Section."); section1.Add(someSectionText); Paragraph title211 = new Paragraph("This is SubSection 1 in Section 1 in Chapter 2", FontFactory.GetFont(FontFactory.HELVETICA, 14, Font.BOLD, new Color(255, 0, 0))); Section section11 = section1.AddSection(40, title211, 2); section11.Add(someSectionText); strong>

Remarks

You can not construct a Section yourself. You will have to ask an instance of Section to the Chapter or Section to which you want to add the new Section.

Constructors

Section()

constructors

protected Section()

Section(Paragraph, int)

Constructs a new Section.

protected Section(Paragraph title, int numberDepth)

Parameters

title Paragraph

a Paragraph

numberDepth int

the numberDepth

Fields

Complete

Indicates if the Section will be complete once added to the document. @since iText 2.0.8

protected bool Complete

Field Value

bool

NUMBERSTYLE_DOTTED

constant

public const int NUMBERSTYLE_DOTTED = 0

Field Value

int

NUMBERSTYLE_DOTTED_WITHOUT_FINAL_DOT

A possible number style. For instance: "1.2.3" @since iText 2.0.8

public const int NUMBERSTYLE_DOTTED_WITHOUT_FINAL_DOT = 1

Field Value

int

Numbers

membervariables

protected List<int> Numbers

Field Value

List<int>

Subsections

This is the number of subsections.

protected int Subsections

Field Value

int

addedCompletely

Indicates if the Section was added completely to the document. @since iText 2.0.8

protected bool addedCompletely

Field Value

bool

bookmarkOpen

false if the bookmark children are not visible

protected bool bookmarkOpen

Field Value

bool

bookmarkTitle

The bookmark title if different from the content title

protected string bookmarkTitle

Field Value

string

indentation

The additional indentation of the content of this section.

protected float indentation

Field Value

float

indentationLeft

The indentation of this section on the left side.

protected float indentationLeft

Field Value

float

indentationRight

The indentation of this section on the right side.

protected float indentationRight

Field Value

float

notAddedYet

Indicates if this is the first time the section was added. @since iText 2.0.8

protected bool notAddedYet

Field Value

bool

numberDepth

This is the number of sectionnumbers that has to be shown before the section title.

protected int numberDepth

Field Value

int

numberStyle

The style for sectionnumbers. @since iText 2.0.8

protected int numberStyle

Field Value

int

title

This is the title of this section.

protected Paragraph title

Field Value

Paragraph

triggerNewPage

true if the section has to trigger a new page

protected bool triggerNewPage

Field Value

bool

Properties

AddedCompletely

@see com.lowagie.text.LargeElement#isAddedCompletely() @since iText 2.0.8

protected bool AddedCompletely { get; set; }

Property Value

bool

BookmarkOpen

private methods

public bool BookmarkOpen { get; set; }

Property Value

bool

a bool

BookmarkTitle

Sets the bookmark title. The bookmark title is the same as the section title but can be changed with this method.

public string BookmarkTitle { set; }

Property Value

string

Chunks

Gets all the chunks in this element.

public IList<Chunk> Chunks { get; }

Property Value

IList<Chunk>

an ArrayList

Depth

Returns the depth of this section.

public int Depth { get; }

Property Value

int

the depth

ElementComplete

@since iText 2.0.8 @see com.lowagie.text.LargeElement#isComplete()

public bool ElementComplete { get; set; }

Property Value

bool

Indentation

Get/set the indentation of the content of this Section.

public float Indentation { get; set; }

Property Value

float

the indentation

IndentationLeft

Get/set the indentation of this Section on the left side.

public float IndentationLeft { get; set; }

Property Value

float

the indentation

IndentationRight

Get/set the indentation of this Section on the right side.

public float IndentationRight { get; set; }

Property Value

float

the indentation

NotAddedYet

Indicates if this is the first time the section is added. @since iText2.0.8

public bool NotAddedYet { get; set; }

Property Value

bool

true if the section wasn't added yet

NumberDepth

Get/set the numberdepth of this Section.

public int NumberDepth { get; set; }

Property Value

int

a int

NumberStyle

Sets the style for numbering sections. Possible values are NUMBERSTYLE_DOTTED: 1.2.3. (the default) or NUMBERSTYLE_DOTTED_WITHOUT_FINAL_DOT: 1.2.3 @since iText 2.0.8

public int NumberStyle { get; set; }

Property Value

int

Title

Get/set the title of this section

public Paragraph Title { get; set; }

Property Value

Paragraph

a Paragraph

TriggerNewPage

public virtual bool TriggerNewPage { get; set; }

Property Value

bool

Type

Gets the type of the text element.

public virtual int Type { get; }

Property Value

int

a type

Methods

Add(int, object)

Adds a Paragraph, List or Table to this Section.

public void Add(int index, object o)

Parameters

index int

index at which the specified element is to be inserted

o object

an object of type Paragraph, List or Table

Add(IElement)

overriding some of the ArrayList-methods

public bool Add(IElement o)

Parameters

o IElement

an object of type Paragraph, List, Table or another Section

Returns

bool

a bool

AddAll<T>(ICollection<T>)

Adds a collection of Elements to this Section.

public bool AddAll<T>(ICollection<T> collection) where T : IElement

Parameters

collection ICollection<T>

a collection of Paragraphs, Lists and/or Tables

Returns

bool

true if the action succeeded, false if not.

Type Parameters

T

AddMarkedSection()

Adds a marked section. For use in class MarkedSection only!

public MarkedSection AddMarkedSection()

Returns

MarkedSection

AddSection(float, string)

Adds a Section to this Section and returns it.

public virtual Section AddSection(float indentation, string title)

Parameters

indentation float

the indentation of the new section

title string

the title of the new section

Returns

Section

the newly added Section

AddSection(float, string, int)

Adds a Section to this Section and returns it.

public virtual Section AddSection(float indentation, string title, int numberDepth)

Parameters

indentation float

the indentation of the new section

title string

the title of the new section

numberDepth int

the numberDepth of the section

Returns

Section

the newly added Section

AddSection(float, Paragraph)

methods that return a Section

public virtual Section AddSection(float indentation, Paragraph title)

Parameters

indentation float

the indentation of the new section

title Paragraph

the title of the new section

Returns

Section

the newly added Section

AddSection(float, Paragraph, int)

Creates a Section, adds it to this Section and returns it.

public virtual Section AddSection(float indentation, Paragraph title, int numberDepth)

Parameters

indentation float

the indentation of the new section

title Paragraph

the title of the new section

numberDepth int

the numberDepth of the section

Returns

Section

the newly added Section

AddSection(string)

Adds a Section to this Section and returns it.

public virtual Section AddSection(string title)

Parameters

title string

the title of the new section

Returns

Section

the newly added Section

AddSection(string, int)

Adds a Section to this Section and returns it.

public virtual Section AddSection(string title, int numberDepth)

Parameters

title string

the title of the new section

numberDepth int

the numberDepth of the section

Returns

Section

the newly added Section

AddSection(Paragraph)

Creates a Section, adds it to this Section and returns it.

public virtual Section AddSection(Paragraph title)

Parameters

title Paragraph

the title of the new section

Returns

Section

the newly added Section

AddSection(Paragraph, int)

Creates a Section, add it to this Section and returns it.

public virtual Section AddSection(Paragraph title, int numberDepth)

Parameters

title Paragraph

the title of the new section

numberDepth int

the numberDepth of the section

Returns

Section

the newly added Section

ConstructTitle(Paragraph, IList<int>, int, int)

Constructs a Paragraph that will be used as title for a Section or Chapter. @since iText 2.0.8

public static Paragraph ConstructTitle(Paragraph title, IList<int> numbers, int numberDepth, int numberStyle)

Parameters

title Paragraph

the title of the section

numbers IList<int>

a list of sectionnumbers

numberDepth int

how many numbers have to be shown

numberStyle int

the numbering style

Returns

Paragraph

a Paragraph object

FlushContent()

@since iText 2.0.8 @see com.lowagie.text.LargeElement#flushContent()

public void FlushContent()

GetBookmarkTitle()

Gets the bookmark title.

public Paragraph GetBookmarkTitle()

Returns

Paragraph

the bookmark title

IsChapter()

Checks if this object is a Chapter.

public bool IsChapter()

Returns

bool

true if it is a Chapter, false if it is a Section

IsContent()

@see com.lowagie.text.Element#isContent() @since iText 2.0.8

public bool IsContent()

Returns

bool

IsNestable()

@see com.lowagie.text.Element#isNestable() @since iText 2.0.8

public virtual bool IsNestable()

Returns

bool

IsSection()

methods to retrieve information

public bool IsSection()

Returns

bool

true if it is a Section, false if it is a Chapter.

IsTag(string)

Checks if a given tag corresponds with this object.

public static bool IsTag(string tag)

Parameters

tag string

the given tag

Returns

bool

true if the tag corresponds

IsTitle(string)

Checks if a given tag corresponds with a title tag for this object.

public static bool IsTitle(string tag)

Parameters

tag string

the given tag

Returns

bool

true if the tag corresponds

NewPage()

Adds a new page to the section. @since 2.1.1

public void NewPage()

Process(IElementListener)

Processes the element by adding it (or the different parts) to an IElementListener.

public bool Process(IElementListener listener)

Parameters

listener IElementListener

the IElementListener

Returns

bool

true if the element was processed successfully

Set(Properties)

Alters the attributes of this Section.

public void Set(Properties attributes)

Parameters

attributes Properties

the attributes

SetChapterNumber(int)

Changes the Chapter number.

public void SetChapterNumber(int number)

Parameters

number int