Class PdfFieldCollection
Inheritance
Implements
Inherited Members
Namespace: Syncfusion.Pdf.Interactive
Assembly: Syncfusion.Pdf.Base.dll
Syntax
public class PdfFieldCollection : PdfCollection, IEnumerable, IPdfWrapper
Constructors
PdfFieldCollection()
Initializes a new instance of the PdfFieldCollection class.
Declaration
public PdfFieldCollection()
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();
PdfFont font = new PdfStandardFont(PdfFontFamily.Courier, 12f);
//Create a combo box
PdfComboBoxField positionComboBox = new PdfComboBoxField(page, "positionComboBox");
positionComboBox.Bounds = new RectangleF(100, 115, 200, 20);
positionComboBox.Font = font;
positionComboBox.Editable = true;
//Add it to document
document.Form.Fields.Add(positionComboBox);
PdfFieldCollection fieldCollection = new PdfFieldCollection();
fieldCollection = document.Form.Fields;
// Flatten the form collection
for (int i = 0; i != fieldCollection.Count; i++)
{
fieldCollection[i].Flatten = true;
}
//Save the document to disk.
document.Save("Form.pdf");
//Close the document.
document.Close(true);
'Create a new PDf document
Dim document As PdfDocument = New PdfDocument()
'Create a page
Dim page As PdfPage = document.Pages.Add()
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Courier, 12f)
'Create a combo box
Dim positionComboBox As PdfComboBoxField = New PdfComboBoxField(page, "positionComboBox")
positionComboBox.Bounds = New RectangleF(100, 115, 200, 20)
positionComboBox.Font = font
positionComboBox.Editable = True
'Add it to document
document.Form.Fields.Add(positionComboBox)
Dim fieldCollection As PdfFieldCollection = New PdfFieldCollection()
fieldCollection = document.Form.Fields
' Flatten the form collection
For i As Integer = 0 To fieldCollection.Count - 1
fieldCollection(i).Flatten = True
Next i
'Save the document to disk.
document.Save("Form.pdf")
'Close the document.
document.Close(True)
See Also
Properties
Item[Int32]
Gets the PdfField at the specified index.[Read-Only]
Declaration
public virtual PdfField this[int index] { get; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index |
Property Value
Type | Description |
---|---|
PdfField |
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();
PdfFont font = new PdfStandardFont(PdfFontFamily.Courier, 12f);
//Create a combo box
PdfComboBoxField positionComboBox = new PdfComboBoxField(page, "positionComboBox");
positionComboBox.Bounds = new RectangleF(100, 115, 200, 20);
positionComboBox.Font = font;
positionComboBox.Editable = true;
//Add it to document
document.Form.Fields.Add(positionComboBox);
PdfFieldCollection fieldCollection = document.Form.Fields;
// Flatten the form collection
for (int i = 0; i != fieldCollection.Count; i++)
{
fieldCollection[i].Flatten = true;
}
//Save the document to disk.
document.Save("Form.pdf");
//Close the document.
document.Close(true);
'Create a new PDf document
Dim document As PdfDocument = New PdfDocument()
'Create a page
Dim page As PdfPage = document.Pages.Add()
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Courier, 12f)
'Create a combo box
Dim positionComboBox As PdfComboBoxField = New PdfComboBoxField(page, "positionComboBox")
positionComboBox.Editable = True
positionComboBox.Bounds = New RectangleF(100, 115, 200, 20)
positionComboBox.Font = font
positionComboBox.Editable = True
'Add it to document
document.Form.Fields.Add(positionComboBox)
Dim fieldCollection As PdfFieldCollection = document.Form.Fields
' Flatten the form collection
For i As Integer = 0 To fieldCollection.Count - 1
fieldCollection(i).Flatten = True
Next i
'Save the document to disk.
document.Save("Form.pdf")
'Close the document.
document.Close(True)
See Also
Item[String]
Gets the PdfField with their field name.[Read-Only]
Declaration
public PdfField this[string name] { get; }
Parameters
Type | Name | Description |
---|---|---|
System.String | name |
Property Value
Type | Description |
---|---|
PdfField |
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();
PdfFont font = new PdfStandardFont(PdfFontFamily.Courier, 12f);
//Create a combo box
PdfComboBoxField positionComboBox = new PdfComboBoxField(page, "positionComboBox");
positionComboBox.Bounds = new RectangleF(100, 115, 200, 20);
positionComboBox.Font = font;
positionComboBox.Editable = true;
//Add it to document
document.Form.Fields.Add(positionComboBox);
PdfFieldCollection fieldCollection = document.Form.Fields;
// Flatten the form collection
fieldCollection["positionComboBox"].Flatten = true;
//Save the document to disk.
document.Save("Form.pdf");
//Close the document.
document.Close(true);
'Create a new PDf document
Dim document As PdfDocument = New PdfDocument()
'Create a page
Dim page As PdfPage = document.Pages.Add()
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Courier, 12f)
'Create a combo box
Dim positionComboBox As PdfComboBoxField = New PdfComboBoxField(page, "positionComboBox")
positionComboBox.Editable = True
positionComboBox.Bounds = New RectangleF(100, 115, 200, 20)
positionComboBox.Font = font
positionComboBox.Editable = True
'Add it to document
document.Form.Fields.Add(positionComboBox)
Dim fieldCollection As PdfFieldCollection = document.Form.Fields
' Flatten the form collection
fieldCollection("positionComboBox").Flatten = True
'Save the document to disk.
document.Save("Form.pdf")
'Close the document.
document.Close(True)
See Also
Methods
Add(PdfField)
Adds the specified field to the collection.
Declaration
public int Add(PdfField field)
Parameters
Type | Name | Description |
---|---|---|
PdfField | field | The field item which is added in the PDF form. |
Returns
Type | Description |
---|---|
System.Int32 | The field to be added on the page. |
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();
PdfFont font = new PdfStandardFont(PdfFontFamily.Courier, 12f);
PdfFieldCollection fieldCollection = document.Form.Fields;
//Create a combo box
PdfComboBoxField positionComboBox = new PdfComboBoxField(page, "positionComboBox");
positionComboBox.Editable = true;
positionComboBox.Bounds = new RectangleF(100, 115, 200, 20);
positionComboBox.Font = font;
positionComboBox.Editable = true;
fieldCollection.Add(positionComboBox as PdfField);
//Save the document to disk.
document.Save("Form.pdf");
//Close the document.
document.Close(true);
'Create a new PDf document
Dim document As PdfDocument = New PdfDocument()
'Create a page
Dim page As PdfPage = document.Pages.Add()
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Courier, 12f)
Dim fieldCollection As PdfFieldCollection = document.Form.Fields
'Create a combo box
Dim positionComboBox As PdfComboBoxField = New PdfComboBoxField(page, "positionComboBox")
positionComboBox.Editable = True
positionComboBox.Bounds = New RectangleF(100, 115, 200, 20)
positionComboBox.Font = font
positionComboBox.Editable = True
fieldCollection.Add(TryCast(positionComboBox, PdfField))
'Save the document to disk.
document.Save("Form.pdf")
'Close the document.
document.Close(True)
See Also
Clear()
Declaration
public void Clear()
Contains(PdfField)
Determines whether field is contained within the collection.
Declaration
public bool Contains(PdfField field)
Parameters
Type | Name | Description |
---|---|---|
PdfField | field | Check whether PdfField object is present in the field collection or not. |
Returns
Type | Description |
---|---|
System.Boolean |
|
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();
PdfFont font = new PdfStandardFont(PdfFontFamily.Courier, 12f);
PdfFieldCollection fieldCollection = document.Form.Fields;
//Create a combo box
PdfComboBoxField positionComboBox = new PdfComboBoxField(page, "positionComboBox");
positionComboBox.Editable = true;
positionComboBox.Bounds = new RectangleF(100, 115, 200, 20);
positionComboBox.Font = font;
positionComboBox.Editable = true;
if (fieldCollection.Contains(positionComboBox as PdfField))
MessageBox.Show("Already added field");
else
fieldCollection.Add(positionComboBox as PdfField);
//Save the document to disk.
document.Save("Form.pdf");
//Close the document.
document.Close(true);
'Create a new PDf document
Dim document As PdfDocument = New PdfDocument()
'Create a page
Dim page As PdfPage = document.Pages.Add()
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Courier, 12f)
Dim fieldCollection As PdfFieldCollection = document.Form.Fields
'Create a combo box
Dim positionComboBox As PdfComboBoxField = New PdfComboBoxField(page, "positionComboBox")
positionComboBox.Editable = True
positionComboBox.Bounds = New RectangleF(100, 115, 200, 20)
positionComboBox.Font = font
positionComboBox.Editable = True
If fieldCollection.Contains(TryCast(positionComboBox, PdfField)) Then
MessageBox.Show("Already added field")
Else
fieldCollection.Add(TryCast(positionComboBox, PdfField))
End If
'Save the document to disk.
document.Save("Form.pdf")
'Close the document.
document.Close(True)
See Also
DoAdd(PdfField)
Adds a field to collection.
Declaration
protected virtual int DoAdd(PdfField field)
Parameters
Type | Name | Description |
---|---|---|
PdfField | field | The field. |
Returns
Type | Description |
---|---|
System.Int32 | field. |
DoAdd(PdfXfaForm, String)
Add the specified XFA form fields
Declaration
protected virtual void DoAdd(PdfXfaForm form, string subformName)
Parameters
Type | Name | Description |
---|---|---|
PdfXfaForm | form | |
System.String | subformName |
DoClear()
Clears the collection.
Declaration
protected virtual void DoClear()
DoInsert(Int32, PdfField)
Inserts a filed into collection.
Declaration
protected virtual void DoInsert(int index, PdfField field)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The index. |
PdfField | field | The field. |
DoRemove(PdfField)
Removes the field from collection.
Declaration
protected virtual void DoRemove(PdfField field)
Parameters
Type | Name | Description |
---|---|---|
PdfField | field | The field. |
DoRemoveAt(Int32)
Removes the field at the specified position.
Declaration
protected virtual void DoRemoveAt(int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The index. |
IndexOf(PdfField)
Gets the index of the specific field.
Declaration
public int IndexOf(PdfField field)
Parameters
Type | Name | Description |
---|---|---|
PdfField | field | The PdfField object whose index is requested. |
Returns
Type | Description |
---|---|
System.Int32 | Index of the field in collection. |
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();
PdfFont font = new PdfStandardFont(PdfFontFamily.Courier, 12f);
PdfFieldCollection fieldCollection = document.Form.Fields;
//Create a combo box
PdfComboBoxField positionComboBox = new PdfComboBoxField(page, "positionComboBox");
positionComboBox.Editable = true;
positionComboBox.Bounds = new RectangleF(100, 115, 200, 20);
positionComboBox.Font = font;
positionComboBox.Editable = true;
document.Form.Fields.Add(positionComboBox);
int index = fieldCollection.IndexOf(positionComboBox as PdfField);
//Save the document to disk.
document.Save("Form.pdf");
//Close the document.
document.Close(true);
'Create a new PDf document
Dim document As PdfDocument = New PdfDocument()
'Create a page
Dim page As PdfPage = document.Pages.Add()
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Courier, 12f)
Dim fieldCollection As PdfFieldCollection = document.Form.Fields
'Create a combo box
Dim positionComboBox As PdfComboBoxField = New PdfComboBoxField(page, "positionComboBox")
positionComboBox.Editable = True
positionComboBox.Bounds = New RectangleF(100, 115, 200, 20)
positionComboBox.Font = font
positionComboBox.Editable = True
document.Form.Fields.Add(positionComboBox)
Dim index As Integer = fieldCollection.IndexOf(TryCast(positionComboBox, PdfField))
'Save the document to disk.
document.Save("Form.pdf")
'Close the document.
document.Close(True)
See Also
Insert(Int32, PdfField)
Inserts the field at the specified index.
Declaration
public void Insert(int index, PdfField field)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The index of the field. |
PdfField | field | The field which should be inserted at the specified index. |
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();
PdfFont font = new PdfStandardFont(PdfFontFamily.Courier, 12f);
//Create a check box
PdfCheckBoxField checkBox = new PdfCheckBoxField(page, "C#.NET");
checkBox.Bounds = new RectangleF(100, 290, 20, 20);
document.Form.Fields.Add(checkBox);
checkBox.HighlightMode = PdfHighlightMode.Push;
checkBox.BorderStyle = PdfBorderStyle.Beveled;
//Set the value for the check box
checkBox.Checked = true;
document.Form.Fields.Add(checkBox);
PdfFieldCollection fieldCollection = document.Form.Fields;
//Create a combo box
PdfComboBoxField positionComboBox = new PdfComboBoxField(page, "positionComboBox");
positionComboBox.Editable = true;
positionComboBox.Bounds = new RectangleF(100, 115, 200, 20);
positionComboBox.Font = font;
positionComboBox.Editable = true;
// Insert the field at first position in the collection
fieldCollection.Insert(0, positionComboBox as PdfField);
//Save the document to disk.
document.Save("Form.pdf");
//Close the document.
document.Close(true);
'Create a new PDf document
Dim document As PdfDocument = New PdfDocument()
'Creates a new page and adds it as the last page of the document
Dim page As PdfPage = document.Pages.Add()
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Courier, 12f)
'Create a check box
Dim checkBox As PdfCheckBoxField = New PdfCheckBoxField(page, "C#.NET")
checkBox.Bounds = New RectangleF(100, 290, 20, 20)
document.Form.Fields.Add(checkBox)
checkBox.HighlightMode = PdfHighlightMode.Push
checkBox.BorderStyle = PdfBorderStyle.Beveled
'Set the value for the check box
checkBox.Checked = True
document.Form.Fields.Add(checkBox)
Dim fieldCollection As PdfFieldCollection = document.Form.Fields
'Create a combo box
Dim positionComboBox As PdfComboBoxField = New PdfComboBoxField(page, "positionComboBox")
positionComboBox.Editable = True
positionComboBox.Bounds = New RectangleF(100, 115, 200, 20)
positionComboBox.Font = font
positionComboBox.Editable = True
' Insert the field at first position in the collection
fieldCollection.Insert(0, TryCast(positionComboBox, PdfField))
'Save the document to disk.
document.Save("Form.pdf")
'Close the document.
document.Close(True)
See Also
Remove(PdfField)
Removes the specified field in the collection.
Declaration
public void Remove(PdfField field)
Parameters
Type | Name | Description |
---|---|---|
PdfField | field | The PdfField object to be removed from collection. |
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();
PdfFont font = new PdfStandardFont(PdfFontFamily.Courier, 12f);
PdfFieldCollection fieldCollection = document.Form.Fields;
//Create a combo box
PdfComboBoxField positionComboBox = new PdfComboBoxField(page, "positionComboBox");
document.Form.Fields.Add(positionComboBox);
positionComboBox.Editable = true;
positionComboBox.Bounds = new RectangleF(100, 115, 200, 20);
positionComboBox.Font = font;
positionComboBox.Editable = true;
fieldCollection.Remove(positionComboBox as PdfField);
//Save the document to disk.
document.Save("Form.pdf");
//Close the document.
document.Close(true);
'Create a new PDf document
Dim document As PdfDocument = New PdfDocument()
'Create a page
Dim page As PdfPage = document.Pages.Add()
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Courier, 12f)
Dim fieldCollection As PdfFieldCollection = document.Form.Fields
'Create a combo box
Dim positionComboBox As PdfComboBoxField = New PdfComboBoxField(page, "positionComboBox")
document.Form.Fields.Add(positionComboBox)
positionComboBox.Editable = True
positionComboBox.Bounds = New RectangleF(100, 115, 200, 20)
positionComboBox.Font = font
positionComboBox.Editable = True
fieldCollection.Remove(TryCast(positionComboBox, PdfField))
'Save the document to disk.
document.Save("Form.pdf")
'Close the document.
document.Close(True)
See Also
RemoveAt(Int32)
Removes field at the specified position.
Declaration
public void RemoveAt(int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The index where to remove the item. |
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();
PdfFont font = new PdfStandardFont(PdfFontFamily.Courier, 12f);
PdfFieldCollection fieldCollection = document.Form.Fields;
//Create a combo box
PdfComboBoxField positionComboBox = new PdfComboBoxField(page, "positionComboBox");
document.Form.Fields.Add(positionComboBox);
positionComboBox.Editable = true;
positionComboBox.Bounds = new RectangleF(100, 115, 200, 20);
positionComboBox.Font = font;
positionComboBox.Editable = true;
// Remove the first element
fieldCollection.RemoveAt(0);
//Save the document to disk.
document.Save("Form.pdf");
//Close the document.
document.Close(true);
'Create a new PDf document
Dim document As PdfDocument = New PdfDocument()
'Create a page
Dim page As PdfPage = document.Pages.Add()
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Courier, 12f)
Dim fieldCollection As PdfFieldCollection = document.Form.Fields
'Create a combo box
Dim positionComboBox As PdfComboBoxField = New PdfComboBoxField(page, "positionComboBox")
document.Form.Fields.Add(positionComboBox)
positionComboBox.Editable = True
positionComboBox.Bounds = New RectangleF(100, 115, 200, 20)
positionComboBox.Font = font
positionComboBox.Editable = True
' Remove the first element
fieldCollection.RemoveAt(0)
'Save the document to disk.
document.Save("Form.pdf")
'Close the document.
document.Close(True)