Class PdfPageCountField
Represents total PDF document page count automatic field.
Inheritance
Inherited Members
Namespace: Syncfusion.Pdf
Assembly: Syncfusion.Pdf.UWP.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()
Initializes a new instance of the PdfPageCountField class.
Declaration
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.
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 |