PdfAutomaticField Class
Represents a fields which is calculated before the document saves.
Inherited Members
Namespace: Syncfusion.Pdf
Assembly: Syncfusion.Pdf.Base.dll
Syntax
public abstract class PdfAutomaticField : PdfGraphicsElement
Examples
//Create a new document.
PdfDocument document = new PdfDocument();
//Create new instance of PDF font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12f);
//Create new instance of PDF brush.
PdfSolidBrush brush = new PdfSolidBrush(Color.Blue);
//Creates page number field.
PdfPageNumberField pageNumber = new PdfPageNumberField(font);
//Set number style for page number field.
pageNumber.NumberStyle = PdfNumberStyle.Numeric;
//Create automatic field.
PdfAutomaticField field = pageNumber;
//Set font for automatic field.
field.Font = font;
//Set brush for automatic field.
field.Brush = brush;
//Set size for automatic field.
field.Size = new SizeF(100, 50);
//Set location for automatic field.
field.Location = new PointF(50, 50);
for (int i = 0; i != 2; i++)
{
PdfPage page = document.Pages.Add();
field.Draw(page.Graphics);
}
//Save and close the document.
document.Save("AutomaticField.pdf");
document.Close(true);
'Create a new document.
Dim document As PdfDocument = New PdfDocument()
'Create new instance of PDF font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12.0F)
'Create new instance of PDF brush.
Dim brush As PdfSolidBrush = New PdfSolidBrush(Color.Blue)
'Creates page number field.
Dim pageNumber As PdfPageNumberField = New PdfPageNumberField()
'Set number style for page number field.
pageNumber.NumberStyle = PdfNumberStyle.Numeric
'Create automatic field.
Dim field As PdfAutomaticField = pageNumber
'Set font for automatic field.
field.Font = font
'Set brush for automatic field.
field.Brush = brush
'Set size for automatic field.
field.Size = New SizeF(100, 50)
'Set location for automatic field.
field.Location = New PointF(50, 50)
For i As Integer = 0 To 1
Dim page As PdfPage = document.Pages.Add()
field.Draw(page.Graphics)
Next i
'Save and close the document.
document.Save("AutomaticField.pdf")
document.Close(True)
Constructors
PdfAutomaticField()
Initializes a new instance of the PdfAutomaticField class.
Declaration
protected PdfAutomaticField()
PdfAutomaticField(PdfFont)
Initializes a new instance of the PdfAutomaticField class with PdfFont
Declaration
protected PdfAutomaticField(PdfFont font)
Parameters
Type | Name | Description |
---|---|---|
PdfFont | font | The PdfFont represents the format of the text. |
PdfAutomaticField(PdfFont, PdfBrush)
Initializes a new instance of the PdfAutomaticField class with PdfFont and PdfBrush.
Declaration
protected PdfAutomaticField(PdfFont font, PdfBrush brush)
Parameters
Type | Name | Description |
---|---|---|
PdfFont | font | The PdfFont represents the format of the text. |
PdfBrush | brush | The PdfBrush provides color and texture to the text. |
PdfAutomaticField(PdfFont, RectangleF)
Initializes a new instance of the PdfAutomaticField class with PdfFont and bounds.
Declaration
protected PdfAutomaticField(PdfFont font, RectangleF bounds)
Parameters
Type | Name | Description |
---|---|---|
PdfFont | font | The PdfFont represents the format of the text. |
System.Drawing.RectangleF | bounds | The bounds. |
Properties
Bounds
Gets or sets the bounds of the field.
Declaration
public RectangleF Bounds { get; set; }
Property Value
Type | Description |
---|---|
System.Drawing.RectangleF | The bounds value. |
Examples
//Create a new document.
PdfDocument document = new PdfDocument();
//Create new instance of PDF font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12f);
//Create new instance of PDF brush.
PdfSolidBrush brush = new PdfSolidBrush(Color.Blue);
//Creates page number field.
PdfPageNumberField pageNumber = new PdfPageNumberField(font);
//Set number style for page number field.
pageNumber.NumberStyle = PdfNumberStyle.Numeric;
//Create automatic field.
PdfAutomaticField field = pageNumber;
//Set font for automatic field.
field.Font = font;
//Set brush for automatic field.
field.Brush = brush;
//Set location and size for the automatic field.
field.Bounds = new RectangleF(50, 50, 100, 100);
for (int i = 0; i != 2; i++)
{
PdfPage page = document.Pages.Add();
field.Draw(page.Graphics);
}
//Save and close the document.
document.Save("AutomaticField.pdf");
document.Close(true);
'Create a new document.
Dim document As PdfDocument = New PdfDocument()
'Create new instance of PDF font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12.0F)
'Create new instance of PDF brush.
Dim brush As PdfSolidBrush = New PdfSolidBrush(Color.Blue)
'Creates page number field.
Dim pageNumber As PdfPageNumberField = New PdfPageNumberField()
'Set number style for page number field.
pageNumber.NumberStyle = PdfNumberStyle.Numeric
'Create automatic field.
Dim field As PdfAutomaticField = pageNumber
'Set font for automatic field.
field.Font = font
'Set brush for automatic field.
field.Brush = brush
'Set location and size for the automatic field.
field.Bounds = New RectangleF(50, 50, 100, 50)
For i As Integer = 0 To 1
Dim page As PdfPage = document.Pages.Add()
field.Draw(page.Graphics)
Next i
'Save and close the document.
document.Save("AutomaticField.pdf")
document.Close(True)
See Also
Brush
Gets or sets the PdfBrush of the field
Declaration
public PdfBrush Brush { get; set; }
Property Value
Type | Description |
---|---|
PdfBrush | The PdfBrush provides color and texture to the text. |
Examples
//Create a new document.
PdfDocument document = new PdfDocument();
//Create new instance of PDF font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12f);
//Create new instance of PDF brush.
PdfSolidBrush brush = new PdfSolidBrush(Color.Blue);
//Creates page number field.
PdfPageNumberField pageNumber = new PdfPageNumberField(font);
//Set number style for page number field.
pageNumber.NumberStyle = PdfNumberStyle.Numeric;
//Create automatic field.
PdfAutomaticField field = pageNumber;
//Set font for automatic field.
field.Font = font;
//Set brush for automatic field.
field.Brush = brush;
//Set size for automatic field.
field.Size = new SizeF(100, 50);
//Set location for automatic field.
field.Location = new PointF(50, 50);
for (int i = 0; i != 2; i++)
{
PdfPage page = document.Pages.Add();
field.Draw(page.Graphics);
}
//Save and close the document.
document.Save("AutomaticField.pdf");
document.Close(true);
'Create a new document.
Dim document As PdfDocument = New PdfDocument()
'Create new instance of PDF font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12.0F)
'Create new instance of PDF brush.
Dim brush As PdfSolidBrush = New PdfSolidBrush(Color.Blue)
'Creates page number field.
Dim pageNumber As PdfPageNumberField = New PdfPageNumberField()
'Set number style for page number field.
pageNumber.NumberStyle = PdfNumberStyle.Numeric
'Create automatic field.
Dim field As PdfAutomaticField = pageNumber
'Set font for automatic field.
field.Font = font
'Set brush for automatic field.
field.Brush = brush
'Set size for automatic field.
field.Size = New SizeF(100, 50)
'Set location for automatic field.
field.Location = New PointF(50, 50)
For i As Integer = 0 To 1
Dim page As PdfPage = document.Pages.Add()
field.Draw(page.Graphics)
Next i
'Save and close the document.
document.Save("AutomaticField.pdf")
document.Close(True)
See Also
Font
Gets or sets the PdfFont of the field.
Declaration
public PdfFont Font { get; set; }
Property Value
Type | Description |
---|---|
PdfFont | The PdfFont represents the format of the text. |
Examples
//Create a new document.
PdfDocument document = new PdfDocument();
//Create new instance of PDF font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12f);
//Create new instance of PDF brush.
PdfSolidBrush brush = new PdfSolidBrush(Color.Blue);
//Creates page number field.
PdfPageNumberField pageNumber = new PdfPageNumberField(font);
//Set number style for page number field.
pageNumber.NumberStyle = PdfNumberStyle.Numeric;
//Create automatic field.
PdfAutomaticField field = pageNumber;
//Set font for automatic field.
field.Font = font;
//Set brush for automatic field.
field.Brush = brush;
//Set size for automatic field.
field.Size = new SizeF(100, 50);
//Set location for automatic field.
field.Location = new PointF(50, 50);
for (int i = 0; i != 2; i++)
{
PdfPage page = document.Pages.Add();
field.Draw(page.Graphics);
}
//Save and close the document.
document.Save("AutomaticField.pdf");
document.Close(true);
'Create a new document.
Dim document As PdfDocument = New PdfDocument()
'Create new instance of PDF font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12.0F)
'Create new instance of PDF brush.
Dim brush As PdfSolidBrush = New PdfSolidBrush(Color.Blue)
'Creates page number field.
Dim pageNumber As PdfPageNumberField = New PdfPageNumberField()
'Set number style for page number field.
pageNumber.NumberStyle = PdfNumberStyle.Numeric
'Create automatic field.
Dim field As PdfAutomaticField = pageNumber
'Set font for automatic field.
field.Font = font
'Set brush for automatic field.
field.Brush = brush
'Set size for automatic field.
field.Size = New SizeF(100, 50)
'Set location for automatic field.
field.Location = New PointF(50, 50)
For i As Integer = 0 To 1
Dim page As PdfPage = document.Pages.Add()
field.Draw(page.Graphics)
Next i
'Save and close the document.
document.Save("AutomaticField.pdf")
document.Close(True)
See Also
Location
Gets or sets the location of the field.
Declaration
public PointF Location { get; set; }
Property Value
Type | Description |
---|---|
System.Drawing.PointF | The location. |
Examples
//Create a new document.
PdfDocument document = new PdfDocument();
//Create new instance of PDF font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12f);
//Create new instance of PDF brush.
PdfSolidBrush brush = new PdfSolidBrush(Color.Blue);
//Creates page number field.
PdfPageNumberField pageNumber = new PdfPageNumberField(font);
//Set number style for page number field.
pageNumber.NumberStyle = PdfNumberStyle.Numeric;
//Create automatic field.
PdfAutomaticField field = pageNumber;
//Set font for automatic field.
field.Font = font;
//Set brush for automatic field.
field.Brush = brush;
//Set size for automatic field.
field.Size = new SizeF(100, 50);
//Set location for automatic field.
field.Location = new PointF(50, 50);
for (int i = 0; i != 2; i++)
{
PdfPage page = document.Pages.Add();
field.Draw(page.Graphics);
}
//Save and close the document.
document.Save("AutomaticField.pdf");
document.Close(true);
'Create a new document.
Dim document As PdfDocument = New PdfDocument()
'Create new instance of PDF font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12.0F)
'Create new instance of PDF brush.
Dim brush As PdfSolidBrush = New PdfSolidBrush(Color.Blue)
'Creates page number field.
Dim pageNumber As PdfPageNumberField = New PdfPageNumberField()
'Set number style for page number field.
pageNumber.NumberStyle = PdfNumberStyle.Numeric
'Create automatic field.
Dim field As PdfAutomaticField = pageNumber
'Set font for automatic field.
field.Font = font
'Set brush for automatic field.
field.Brush = brush
'Set size for automatic field.
field.Size = New SizeF(100, 50)
'Set location for automatic field.
field.Location = New PointF(50, 50)
For i As Integer = 0 To 1
Dim page As PdfPage = document.Pages.Add()
field.Draw(page.Graphics)
Next i
'Save and close the document.
document.Save("AutomaticField.pdf")
document.Close(True)
See Also
Pen
Gets or sets the PdfPen of the field.
Declaration
public PdfPen Pen { get; set; }
Property Value
Type | Description |
---|---|
PdfPen | The PdfPen that determines the color, width, and style of the text. |
Examples
//Create a new document.
PdfDocument document = new PdfDocument();
//Create new instance of PDF font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12f);
//Create new instance of PDF brush.
PdfSolidBrush brush = new PdfSolidBrush(Color.Blue);
//Creates page number field.
PdfPageNumberField pageNumber = new PdfPageNumberField(font);
//Set number style for page number field.
pageNumber.NumberStyle = PdfNumberStyle.Numeric;
//Create automatic field.
PdfAutomaticField field = pageNumber;
//Set font for automatic field.
field.Font = font;
//Set brush for automatic field.
field.Brush = brush;
//Set size for automatic field.
field.Size = new SizeF(100, 50);
//Set location for automatic field.
field.Location = new PointF(50, 50);
for (int i = 0; i != 2; i++)
{
PdfPage page = document.Pages.Add();
field.Draw(page.Graphics);
}
//Save and close the document.
document.Save("AutomaticField.pdf");
document.Close(true);
'Create a new document.
Dim document As PdfDocument = New PdfDocument()
'Create new instance of PDF font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12.0F)
'Create new instance of PDF brush.
Dim brush As PdfSolidBrush = New PdfSolidBrush(Color.Blue)
'Creates page number field.
Dim pageNumber As PdfPageNumberField = New PdfPageNumberField()
'Set number style for page number field.
pageNumber.NumberStyle = PdfNumberStyle.Numeric
'Create automatic field.
Dim field As PdfAutomaticField = pageNumber
'Set font for automatic field.
field.Font = font
'Set brush for automatic field.
field.Brush = brush
'Set size for automatic field.
field.Size = New SizeF(100, 50)
'Set location for automatic field.
field.Location = New PointF(50, 50)
For i As Integer = 0 To 1
Dim page As PdfPage = document.Pages.Add()
field.Draw(page.Graphics)
Next i
'Save and close the document.
document.Save("AutomaticField.pdf")
document.Close(True)
See Also
Size
Gets or sets the size of the field.
Declaration
public SizeF Size { get; set; }
Property Value
Type | Description |
---|---|
System.Drawing.SizeF | The size of the field. |
Examples
//Create a new document.
PdfDocument document = new PdfDocument();
//Create new instance of PDF font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12f);
//Create new instance of PDF brush.
PdfSolidBrush brush = new PdfSolidBrush(Color.Blue);
//Creates page number field.
PdfPageNumberField pageNumber = new PdfPageNumberField(font);
//Set number style for page number field.
pageNumber.NumberStyle = PdfNumberStyle.Numeric;
//Create automatic field.
PdfAutomaticField field = pageNumber;
//Set font for automatic field.
field.Font = font;
//Set brush for automatic field.
field.Brush = brush;
//Set size for automatic field.
field.Size = new SizeF(100, 50);
//Set location for automatic field.
field.Location = new PointF(50, 50);
for (int i = 0; i != 2; i++)
{
PdfPage page = document.Pages.Add();
field.Draw(page.Graphics);
}
//Save and close the document.
document.Save("AutomaticField.pdf");
document.Close(true);
'Create a new document.
Dim document As PdfDocument = New PdfDocument()
'Create new instance of PDF font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12.0F)
'Create new instance of PDF brush.
Dim brush As PdfSolidBrush = New PdfSolidBrush(Color.Blue)
'Creates page number field.
Dim pageNumber As PdfPageNumberField = New PdfPageNumberField()
'Set number style for page number field.
pageNumber.NumberStyle = PdfNumberStyle.Numeric
'Create automatic field.
Dim field As PdfAutomaticField = pageNumber
'Set font for automatic field.
field.Font = font
'Set brush for automatic field.
field.Brush = brush
'Set size for automatic field.
field.Size = New SizeF(100, 50)
'Set location for automatic field.
field.Location = New PointF(50, 50)
For i As Integer = 0 To 1
Dim page As PdfPage = document.Pages.Add()
field.Draw(page.Graphics)
Next i
'Save and close the document.
document.Save("AutomaticField.pdf")
document.Close(True)
See Also
StringFormat
Gets or sets the PdfStringFormat of the field.
Declaration
public PdfStringFormat StringFormat { get; set; }
Property Value
Type | Description |
---|---|
PdfStringFormat | The PdfStringFormat determines text layout information on PDF |