Table of Contents

Class PdfLoadedTextBoxField

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

Represents the text box field of an existing PDF document.

public class PdfLoadedTextBoxField : PdfLoadedStyledField, INotifyPropertyChanged
Inheritance
PdfLoadedTextBoxField
Implements
Inherited Members

Examples

//Load an existing document
PdfLoadedDocument doc = new PdfLoadedDocument("SourceForm.pdf");
// Load the text box field
PdfLoadedTextBoxField ldField = doc.Form.Fields[0] as PdfLoadedTextBoxField;
RectangleF newBounds = new RectangleF(100, 100, 50, 50);
ldField.Bounds = newBounds;
ldField.SpellCheck = true;
ldField.Text = "New text of the field.";
ldField.Password = false;
ldField.BorderStyle = PdfBorderStyle.Dashed;
doc.Save("LoadedForm.pdf");
doc.Close(true);
'Load an existing document
Dim doc As PdfLoadedDocument = New PdfLoadedDocument("SourceForm.pdf")
' Load the text box field
Dim ldField As PdfLoadedTextBoxField = TryCast(doc.Form.Fields(0), PdfLoadedTextBoxField)
Dim newBounds As RectangleF = New RectangleF(100, 100, 50, 50)
ldField.Bounds = newBounds
ldField.SpellCheck = True
ldField.Text = "New text of the field."
ldField.Password = False
ldField.BorderStyle = PdfBorderStyle.Dashed
doc.Save("LoadedForm.pdf")
doc.Close(True)

Properties

AutoResizeText

get or set the autosize value of the textbox field

public bool AutoResizeText { get; set; }

Property Value

bool

true if the field autosize property else it is false.

Examples

//Load an existing document
PdfLoadedDocument doc = new PdfLoadedDocument("SourceForm.pdf");
// Read the text box field
PdfLoadedTextBoxField ldField = doc.Form.Fields[0] as PdfLoadedTextBoxField;
bool value=ldField.AutoResizeText
ldField.AutoResizeText=value;
form.Flatten=true;
doc.Save("Form.pdf");
doc.Close(true);
'Load an existing document
Dim doc As PdfLoadedDocument = New PdfLoadedDocument("SourceForm.pdf")
' Read the text box field
Dim ldField As PdfLoadedTextBoxField = TryCast(doc.Form.Fields(0), PdfLoadedTextBoxField)
 bool value = ldField.AutoResizeText
ldField.AutoResizeText=value;
form.Flatten=true;
doc.Save("Form.pdf")
doc.Close(True)
See Also

BackColor

Get or Set the back color of the field

public PdfColor BackColor { get; set; }

Property Value

PdfColor

A PdfColor object specifying the background color of field.

Examples

//Load an existing document
PdfLoadedDocument doc = new PdfLoadedDocument("SourceForm.pdf");
// Read the text box field.
PdfLoadedTextBoxField ldField = doc.Form.Fields[0] as PdfLoadedTextBoxField;
ldField.BackColor = new PdfColor(Color.Transparent);
doc.Save("Form.pdf");
doc.Close(true);
'Load an existing document
Dim doc As PdfLoadedDocument = New PdfLoadedDocument("SourceForm.pdf")
' Read the text box field
Dim ldField As PdfLoadedTextBoxField = TryCast(doc.Form.Fields(0), PdfLoadedTextBoxField)
ldField.BackColor = New PdfColor(Color.Transparent)
doc.Save("Form.pdf")
doc.Close(True)
See Also

ComplexScript

Gets or sets the complex script language support.

public bool ComplexScript { get; set; }

Property Value

bool

Examples

//Load existing PDF document.
PdfLoadedDocument ldoc = new PdfLoadedDocument("form.pdf");
//Load the existing text box field.
PdfLoadedTextBoxField textField = ldoc.Form.Fields[0] as PdfLoadedTextBoxField;
//Create font.
Font font = new Font("Tahoma", 10f);
//Create a new PDF font instance.
PdfFont pdfFont = new PdfTrueTypeFont(font, FontStyle.Regular, 10f, true, true);
//Set font.
textField.Font = pdfFont;
//Enable complex script support.
textField.ComplexScript = true;
ldoc.Form.SetDefaultAppearance(false);
//Save the document.
ldoc.Save("output.pdf");
//Close the document.
ldoc.Close(true);
'Load existing PDF document.
Dim ldoc As New PdfLoadedDocument("form.pdf")
'Load the existing text box field.
Dim textField As PdfLoadedTextBoxField = TryCast(ldoc.Form.Fields(0), PdfLoadedTextBoxField)
'Create font.
Dim font As New Font("Tahoma", 10F)
'Create a new PDF font instance.
Dim pdfFont As PdfFont = New PdfTrueTypeFont(font, FontStyle.Regular, 10F, True, True)
'Set font.
textField.Font = pdfFont
'Enable complex script support.
textField.ComplexScript = True
ldoc.Form.SetDefaultAppearance(False)
'Save the document.
ldoc.Save("output.pdf")
'Close the document.
ldoc.Close(True)
See Also

DefaultValue

Gets or set the default value of the field.

public string DefaultValue { get; set; }

Property Value

string

A string value representing the default value of the item.

Examples

//Load an existing document
PdfLoadedDocument doc = new PdfLoadedDocument("SourceForm.pdf");
// Read the text box field
PdfLoadedTextBoxField ldField = doc.Form.Fields[0] as PdfLoadedTextBoxField;
ldField.DefaultValue = "Cris";
doc.Save("Form.pdf");
doc.Close(true);
'Load an existing document
Dim doc As PdfLoadedDocument = New PdfLoadedDocument("SourceForm.pdf")
' Read the text box field
Dim ldField As PdfLoadedTextBoxField = TryCast(doc.Form.Fields(0), PdfLoadedTextBoxField)
ldField.DefaultValue = "Cris"
doc.Save("Form.pdf")
doc.Close(True)
See Also

ForeColor

Gets or Set the fore color of the field.

public virtual PdfColor ForeColor { get; set; }

Property Value

PdfColor

A PdfColor object specifying the background color of field.

Examples

//Load an existing document
PdfLoadedDocument doc = new PdfLoadedDocument("SourceForm.pdf");
// Read the text box field.
PdfLoadedTextBoxField ldField = doc.Form.Fields[0] as PdfLoadedTextBoxField;
ldField.ForeColor = new PdfColor(Color.Red);
doc.Save("Form.pdf");
doc.Close(true);
'Load an existing document
Dim doc As PdfLoadedDocument = New PdfLoadedDocument("SourceForm.pdf")
' Read the text box field.
Dim ldField As PdfLoadedTextBoxField = TryCast(doc.Form.Fields(0), PdfLoadedTextBoxField)
ldField.ForeColor = New PdfColor(Color.Red)
doc.Save("Form.pdf")
doc.Close(True)
See Also

HighlightMode

Get or Set the HighLightMode of the Field.

public PdfHighlightMode HighlightMode { get; set; }

Property Value

PdfHighlightMode

A PdfHighlightMode enumeration member specifying the highlight mode in a text box.

Examples

//Load an existing document
PdfLoadedDocument doc = new PdfLoadedDocument("SourceForm.pdf");
// Load the text box field
PdfLoadedTextBoxField ldField = doc.Form.Fields[0] as PdfLoadedTextBoxField;
ldField.HighlightMode = PdfHighlightMode.Push;
doc.Save("Form.pdf");
doc.Close(true);
'Load an existing document
Dim doc As PdfLoadedDocument = New PdfLoadedDocument("SourceForm.pdf")
' Load the text box field
Dim ldField As PdfLoadedTextBoxField = TryCast(doc.Form.Fields(0), PdfLoadedTextBoxField)
ldField.HighlightMode = PdfHighlightMode.Push
doc.Save("Form.pdf")
doc.Close(True)
See Also

InsertSpaces

Meaningful only if the MaxLength property is set and the Multiline, Password properties are false. If set, the field is automatically divided into as many equally spaced positions, or combs, as the value of MaxLength, and the text is laid out into those combs.

public bool InsertSpaces { get; set; }

Property Value

bool

Examples

//Load an existing document
PdfLoadedDocument doc = new PdfLoadedDocument("SourceForm.pdf");
// Read the text box field
PdfLoadedTextBoxField ldField = doc.Form.Fields[0] as PdfLoadedTextBoxField;
ldField.InsertSpaces = true;
doc.Save("Form.pdf");
doc.Close(true);
'Load an existing document
Dim doc As PdfLoadedDocument = New PdfLoadedDocument("SourceForm.pdf")
' Read the text box field
Dim ldField As PdfLoadedTextBoxField = TryCast(doc.Form.Fields(0), PdfLoadedTextBoxField)
ldField.InsertSpaces = True
doc.Save("Form.pdf")
doc.Close(True)
See Also

IsAutoFontSize

check whether the textbox field is autosize.

public bool IsAutoFontSize { get; }

Property Value

bool

true if the field autosize property else it is false.

Examples

//Load an existing document
PdfLoadedDocument doc = new PdfLoadedDocument("SourceForm.pdf");
// Read the text box field
PdfLoadedTextBoxField ldField = doc.Form.Fields[0] as PdfLoadedTextBoxField;
bool value=ldField.IsAutoFontSize
ldField.AutoResizeText=value;
form.Flatten=true;
doc.Save("Form.pdf");
doc.Close(true);
'Load an existing document
Dim doc As PdfLoadedDocument = New PdfLoadedDocument("SourceForm.pdf")
'Read the text box field
Dim ldField As PdfLoadedTextBoxField = TryCast(doc.Form.Fields(0), PdfLoadedTextBoxField)
bool value = ldField.IsAutoFontSize
ldField.AutoResizeText=value;
form.Flatten=true;
doc.Save("Form.pdf")
doc.Close(True)
See Also

Items

Gets the collection of text box field items.[Read-Only]

public PdfLoadedTextBoxItemCollection Items { get; }

Property Value

PdfLoadedTextBoxItemCollection

Examples

//Load an existing document
PdfLoadedDocument doc = new PdfLoadedDocument("SourceForm.pdf");
// Read the text box field
PdfLoadedTextBoxField textboxField = doc.Form.Fields[0] as PdfLoadedTextBoxField;
// TextBox Item collection
PdfLoadedTextBoxItemCollection textboxFieldCollection = textboxField.Items;
textboxFieldCollection[0].Location = new PointF(10, 20);
doc.Save("Form.pdf");
doc.Close(true);
'Load an existing document
Dim doc As PdfLoadedDocument = New PdfLoadedDocument("SourceForm.pdf")
' Read the text box field
Dim textboxField As PdfLoadedTextBoxField = TryCast(doc.Form.Fields(0), PdfLoadedTextBoxField)
' TextBox Item collection
Dim textboxFieldCollection As PdfLoadedTextBoxItemCollection = textboxField.Items
textboxFieldCollection(0).Location = New PointF(10, 20)
doc.Save("Form.pdf")
doc.Close(True)
See Also

MaxLength

Gets or sets the maximum length of the field, in characters.

public int MaxLength { get; set; }

Property Value

int

A positive integer value specifying the maximum number of characters that can be entered in the text edit field.

Examples

//Load an existing document
PdfLoadedDocument doc = new PdfLoadedDocument("SourceForm.pdf");
// Read the text box field
PdfLoadedTextBoxField ldField = doc.Form.Fields[0] as PdfLoadedTextBoxField;
ldField.MaxLength = 10;
doc.Save("Form.pdf");
doc.Close(true);
'Load an existing document
Dim doc As PdfLoadedDocument = New PdfLoadedDocument("SourceForm.pdf")
' Read the text box field
Dim ldField As PdfLoadedTextBoxField = TryCast(doc.Form.Fields(0), PdfLoadedTextBoxField)
ldField.MaxLength = 10
doc.Save("Form.pdf")
doc.Close(True)
See Also

Multiline

Gets or sets a value indicating whether this PdfTextBoxField is multiline.

public bool Multiline { get; set; }

Property Value

bool

True if the field is multiline, false otherwise. Default is false.

Examples

//Load an existing document
PdfLoadedDocument doc = new PdfLoadedDocument("SourceForm.pdf");
// Read the text box field
PdfLoadedTextBoxField ldField = doc.Form.Fields[0] as PdfLoadedTextBoxField;
ldField.Multiline = true;
doc.Save("Form.pdf");
doc.Close(true);
'Load an existing document
Dim doc As PdfLoadedDocument = New PdfLoadedDocument("SourceForm.pdf")
' Read the text box field
Dim ldField As PdfLoadedTextBoxField = TryCast(doc.Form.Fields(0), PdfLoadedTextBoxField)
ldField.Multiline = True
doc.Save("Form.pdf")
doc.Close(True)
See Also

Password

Gets or sets a value indicating whether this PdfTextBoxField is password field.

public bool Password { get; set; }

Property Value

bool

True if the field is a password field, false otherwise. Default is false.

Examples

//Load an existing document
PdfLoadedDocument doc = new PdfLoadedDocument("SourceForm.pdf");
// Read the text box field
PdfLoadedTextBoxField ldField = doc.Form.Fields[0] as PdfLoadedTextBoxField;
ldField.Password = true;
doc.Save("Form.pdf");
doc.Close(true);
'Load an existing document
Dim doc As PdfLoadedDocument = New PdfLoadedDocument("SourceForm.pdf")
' Read the text box field
Dim ldField As PdfLoadedTextBoxField = TryCast(doc.Form.Fields(0), PdfLoadedTextBoxField)
ldField.Password = True
doc.Save("Form.pdf")
doc.Close(True)
See Also

Scrollable

Gets or sets a value indicating whether this PdfTextBoxField is scrollable.

public bool Scrollable { get; set; }

Property Value

bool

True if the field content can be scrolled, false otherwise. Default is true.

Examples

//Load an existing document
PdfLoadedDocument doc = new PdfLoadedDocument("SourceForm.pdf");
// Read the text box field
PdfLoadedTextBoxField ldField = doc.Form.Fields[0] as PdfLoadedTextBoxField;
ldField.Scrollable = true;
doc.Save("Form.pdf");
doc.Close(true);
'Load an existing document
Dim doc As PdfLoadedDocument = New PdfLoadedDocument("SourceForm.pdf")
' Read the text box field
Dim ldField As PdfLoadedTextBoxField = TryCast(doc.Form.Fields(0), PdfLoadedTextBoxField)
ldField.Scrollable = True
doc.Save("Form.pdf")
doc.Close(True)
See Also

SpellCheck

Gets or sets a value indicating whether to check spelling.

public bool SpellCheck { get; set; }

Property Value

bool

True if the field content should be checked for spelling erorrs, false otherwise. Default is true.

Examples

//Load an existing document
PdfLoadedDocument doc = new PdfLoadedDocument("SourceForm.pdf");
// Read the text box field
PdfLoadedTextBoxField ldField = doc.Form.Fields[0] as PdfLoadedTextBoxField;
ldField.SpellCheck = true;
doc.Save("Form.pdf");
doc.Close(true);
'Load an existing document
Dim doc As PdfLoadedDocument = New PdfLoadedDocument("SourceForm.pdf")
' Read the text box field
Dim ldField As PdfLoadedTextBoxField = TryCast(doc.Form.Fields(0), PdfLoadedTextBoxField)
ldField.SpellCheck = True
doc.Save("Form.pdf")
doc.Close(True)
See Also

Text

Gets or Set value of the text box field.

public string Text { get; set; }

Property Value

string

A string value representing the value of the item.

Examples

//Load an existing document
PdfLoadedDocument doc = new PdfLoadedDocument("SourceForm.pdf");
// Read the text box field
PdfLoadedTextBoxField ldField = doc.Form.Fields[0] as PdfLoadedTextBoxField;
ldField.Text = "New Text";
doc.Save("Form.pdf");
doc.Close(true);
'Load an existing document
Dim doc As PdfLoadedDocument = New PdfLoadedDocument("SourceForm.pdf")
' Read the text box field
Dim ldField As PdfLoadedTextBoxField = TryCast(doc.Form.Fields(0), PdfLoadedTextBoxField)
ldField.Text = "New Text"
doc.Save("Form.pdf")
doc.Close(True)
See Also

TextAlignment

Get or Set the text alignment in a text box.

public PdfTextAlignment TextAlignment { get; set; }

Property Value

PdfTextAlignment

A PdfTextAlignment enumeration member specifying the text alignment in a text box.

Examples

//Load an existing document
PdfLoadedDocument doc = new PdfLoadedDocument("SourceForm.pdf");
// Read the text box field.
PdfLoadedTextBoxField ldField = doc.Form.Fields[0] as PdfLoadedTextBoxField;
ldField.TextAlignment = PdfTextAlignment.Justify;
doc.Save("Form.pdf");
doc.Close(true);
'Load an existing document
Dim doc As PdfLoadedDocument = New PdfLoadedDocument("SourceForm.pdf")
' Read the text box field.
Dim ldField As PdfLoadedTextBoxField = TryCast(doc.Form.Fields(0), PdfLoadedTextBoxField)
ldField.TextAlignment = PdfTextAlignment.Justify
doc.Save("Form.pdf")
doc.Close(True)
See Also

Methods

Remove(PdfLoadedTexBoxItem)

Remove the particular PdfLoadedTexBoxItem from PdfLoadedTextBoxField.

public void Remove(PdfLoadedTexBoxItem item)

Parameters

item PdfLoadedTexBoxItem

Examples

 //Load an existing document
 PdfLoadedDocument loadedDocument = new PdfLoadedDocument("input.pdf");        
 //Get the loaded form.
  PdfLoadedForm loadedForm = loadedDocument.Form;
 //Get the textbox field
 PdfLoadedTextBoxField textBoxField = loadedForm.Fields[0] as PdfLoadedTextBoxField;
 //Get the textBox field item
 PdfLoadedTexBoxItem texBoxItem = textBoxField.Items[0] as PdfLoadedTexBoxItem;
//Remove the textBox field item
 loadedField.Remove(texBoxItem); 
//Save the modified document.
 loadedDocument.Save("form.pdf");
//Close the document
loadedDocument.Close(true);
See Also

RemoveAt(int)

Remove the PdfLoadedTextBoxField item at the specified index.

public void RemoveAt(int index)

Parameters

index int

Examples

 //Load an existing document
 PdfLoadedDocument loadedDocument = new PdfLoadedDocument("input.pdf");        
 //Get the loaded form.
  PdfLoadedForm loadedForm = loadedDocument.Form;
 //Get the textbox field
 PdfLoadedTextBoxField textBoxField = loadedForm.Fields[0] as PdfLoadedTextBoxField;       
//Remove the textBox field item
 textBoxField.RemoveAt(0);
//Save the modified document.
 loadedDocument.Save("form.pdf");
//Close the document
loadedDocument.Close(true);
See Also

See Also