Table of Contents

Class PdfSectionCollection

Namespace
Syncfusion.Pdf
Assembly
Syncfusion.Pdf.Portable.dll

Represents the collection of the PdfSection.

public class PdfSectionCollection : IEnumerable
Inheritance
PdfSectionCollection
Implements
Inherited Members

Examples

//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Get the document section collection.
PdfSectionCollection sections = document.Sections;
//Add the section.
PdfSection section = sections.Add();
//Add pages to the section.
PdfPage page = section.Pages.Add();
//Create PDF graphics for the page.
PdfGraphics graphics = page.Graphics;
//Set the font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 20);
//Draw the text.
graphics.DrawString("Hello World!!!", font, PdfBrushes.Black, new PointF(0, 0));
//Save the document.
document.Save("Output.pdf");
//Close the document.
document.Close(true);
'Create a new PDF document.
Dim document As New PdfDocument()
'Get the document section collection.
Dim sections As PdfSectionCollection = document.Sections
'Add the section.
Dim section As PdfSection = sections.Add()
'Add pages to the section.
Dim page As PdfPage = section.Pages.Add()
'Create PDF graphics for the page.
Dim graphics As PdfGraphics = page.Graphics
'Set the font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 20)
'Draw the text.
graphics.DrawString("Hello World!!!", font, PdfBrushes.Black, New PointF(0, 0))
'Save the document.
document.Save("Output.pdf")
'Close the document.
document.Close(True)

Properties

Count

Gets the total number of PdfSection in a document.Read only.

public int Count { get; }

Property Value

int

The count of the sections.

Examples

//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Add the section.
PdfSection section = document.Sections.Add();
//Add pages to the section.
PdfPage page = section.Pages.Add();
//Add another section.
PdfSection section1 = document.Sections.Add();
//Add pages to the section1.
PdfPage page1 = section1.Pages.Add();
//Get the sections count.
int count = document.Sections.Count;
//Save the document.
document.Save("Output.pdf");
//Close the document.
document.Close(true);
'Create a new PDF document.
Dim document As New PdfDocument()
'Add the section.
Dim section As PdfSection = document.Sections.Add()
'Add pages to the section.
Dim page As PdfPage = section.Pages.Add()
'Add another section.
Dim section1 As PdfSection = document.Sections.Add()
'Add pages to the section1.
Dim page1 As PdfPage = section1.Pages.Add()
'Get the sections count.
Dim count As Integer = document.Sections.Count
'Save the document.
document.Save("Output.pdf")
'Close the document.
document.Close(True)
See Also

this[int]

Gets the PdfSection at the specified index.Read only.

public PdfSection this[int index] { get; }

Parameters

index int

Property Value

PdfSection

Examples

//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Add the section.
PdfSection section = document.Sections.Add();
//Add pages to the section1.
PdfPage page = section.Pages.Add();
//Get the section from collection.
PdfSection section2 = document.Sections[0];
//Save the document.
document.Save("Output.pdf");
//Close the document.
document.Close(true);
'Create a new PDF document.
Dim document As New PdfDocument()
'Add the section.
Dim section As PdfSection = document.Sections.Add()
'Add pages to the section1.
Dim page As PdfPage = section.Pages.Add()
'Get the section from collection.
Dim section2 As PdfSection = document.Sections(0)
'Save the document.
document.Save("Output.pdf")
'Close the document.
document.Close(True)
See Also

Methods

Add()

Creates a new PdfSection and adds it to the collection.

public PdfSection Add()

Returns

PdfSection

Created section object.

Examples

//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Add the section.
PdfSection section = document.Sections.Add();
//Add pages to the section.
PdfPage page = section.Pages.Add();
//Add another section.
PdfSection section1 = document.Sections.Add();
//Add the pages to section1.
PdfPage page1 = section1.Pages.Add();
//Create PDF graphics for the page.
PdfGraphics graphics = page.Graphics;
//Set the font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 20);
//Draw the text.
graphics.DrawString("Hello World!!!", font, PdfBrushes.Black, new PointF(0, 0));
//Save the document.
document.Save("Output.pdf");
//Close the document.
document.Close(true);
'Create a new PDF document.
Dim document As New PdfDocument()
'Add the section.
Dim section As PdfSection = document.Sections.Add()
'Add pages to the section.
Dim page As PdfPage = section.Pages.Add()
'Add another section.
Dim section1 As PdfSection = document.Sections.Add()
'Add the pages to section1.
Dim page1 As PdfPage = section1.Pages.Add()
'Create PDF graphics for the page.
Dim graphics As PdfGraphics = page.Graphics
'Set the font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 20)
'Draw the text.
graphics.DrawString("Hello World!!!", font, PdfBrushes.Black, New PointF(0, 0))
'Save the document.
document.Save("Output.pdf")
'Close the document.
document.Close(True)
See Also

Contains(PdfSection)

Checks whether the collection contains the specified section.

public bool Contains(PdfSection section)

Parameters

section PdfSection

The PdfSection

Returns

bool

True - if the sections belongs to the collection, False otherwise.

Examples

//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Add the section
PdfSection section = document.Sections.Add();
//Add pages to the section
PdfPage page = section.Pages.Add();
//Add the section
PdfSection section1 = document.Sections.Add();
//Add pages to the section1
PdfPage page1 = section1.Pages.Add();
//Check whether the specified section is in the collection
bool isExists = document.Sections.Contains(section1);
//Save the document.
document.Save("Output.pdf");
//Close the document.
document.Close(true);
'Create a new PDF document.
Dim document As New PdfDocument()
'Add the section
Dim section As PdfSection = document.Sections.Add()
'Add pages to the section
Dim page As PdfPage = section.Pages.Add()
'Add the section
Dim section1 As PdfSection = document.Sections.Add()
'Add pages to the section1
Dim page1 As PdfPage = section1.Pages.Add()
'Check whether the specified section is in the collection
Dim isExists As Boolean = document.Sections.Contains(section1)
'Save the document.
document.Save("Output.pdf")
'Close the document.
document.Close(True)
See Also

GetEnumerator()

Returns an enumerator that iterates through a collection.

public IEnumerator GetEnumerator()

Returns

IEnumerator

An IEnumerator object that can be used to iterate through the collection.

See Also

IndexOf(PdfSection)

Determines the index of the specified PdfSection .

public int IndexOf(PdfSection section)

Parameters

section PdfSection

The section which is to be found the index.

Returns

int

The index of the specified section.

Examples

//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Add the section.
PdfSection section = document.Sections.Add();
//Add pages to the section.
PdfPage page = section.Pages.Add();
//Add another section.
PdfSection section1 = document.Sections.Add();
//Add pages to the section1.
PdfPage page1 = section1.Pages.Add();
//Get the index of the specified section.
int index = document.Sections.IndexOf(section);
//Save the document.
document.Save("Output.pdf");
//Close the document.
document.Close(true);
'Create a new PDF document.
Dim document As New PdfDocument()
'Add the section.
Dim section As PdfSection = document.Sections.Add()
'Add pages to the section.
Dim page As PdfPage = section.Pages.Add()
'Add another section.
Dim section1 As PdfSection = document.Sections.Add()
'Add pages to the section1.
Dim page1 As PdfPage = section1.Pages.Add()
'Get the index of the specified section.
Dim index As Integer = document.Sections.IndexOf(section)
'Save the document.
document.Save("Output.pdf")
'Close the document.
document.Close(True)
See Also

Insert(int, PdfSection)

Inserts the PdfSection at the specified index.

public void Insert(int index, PdfSection section)

Parameters

index int

The index of the section to be added.

section PdfSection

The section to be added.

Examples

//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Add the section.
PdfSection section = document.Sections.Add();
//Add pages to the section.
PdfPage page = section.Pages.Add();
//Add the section.
PdfSection section1 = document.Sections.Add();
//Add pages to the section1.
PdfPage page1 = section1.Pages.Add();
//insert the section at specified index.
document.Sections.Insert(0, section1);
//Save the document.
document.Save("Output.pdf");
//Close the document.
document.Close(true);
'Create a new PDF document.
Dim document As New PdfDocument()
'Add the section.
Dim section As PdfSection = document.Sections.Add()
'Add pages to the section.
Dim page As PdfPage = section.Pages.Add()
'Add the section.
Dim section1 As PdfSection = document.Sections.Add()
'Add pages to the section1.
Dim page1 As PdfPage = section1.Pages.Add()
'insert the section at specified index.
document.Sections.Insert(0, section1)
'Save the document.
document.Save("Output.pdf")
'Close the document.
document.Close(True)

Remarks

Index value should start from zero.

See Also

See Also