Table of Contents

Class PdfPageCountField

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

Represents total PDF document page count automatic field.

public class PdfPageCountField : PdfSingleValueField
Inheritance
PdfPageCountField
Inherited Members

Examples

// Create a new document
PdfDocument doc = new PdfDocument();         
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12f);
PdfBrush brush = PdfBrushes.Black;
// Creates page count field
PdfPageCountField pageCount = new PdfPageCountField(font);
pageCount.NumberStyle = PdfNumberStyle.Numeric;
for (int i = 0; i != 2; i++)
{
 PdfPage page = doc.Pages.Add();
 pageCount.Draw(page.Graphics);
}
doc.Save("PageCountField.pdf");
doc.Close(true);
' Create a new document
Dim doc As PdfDocument = New PdfDocument()
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12f)
Dim brush As PdfBrush = PdfBrushes.Black
' Creates page count field
Dim pageCount As PdfPageCountField = New PdfPageCountField(font)
pageCount.NumberStyle = PdfNumberStyle.Numeric
For i As Integer = 0 To 1
 Dim page As PdfPage = doc.Pages.Add()
 pageCount.Draw(page.Graphics)
Next i
doc.Save("PageCountField.pdf")
doc.Close(True);

Constructors

PdfPageCountField()

Initializes a new instance of the PdfPageCountField class.

public PdfPageCountField()

Examples

//Create a new document.
PdfDocument document = new PdfDocument();
//Create a new page.
PdfPage page = document.Pages.Add();
//Create new instance of PDF font.
PdfTrueTypeFont font = new PdfTrueTypeFont(new Font("Tahoma", 10f), true);
//Create new instance of PDF brush.
PdfSolidBrush brush = new PdfSolidBrush(Color.Black);
SizeF bounds = page.GetClientSize();
//Create new instance of page count field.
PdfPageCountField pageCount = new PdfPageCountField();
//Set font for page count field.
pageCount.Font = font;
//Set brush for page count field.
pageCount.Brush = brush;
//Set size for page count field.
pageCount.Size = new SizeF(100, 50);
//Set location for page count field.
pageCount.Location = new PointF(110, 20);
//Set number style for page count field.
pageCount.NumberStyle = PdfNumberStyle.Numeric;
for (int i = 0; i != 100; i++)
{
//Draw the text.
page.Graphics.DrawString("Total page count :", font, PdfBrushes.Blue, new PointF(20, 20));
//Draw the page count field.
pageCount.Draw(page.Graphics);
//Add new page to DPF document.
page = document.Pages.Add();
}
//Save and close the document.
document.Save("Output.pdf");
document.Close(true);
'Create a new document.
Dim document As PdfDocument = New PdfDocument()
'Create a new page.
Dim page As PdfPage = document.Pages.Add()
'Create new instance of PDF font.
Dim font As PdfTrueTypeFont = New PdfTrueTypeFont(New Font("Tahoma", 10.0F), True)
'Create new instance of PDF brush.
Dim brush As PdfSolidBrush = New PdfSolidBrush(Color.Black)
Dim bounds As SizeF = page.GetClientSize()
'Create new instance of page count field.
Dim pageCount As PdfPageCountField = New PdfPageCountField()
'Set font for page count field.
pageCount.Font = font
'Set brush for page count field.
pageCount.Brush = brush
'Set size for page count field.
pageCount.Size = New SizeF(100, 50)
'Set location for page count field.
pageCount.Location = New PointF(110, 20)
'Set number style for page count field.
pageCount.NumberStyle = PdfNumberStyle.Numeric
For i As Integer = 0 To 99
'Draw the text.
page.Graphics.DrawString("Total page count :", font, PdfBrushes.Blue, New PointF(20, 20))
'Draw the page count field.
pageCount.Draw(page.Graphics)
'Add new page to PDF document.
page = document.Pages.Add()
Next i
'Save and close the document.
document.Save("Output.pdf")
document.Close(True)
See Also

PdfPageCountField(PdfFont)

Initializes a new instance of the PdfPageCountField class with PdfFont.

public PdfPageCountField(PdfFont font)

Parameters

font PdfFont

A PdfFont object that specifies the font attributes (the family name, the size, and the style of the font) to use.

Examples

// Creates a new document
PdfDocument doc = new PdfDocument();         
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12f);
// Creates page count field
PdfPageCountField pageCount = new PdfPageCountField(font);
pageCount.NumberStyle = PdfNumberStyle.Numeric;
for (int i = 0; i != 2; i++)
{
 PdfPage page = doc.Pages.Add();
 pageCount.Draw(page.Graphics);
}
doc.Save("PageCountField.pdf");
doc.Close(true);
' Creates a new document
Dim doc As PdfDocument = New PdfDocument()
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12f)
' Creates page count field
Dim pageCount As PdfPageCountField = New PdfPageCountField(font)
pageCount.NumberStyle = PdfNumberStyle.Numeric
For i As Integer = 0 To 1
 Dim page As PdfPage = doc.Pages.Add()
 pageCount.Draw(page.Graphics)
Next i
doc.Save("PageCountField.pdf")
doc.Close(True);
See Also

PdfPageCountField(PdfFont, RectangleF)

Initializes a new instance of the PdfPageCountField class with PdfFont and rectangle bounds

public PdfPageCountField(PdfFont font, RectangleF bounds)

Parameters

font PdfFont

A PdfFont object that specifies the font attributes (the family name, the size, and the style of the font) to use.

bounds RectangleF

The rectangle bounds of the field.

Examples

//Creates a new document.
PdfDocument doc = new PdfDocument();         
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12f);
RectangleF rect = new RectangleF(10, 10, 50, 30);
//Creates page count field.
PdfPageCountField pageCount = new PdfPageCountField(font,rect);
pageCount.NumberStyle = PdfNumberStyle.Numeric;
for (int i = 0; i != 2; i++)
{
 PdfPage page = doc.Pages.Add();
 pageCount.Draw(page.Graphics);
}
//Save and close the document.
doc.Save("PageCountField.pdf");
doc.Close(true);
'Creates a new document.
Dim doc As PdfDocument = New PdfDocument()
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12f)
Dim rect As RectangleF = New RectangleF(10, 10, 50, 30)
'Creates page count field.
Dim pageCount As PdfPageCountField = New PdfPageCountField(font)
pageCount.NumberStyle = PdfNumberStyle.Numeric
For i As Integer = 0 To 1
 Dim page As PdfPage = doc.Pages.Add()
 pageCount.Draw(page.Graphics)
Next i
'Save and close the document.
doc.Save("PageCountField.pdf")
doc.Close(True);
See Also

PdfPageCountField(PdfFont, PdfBrush)

Initializes a new instance of the PdfPageCountField class with PdfFont and PdfBrush.

public PdfPageCountField(PdfFont font, PdfBrush brush)

Parameters

font PdfFont

A PdfFont object that specifies the font attributes (the family name, the size, and the style of the font) to use.

brush PdfBrush

A PdfBrush object that is used to fill the string.

Examples

//Creates a new document.
PdfDocument doc = new PdfDocument();         
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12f);
PdfBrush brush = PdfBrushes.Black;
//Creates page count field.
PdfPageCountField pageCount = new PdfPageCountField(font,brush);
pageCount.NumberStyle = PdfNumberStyle.Numeric;
for (int i = 0; i != 2; i++)
{
 PdfPage page = doc.Pages.Add();
 pageCount.Draw(page.Graphics);
}
//Save and close the document.
doc.Save("PageCountField.pdf");
doc.Close(true);
'Creates a new document.
Dim doc As PdfDocument = New PdfDocument()
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12f)
Dim brush As PdfBrush = PdfBrushes.Black
'Creates page count field.
Dim pageCount As PdfPageCountField = New PdfPageCountField(font)
pageCount.NumberStyle = PdfNumberStyle.Numeric
For i As Integer = 0 To 1
 Dim page As PdfPage = doc.Pages.Add()
 pageCount.Draw(page.Graphics)
Next i
'Save and close the document.
doc.Save("PageCountField.pdf")
doc.Close(True);
See Also

Properties

NumberStyle

Gets or sets the number style.

public PdfNumberStyle NumberStyle { get; set; }

Property Value

PdfNumberStyle

The number style.

Examples

// Creates a new document
PdfDocument doc = new PdfDocument();         
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12f);
PdfBrush brush = PdfBrushes.Black;
// Creates page count field
PdfPageCountField pageCount = new PdfPageCountField(font);
pageCount.NumberStyle = PdfNumberStyle.Numeric;
for (int i = 0; i != 2; i++)
{
 PdfPage page = doc.Pages.Add();
 pageCount.Draw(page.Graphics);
}
doc.Save("PageCountField.pdf");
doc.Close(true);
' Creates a new document
Dim doc As PdfDocument = New PdfDocument()
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12f)
Dim brush As PdfBrush = PdfBrushes.Black
' Creates page count field
Dim pageCount As PdfPageCountField = New PdfPageCountField(font)
pageCount.NumberStyle = PdfNumberStyle.Numeric
For i As Integer = 0 To 1
 Dim page As PdfPage = doc.Pages.Add()
 pageCount.Draw(page.Graphics)
Next i
doc.Save("PageCountField.pdf")
doc.Close(True);
See Also

Methods

GetValue(PdfGraphics)

Gets the value of the field at the specified graphics.

protected override string GetValue(PdfGraphics graphics)

Parameters

graphics PdfGraphics

The graphics.

Returns

string

result

See Also

See Also