Table of Contents

Class PdfAutomaticField

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

Represents a fields which is calculated before the document saves.

public abstract class PdfAutomaticField : PdfGraphicsElement
Inheritance
PdfAutomaticField
Derived
Inherited Members

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.

protected PdfAutomaticField()
See Also

PdfAutomaticField(PdfFont)

Initializes a new instance of the PdfAutomaticField class with PdfFont

protected PdfAutomaticField(PdfFont font)

Parameters

font PdfFont

The PdfFont represents the format of the text.

See Also

PdfAutomaticField(PdfFont, RectangleF)

Initializes a new instance of the PdfAutomaticField class with PdfFont and bounds.

protected PdfAutomaticField(PdfFont font, RectangleF bounds)

Parameters

font PdfFont

The PdfFont represents the format of the text.

bounds RectangleF

The bounds.

See Also

PdfAutomaticField(PdfFont, PdfBrush)

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

protected PdfAutomaticField(PdfFont font, PdfBrush brush)

Parameters

font PdfFont

The PdfFont represents the format of the text.

brush PdfBrush

The PdfBrush provides color and texture to the text.

See Also

Properties

Bounds

Gets or sets the bounds of the field.

public RectangleF Bounds { get; set; }

Property Value

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

public PdfBrush Brush { get; set; }

Property Value

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.

public PdfFont Font { get; set; }

Property Value

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.

public PointF Location { get; set; }

Property Value

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.

public PdfPen Pen { get; set; }

Property Value

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.

public SizeF Size { get; set; }

Property Value

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.

public PdfStringFormat StringFormat { get; set; }

Property Value

PdfStringFormat

The PdfStringFormat determines text layout information on PDF

See Also

Methods

Draw(PdfGraphics, float, float)

Draws an element on the Graphics.

public override void Draw(PdfGraphics graphics, float x, float y)

Parameters

graphics PdfGraphics

Graphics context where the element should be printed.

x float

X co-ordinate of the element.

y float

Y co-ordinate of the element.

See Also

DrawInternal(PdfGraphics)

Draws an element on the Graphics.

protected override void DrawInternal(PdfGraphics graphics)

Parameters

graphics PdfGraphics

Graphics context where the element should be printed.

See Also

GetValue(PdfGraphics)

Gets the value of the field at the specified graphics.

protected abstract string GetValue(PdfGraphics graphics)

Parameters

graphics PdfGraphics

The graphics.

Returns

string
See Also

ObtainBrush()

Gets the brush. If brush is undefined default black brush will be used.

protected PdfBrush ObtainBrush()

Returns

PdfBrush

The brush

See Also

ObtainFont()

Gets the font. If font is undefined default font will be used.

protected PdfFont ObtainFont()

Returns

PdfFont
See Also

ObtainSize()

Gets the template size.

protected SizeF ObtainSize()

Returns

SizeF

The template size.

See Also

PerformDraw(PdfGraphics, PointF, float, float)

Performs draw.

protected virtual void PerformDraw(PdfGraphics graphics, PointF location, float scalingX, float scalingY)

Parameters

graphics PdfGraphics

The graphics.

location PointF

The location.

scalingX float

The scaling X.

scalingY float

The scaling Y.

See Also

See Also