Class PdfPageCountField
Represents total PDF document page count automatic field.
Inheritance
Inherited Members
Namespace: Syncfusion.Pdf
Assembly: Syncfusion.Pdf.Base.dll
Syntax
public class PdfPageCountField : PdfSingleValueField
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()
Declaration
public PdfPageCountField()
PdfPageCountField(PdfFont)
Initializes a new instance of the PdfPageCountField class with PdfFont.
Declaration
public PdfPageCountField(PdfFont font)
Parameters
Type | Name | Description |
---|---|---|
PdfFont | font | 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);
PdfPageCountField(PdfFont, PdfBrush)
Initializes a new instance of the PdfPageCountField class with PdfFont and PdfBrush.
Declaration
public PdfPageCountField(PdfFont font, PdfBrush brush)
Parameters
Type | Name | Description |
---|---|---|
PdfFont | font | A PdfFont object that specifies the font attributes (the family name, the size, and the style of the font) to use. |
PdfBrush | brush | 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);
PdfPageCountField(PdfFont, RectangleF)
Initializes a new instance of the PdfPageCountField class with PdfFont and rectangle bounds
Declaration
public PdfPageCountField(PdfFont font, RectangleF bounds)
Parameters
Type | Name | Description |
---|---|---|
PdfFont | font | A PdfFont object that specifies the font attributes (the family name, the size, and the style of the font) to use. |
System.Drawing.RectangleF | bounds | 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);
Properties
NumberStyle
Gets or sets the number style.
Declaration
public PdfNumberStyle NumberStyle { get; set; }
Property Value
Type | Description |
---|---|
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);
Methods
GetValue(PdfGraphics)
Gets the value of the field at the specified graphics.
Declaration
protected override string GetValue(PdfGraphics graphics)
Parameters
Type | Name | Description |
---|---|---|
PdfGraphics | graphics | The graphics. |
Returns
Type | Description |
---|---|
System.String | result |