Class PdfField
Represents field of the PDF document's interactive form.
Inheritance
Implements
Inherited Members
Namespace: Syncfusion.Pdf.Interactive
Assembly: Syncfusion.Pdf.Base.dll
Syntax
public abstract class PdfField : IPdfWrapper, INotifyPropertyChanged
Constructors
PdfField(PdfPageBase, String)
Initializes a new instance of the PdfField class with the specific page and name.
Declaration
public PdfField(PdfPageBase page, string name)
Parameters
Type | Name | Description |
---|---|---|
PdfPageBase | page | The page where the field should be placed. |
System.String | name | The name. |
Properties
DisableAutoFormat
Gets or sets a value indicating whether to disable auto format this PdfField.
Declaration
public bool DisableAutoFormat { get; set; }
Property Value
Type |
---|
System.Boolean |
Export
Gets or sets a value indicating whether this PdfField is export.
Declaration
public virtual bool Export { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Flatten
Gets or sets a value indicating whether to flatten this PdfField.
Declaration
public bool Flatten { get; set; }
Property Value
Type |
---|
System.Boolean |
Form
Gets the form of the PdfField.[Read-Only]
Declaration
public virtual PdfForm Form { get; }
Property Value
Type | Description |
---|---|
PdfForm | The form. |
Layer
Gets or sets the PdfLayer to the AcroForm fields
Declaration
public PdfLayer Layer { get; set; }
Property Value
Type |
---|
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)
MappingName
Gets or sets the mapping name to be used when exporting interactive form field data from the document.
Declaration
public virtual string MappingName { get; set; }
Property Value
Type | Description |
---|---|
System.String | The mapping name. |
Name
Gets the name of the PdfField.[Read-Only]
Declaration
public virtual string Name { get; }
Property Value
Type | Description |
---|---|
System.String | The name. |
Page
Gets the page of the field.[Read-Only]
Declaration
public virtual PdfPageBase Page { get; }
Property Value
Type | Description |
---|---|
PdfPageBase | The page. |
PdfTag
Get or set tag for the field
Declaration
public PdfTag PdfTag { get; set; }
Property Value
Type |
---|
PdfTag |
ReadOnly
Gets or sets a value indicating whether this PdfField field is read-only.
Declaration
public virtual bool ReadOnly { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | if the field is read only, set to |
Required
Gets or sets a value indicating whether this PdfField is required.
Declaration
public virtual bool Required { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
TabIndex
Gets or sets the tab index for form fields
Declaration
public int TabIndex { get; set; }
Property Value
Type |
---|
System.Int32 |
ToolTip
Gets or sets the tool tip.
Declaration
public virtual string ToolTip { get; set; }
Property Value
Type | Description |
---|---|
System.String | The tool tip. |
Methods
DefineDefaultAppearance()
Defines default appearance.
Declaration
protected virtual void DefineDefaultAppearance()
GetValue(String)
Get the value associated with the specified key.
Declaration
public string GetValue(string key)
Parameters
Type | Name | Description |
---|---|---|
System.String | key |
Returns
Type |
---|
System.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)
Initialize()
Initializes this instance.
Declaration
protected virtual void Initialize()
SetValue(String, String)
Set the value associated with the specified key.
Declaration
public void SetValue(string key, string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | |
System.String | value |
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)
Events
PropertyChanged
The event will rise when form field properties have been changed.
Declaration
public event PropertyChangedEventHandler PropertyChanged
Event Type
Type |
---|
System.ComponentModel.PropertyChangedEventHandler |