Table of Contents

Class PdfField

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

Represents field of the PDF document's interactive form.

public abstract class PdfField : INotifyPropertyChanged
Inheritance
PdfField
Implements
Derived
Inherited Members

Constructors

PdfField(PdfPageBase, string)

Initializes a new instance of the PdfField class with the specific page and name.

public PdfField(PdfPageBase page, string name)

Parameters

page PdfPageBase

The page where the field should be placed.

name string

The name.

See Also

Properties

DisableAutoFormat

Gets or sets a value indicating whether to disable auto format this PdfField.

public bool DisableAutoFormat { get; set; }

Property Value

bool
See Also

Export

Gets or sets a value indicating whether this PdfField is export.

public virtual bool Export { get; set; }

Property Value

bool

true if export; otherwise, false.

See Also

Flatten

Gets or sets a value indicating whether to flatten this PdfField.

public bool Flatten { get; set; }

Property Value

bool
See Also

Form

Gets the form of the PdfField.[Read-Only]

public virtual PdfForm Form { get; }

Property Value

PdfForm

The form.

See Also

Layer

Gets or sets the PdfLayer to the AcroForm fields

public PdfLayer Layer { get; set; }

Property Value

PdfLayer

Examples

//Create a new PDf document
PdfDocument document = new PdfDocument();           
//Creates a new page and adds it as the last page of the document
PdfPage page = document.Pages.Add();
//Creates a PdfLayer
PdfLayer layer = document.Layers.Add("Hello");
PdfFont font = new PdfStandardFont(PdfFontFamily.Courier, 12f);
//Create a text box
PdfTextBoxField firstNameTextBox = new PdfTextBoxField(page, "firstNameTextBox");  
firstNameTextBox.Bounds = new RectangleF(100, 20, 200, 20);
firstNameTextBox.Font = font;
//Set layer to text box field
firstNameTextBox.Layer = layer;
page.Graphics.DrawString("First Name", font, PdfBrushes.Black, 10, 55);
//Add the textbox in document
document.Form.Fields.Add(firstNameTextBox);                      
document.Save("Form.pdf");
document.Close(true);
'Create a new PDf document
Dim document As PdfDocument = New PdfDocument()
'Create a page
Dim page As PdfPage = document.Pages.Add()
'Creates a PdfLayer
Dim layer As PdfLayer = document.Layers.Add("Hello")
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Courier, 12f)
'Create a text box
Dim firstNameTextBox As PdfTextBoxField = New PdfTextBoxField(page, "firstNameTextBox")   
firstNameTextBox.Bounds = New RectangleF(100, 20, 200, 20)
firstNameTextBox.Font = font
'Set layer to text box field
firstNameTextBox.Layer = layer
page.Graphics.DrawString("First Name", font, PdfBrushes.Black, 10, 55)
'Add the textbox in document
document.Form.Fields.Add(firstNameTextBox)
document.Save("Form.pdf")
document.Close(True)
See Also

MappingName

Gets or sets the mapping name to be used when exporting interactive form field data from the document.

public virtual string MappingName { get; set; }

Property Value

string

The mapping name.

See Also

Name

Gets the name of the PdfField.[Read-Only]

public virtual string Name { get; }

Property Value

string

The name.

See Also

Page

Gets the page of the field.[Read-Only]

public virtual PdfPageBase Page { get; }

Property Value

PdfPageBase

The page.

See Also

PdfTag

Get or set tag for the field

public PdfTag PdfTag { get; set; }

Property Value

PdfTag
See Also

ReadOnly

Gets or sets a value indicating whether this PdfField field is read-only.

public virtual bool ReadOnly { get; set; }

Property Value

bool

if the field is read only, set to true.

See Also

Required

Gets or sets a value indicating whether this PdfField is required.

public virtual bool Required { get; set; }

Property Value

bool

true if required; otherwise, false.

See Also

TabIndex

Gets or sets the tab index for form fields

public int TabIndex { get; set; }

Property Value

int
See Also

ToolTip

Gets or sets the tool tip.

public virtual string ToolTip { get; set; }

Property Value

string

The tool tip.

See Also

Methods

DefineDefaultAppearance()

Defines default appearance.

protected virtual void DefineDefaultAppearance()
See Also

GetValue(string)

Get the value associated with the specified key.

public string GetValue(string key)

Parameters

key string

Returns

string

Examples

PdfLoadedDocument ldoc = new PdfLoadedDocument("Form.pdf");
PdfLoadedFormFieldCollection fields = ldoc.Form.Fields;
PdfLoadedTextBoxField textBox = fields[0] as PdfLoadedTextBoxField;
//Get the custom value
string author = textBox.GetValue("Author");
ldoc.Close(true);
Dim ldoc As PdfLoadedDocument = New PdfLoadedDocument("Form.pdf")
Dim fields As PdfLoadedFormFieldCollection = ldoc.Form.Fields
Dim textBox As PdfLoadedTextBoxField = CType(fields(0), PdfLoadedTextBoxField)
'Get the custom value
Dim author As string = textBox.GetValue("Author")
ldoc.Close(true)
See Also

Initialize()

Initializes this instance.

protected virtual void Initialize()
See Also

SetValue(string, string)

Set the value associated with the specified key.

public void SetValue(string key, string value)

Parameters

key string
value string

Examples

PdfLoadedDocument ldoc = new PdfLoadedDocument("Form.pdf");
PdfLoadedFormFieldCollection fields = ldoc.Form.Fields;
PdfLoadedTextBoxField textBox = fields[0] as PdfLoadedTextBoxField;
//Set custom value
textBox.SetValue("Author", "John");
ldoc.Save("result.pdf");
ldoc.Close(true);
Dim ldoc As PdfLoadedDocument = New PdfLoadedDocument("Form.pdf")
Dim fields As PdfLoadedFormFieldCollection = ldoc.Form.Fields
Dim textBox As PdfLoadedTextBoxField = CType(fields(0), PdfLoadedTextBoxField)
'Set custom value
textBox.SetValue("Author", "John")
ldoc.Save("result.pdf")
ldoc.Close(true)
See Also

Events

PropertyChanged

The event will rise when form field properties have been changed.

public event PropertyChangedEventHandler PropertyChanged

Event Type

PropertyChangedEventHandler
See Also

See Also