> For the complete documentation index, see [llms.txt](https://docs.apryse.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.apryse.com/core/forms/new-fields.md).

# Create new form fields and widget annotations on Server/Desktop

Learn how to create new form fields and widget annotations within a PDF document. Explore PDF interactive forms (AcroForms) and discover various field types like text-box, checkbox, radio-button, and

To create new form fields and widget annotations within a new document.

{% tabs %}
{% tab title="C#" %}
{% code lineNumbers="true" %}

```csharp
// Create a blank page
PDFDoc doc = new PDFDoc();
Page blank_page = doc.PageCreate();

// Create a new text field and text widget/annotation (aka AcroForms).
Field text_field = doc.FieldCreate("employee.name", Field.Type.e_text);
TextWidget text = TextWidget.Create(doc, new Rect(110, 660, 380, 690), text_field);
text.SetFont(Font.Create(doc, Font.StandardType1Font.e_times_bold));
text.RefreshAppearance();
blank_page.AnnotPushBack(text);

// Create a new signature field and signature annotation (aka AcroForms)
DigitalSignatureField sig_field = doc.CreateDigitalSignatureField("employee.signature");
SignatureWidget signature = SignatureWidget.Create(doc, new Rect(0, 100, 200, 150), sig_field);
signature.RefreshAppearance();
blank_page.AnnotPushBack(signature);

// Create a new checkbox field and checkbox widget/annotation (aka AcroForms)
Field checkbox_field = doc.FieldCreate("employee.checkbox", Field.Type.e_check);
CheckBoxWidget checkbox = CheckBoxWidget.Create(doc, new Rect(190, 490, 250, 540), checkbox_field);
checkbox.SetBackgroundColor(new ColorPt(1, 1, 1), 3);
checkbox.SetBorderColor(new ColorPt(0, 0, 0), 3);
checkbox.SetChecked(true); // Check the widget (by default it is unchecked).
checkbox.RefreshAppearance();
blank_page.AnnotPushBack(checkbox);

// Create a radio button group and add three radio button widget/annotation (aka AcroForms) in it.
RadioButtonGroup radio_group = RadioButtonGroup.Create(doc, "employee.radiogroup");
RadioButtonWidget radiobutton1 = radio_group.Add(new Rect(140, 410, 190, 460));
radiobutton1.SetBackgroundColor(new ColorPt(1, 1, 0), 3);
radiobutton1.RefreshAppearance();
RadioButtonWidget radiobutton2 = radio_group.Add(new Rect(310, 410, 360, 460));
radiobutton2.SetBackgroundColor(new ColorPt(0, 1, 0), 3);
radiobutton2.RefreshAppearance();
RadioButtonWidget radiobutton3 = radio_group.Add(new Rect(480, 410, 530, 460));
radiobutton3.EnableButton(); // Enable the third radio button. By default the first one is selected
radiobutton3.SetBackgroundColor(new ColorPt(0, 1, 1), 3);
radiobutton3.RefreshAppearance();
radio_group.AddGroupButtonsToPage(blank_page);

// Add the page as the last page in the document.
doc.PagePushBack(blank_page);
```

{% endcode %}
{% endtab %}

{% tab title="C++" %}
{% code lineNumbers="true" %}

```cpp
// Create a blank page
PDFDoc doc;
Page blank_page = doc.PageCreate();

// Create a new text field and text widget/annotation (aka AcroForms).
Field text_field = doc.FieldCreate("employee.name", Field::e_text);
TextWidget text = TextWidget::Create(doc, Rect(110, 660, 380, 690), text_field);
text.SetFont(Font::Create(doc, Font::e_times_bold));
text.RefreshAppearance();
blank_page.AnnotPushBack(text);

// Create a new signature field and signature annotation (aka AcroForms)
DigitalSignatureField sig_field = doc.CreateDigitalSignatureField("employee.signature");
SignatureWidget signature = SignatureWidget::Create(doc, Rect(0, 100, 200, 150), sig_field);
signature.RefreshAppearance();
blank_page.AnnotPushBack(signature);

// Create a new checkbox field and checkbox widget/annotation (aka AcroForms)
Field checkbox_field = doc.FieldCreate("employee.checkbox", Field::e_check);
CheckBoxWidget checkbox = CheckBoxWidget::Create(doc, Rect(190, 490, 250, 540), checkbox_field);
checkbox.SetBackgroundColor(ColorPt(1, 1, 1), 3);
checkbox.SetBorderColor(ColorPt(0, 0, 0), 3);
checkbox.SetChecked(true); // Check the widget (by default it is unchecked).
checkbox.RefreshAppearance();
blank_page.AnnotPushBack(checkbox);

// Create a radio button group and add three radio button widget/annotation (aka AcroForms) in it.
RadioButtonGroup radio_group = RadioButtonGroup::Create(doc, "employee.radiogroup");
RadioButtonWidget radiobutton1 = radio_group.Add(Rect(140, 410, 190, 460));
radiobutton1.SetBackgroundColor(ColorPt(1, 1, 0), 3);
radiobutton1.RefreshAppearance();
RadioButtonWidget radiobutton2 = radio_group.Add(Rect(310, 410, 360, 460));
radiobutton2.SetBackgroundColor(ColorPt(0, 1, 0), 3);
radiobutton2.RefreshAppearance();
RadioButtonWidget radiobutton3 = radio_group.Add(Rect(480, 410, 530, 460));
radiobutton3.EnableButton(); // Enable the third radio button. By default the first one is selected
radiobutton3.SetBackgroundColor(ColorPt(0, 1, 1), 3);
radiobutton3.RefreshAppearance();
radio_group.AddGroupButtonsToPage(blank_page);

// Add the page as the last page in the document.
doc.PagePushBack(blank_page);
```

{% endcode %}
{% endtab %}

{% tab title="Go" %}
{% code lineNumbers="true" %}

```go
// Create a blank page
doc := NewPDFDoc()
blankPage := doc.PageCreate()

// Create a new text field and text widget/annotation (aka AcroForms).
textField := doc.FieldCreate("employee.name", FieldE_text)
text := TextWidgetCreate(doc, NewRect(110.0, 660.0, 380.0, 690.0), textField)
text.SetFont(FontCreate(doc.GetSDFDoc(), FontE_times_bold))
text.RefreshAppearance()
blankPage.AnnotPushBack(text)

// Create a new signature field and signature annotation (aka AcroForms)
sigField := doc.CreateDigitalSignatureField("employee.signature")
signature := SignatureWidgetCreate(doc, NewRect(0.0, 100.0, 200.0, 150.0), sigField)
signature.RefreshAppearance()
blankPage.AnnotPushBack(signature)

// Create a new checkbox field and checkbox widget/annotation (aka AcroForms)
checkField := doc.FieldCreate("employee.checkbox", FieldE_check)
checkbox := CheckBoxWidgetCreate(doc, NewRect(190.0, 490.0, 250.0, 540.0), checkField)
checkbox.SetBackgroundColor(NewColorPt(1.0, 1.0, 1.0), 3)
checkbox.SetBorderColor(NewColorPt(0.0, 0.0, 0.0), 3)
checkbox.SetChecked(true) // Check the widget (by default it is unchecked).
checkbox.RefreshAppearance()
blankPage.AnnotPushBack(checkbox)

// Create a radio button group and add three radio button widget/annotation (aka AcroForms) in it.
radioGroup := RadioButtonGroupCreate(doc, "employee.radiogroup")
radiobutton1 := radioGroup.Add(NewRect(140.0, 410.0, 190.0, 460.0))
radiobutton1.SetBackgroundColor(NewColorPt(1.0, 1.0, 0.0), 3)
radiobutton1.RefreshAppearance()
radiobutton2 := radioGroup.Add(NewRect(310.0, 410.0, 360.0, 460.0))
radiobutton2.SetBackgroundColor(NewColorPt(0.0, 1.0, 0.0), 3)
radiobutton2.RefreshAppearance()
radiobutton3 := radioGroup.Add(NewRect(480.0, 410.0, 530.0, 460.0))
radiobutton3.EnableButton() // Enable the third radio button. By default the first one is selected
radiobutton3.SetBackgroundColor(NewColorPt(0.0, 1.0, 1.0), 3)
radiobutton3.RefreshAppearance()
radioGroup.AddGroupButtonsToPage(blankPage)

// Add the page as the last page in the document.
doc.PagePushBack(blankPage)
```

{% endcode %}
{% endtab %}

{% tab title="Java" %}
{% code lineNumbers="true" %}

```java
// Create a blank page
PDFDoc doc = new PDFDoc();
Page blank_page = doc.pageCreate();

// Create a new text field and text widget/annotation (aka AcroForms).
Field text_field = doc.FieldCreate("employee.name", Field.e_text);
TextWidget text = TextWidget.Create(doc, new Rect(110, 660, 380, 690), text_field);
text.SetFont(Font.Create(doc, Font.StandardType1Font.e_times_bold));
text.RefreshAppearance();
blank_page.AnnotPushBack(text);

// Create a new signature field and signature annotation (aka AcroForms)
DigitalSignatureField sig_field = doc.CreateDigitalSignatureField("employee.signature");
SignatureWidget signature = SignatureWidget.Create(doc, new Rect(0, 100, 200, 150), sig_field);
signature.RefreshAppearance();
blank_page.AnnotPushBack(signature);

// Create a new checkbox field and checkbox widget/annotation (aka AcroForms)
Field checkbox_field = doc.FieldCreate("employee.checkbox", Field.e_check);
CheckBoxWidget checkbox = CheckBoxWidget.Create(doc, new Rect(190, 490, 250, 540), checkbox_field);
checkbox.SetBackgroundColor(new ColorPt(1, 1, 1), 3);
checkbox.SetBorderColor(new ColorPt(0, 0, 0), 3);
checkbox.SetChecked(true); // Check the widget (by default it is unchecked).
checkbox.RefreshAppearance();
blank_page.AnnotPushBack(checkbox);

// Create a radio button group and add three radio button widget/annotation (aka AcroForms) in it.
RadioButtonGroup radio_group = RadioButtonGroup.Create(doc, "employee.radiogroup");
RadioButtonWidget radiobutton1 = radio_group.Add(new Rect(140, 410, 190, 460));
radiobutton1.SetBackgroundColor(new ColorPt(1, 1, 0), 3);
radiobutton1.RefreshAppearance();
RadioButtonWidget radiobutton2 = radio_group.Add(new Rect(310, 410, 360, 460));
radiobutton2.SetBackgroundColor(new ColorPt(0, 1, 0), 3);
radiobutton2.RefreshAppearance();
RadioButtonWidget radiobutton3 = radio_group.Add(new Rect(480, 410, 530, 460));
radiobutton3.EnableButton(); // Enable the third radio button. By default the first one is selected
radiobutton3.SetBackgroundColor(new ColorPt(0, 1, 1), 3);
radiobutton3.RefreshAppearance();
radio_group.AddGroupButtonsToPage(blank_page);

// Add the page as the last page in the document.
doc.pagePushBack(blank_page);
```

{% endcode %}
{% endtab %}

{% tab title="JavaScript" %}
{% code lineNumbers="true" %}

```js
async function main() {
  // Create a blank page
  const doc = await PDFNet.PDFDoc.create();
  const blankPage = await doc.pageCreate();

  // Create a new text field and text widget/annotation (aka AcroForms).
  const textField = await doc.fieldCreate(
    "employee.name",
    PDFNet.Field.Type.e_text
  );
  const text = await PDFNet.TextWidget.createWithField(
    doc,
    await PDFNet.Rect.init(110, 660, 380, 690),
    textField
  );
  await text.setFont(
    await PDFNet.Font.Create(doc, PDFNet.Font.StandardType1Font.e_times_bold)
  );
  await text.refreshAppearance();
  await blankPage.annotPushBack(text);

  // Create a new signature field and signature annotation (aka AcroForms)
  const sigField = await doc.createDigitalSignatureField("employee.signature");
  const signature = await PDFNet.SignatureWidget.createWithField(
    doc,
    await PDFNet.Rect.init(0, 100, 200, 150),
    sigField
  );
  await signature.refreshAppearance();
  await blankPage.annotPushBack(signature);

  // Create a new checkbox field and checkbox widget/annotation (aka AcroForms)
  const checkboxField = await doc.fieldCreate(
    "employee.checkbox",
    PDFNet.Field.Type.e_check
  );
  const checkbox = await PDFNet.CheckBoxWidget.createWithField(
    doc,
    await PDFNet.Rect.init(190, 490, 250, 540),
    checkboxField
  );
  await checkbox.setBackgroundColor(await PDFNet.ColorPt.init(1, 1, 1), 3);
  await checkbox.setBorderColor(await PDFNet.ColorPt.init(0, 0, 0), 3);
  await checkbox.setChecked(true); // Check the widget (by default it is unchecked).
  await checkbox.refreshAppearance();
  await blankPage.annotPushBack(checkbox);

  // Create a radio button group and add three radio button widget/annotation (aka AcroForms) in it.
  const radioGroup = await PDFNet.RadioButtonGroup.Create(
    doc,
    "employee.radiogroup"
  );
  const radiobutton1 = await radioGroup.add(
    await PDFNet.Rect.init(140, 410, 190, 460)
  );
  await radiobutton1.setBackgroundColor(await PDFNet.ColorPt.init(1, 1, 0), 3);
  await radiobutton1.refreshAppearance();
  const radiobutton2 = await radioGroup.add(
    await PDFNet.Rect.init(310, 410, 360, 460)
  );
  await radiobutton2.setBackgroundColor(await PDFNet.ColorPt.init(0, 1, 0), 3);
  await radiobutton2.refreshAppearance();
  const radiobutton3 = await radioGroup.add(
    await PDFNet.Rect.init(480, 410, 530, 460)
  );
  await radiobutton3.enableButton(); // Enable the third radio button. By default the first one is selected
  await radiobutton3.setBackgroundColor(await PDFNet.ColorPt.init(0, 1, 1), 3);
  await radiobutton3.refreshAppearance();
  await radioGroup.addGroupButtonsToPage(blankPage);

  // Add the page as the last page in the document.
  await doc.pagePushBack(blankPage);
}
PDFNet.runWithCleanup(main);
```

{% endcode %}
{% endtab %}

{% tab title="Kotlin" %}
{% code lineNumbers="true" %}

```kotlin
// Create a blank page
val doc = PDFDoc()
val blank_page = doc.pageCreate()

// Create a new text field and text widget/annotation (aka AcroForms).
val text_field = doc.fieldCreate("employee.name", Field.e_text);
val text = TextWidget.Create(doc, Rect(110.0, 660.0, 380.0, 690.0), text_field);
text.font = Font.create(doc, Font.e_times_bold));
text.refreshAppearance();
blank_page.annotPushBack(text);

// Create a new signature field and signature annotation (aka AcroForms)
val sig_field = doc.createDigitalSignatureField("employee.signature");
val signature = SignatureWidget.Create(doc, Rect(0.0, 100.0, 200.0, 150.0), sig_field);
signature.refreshAppearance();
blank_page.annotPushBack(signature);

// Create a new checkbox field and checkbox widget/annotation (aka AcroForms)
val checkbox_field = doc.fieldCreate("employee.checkbox", Field.e_check);
val checkbox = CheckBoxWidget.Create(doc, Rect(190.0, 490.0, 250.0, 540.0), checkbox_field);
checkbox.setBackgroundColor(ColorPt(1.0, 1.0, 1.0), 3);
checkbox.setBorderColor(ColorPt(0.0, 0.0, 0.0), 3);
checkbox.isChecked = true; // Check the widget (by default it is unchecked).
checkbox.refreshAppearance();
blank_page.annotPushBack(checkbox);

// Create a radio button group and add three radio button widget/annotation (aka AcroForms) in it.
val radio_group = RadioButtonGroup.create(doc, "employee.radiogroup")
val radiobutton1 = radio_group.add(Rect(140.0, 410.0, 190.0, 460.0))
radiobutton1.setBackgroundColor(ColorPt(1.0, 1.0, 0.0), 3)
radiobutton1.refreshAppearance()
val radiobutton2 = radio_group.add(Rect(310.0, 410.0, 360.0, 460.0))
radiobutton2.setBackgroundColor(ColorPt(0.0, 1.0, 0.0), 3)
radiobutton2.refreshAppearance()
val radiobutton3 = radio_group.add(Rect(480.0, 410.0, 530.0, 460.0))
radiobutton3.enableButton() // Enable the third radio button. By default the first one is selected
radiobutton3.setBackgroundColor(ColorPt(0.0, 1.0, 1.0), 3)
radiobutton3.refreshAppearance()
radio_group.addGroupButtonsToPage(blank_page)

// Add the page as the last page in the document.
doc.pagePushBack(blank_page)
```

{% endcode %}
{% endtab %}

{% tab title="Obj-C" %}
{% code lineNumbers="true" %}

```objc
// Create a blank page
PTPDFDoc *doc = [[PTPDFDoc alloc] init];
PTPage *blank_page = [doc PageCreate: [[PTPDFRect alloc] initWithX1: 0 y1: 0 x2: 612 y2: 792]];

// Create a new text field and text widget/annotation (aka AcroForms).
PTField *text_field = [doc FieldCreateWithString: @"employee.name" type: e_pttext field_value: @"" def_field_value: @""];
PTTextWidget *text = [PTTextWidget CreateWithField: doc pos: [[PTPDFRect alloc] initWithX1: 110 y1: 620 x2: 380 y2: 650] field: text_field];
[text SetFont: [PTFont Create: [doc GetSDFDoc] type: e_pttimes_bold embed: NO]];
[text RefreshAppearance];
[blank_page AnnotPushBack: text];

// Create a new signature field and signature annotation (aka AcroForms)
PTDigitalSignatureField* sig_field = [doc CreateDigitalSignatureField: @"employee.signature"];
PTSignatureWidget* signature = [PTSignatureWidget CreateWithDigitalSignatureField: doc pos: [[PTPDFRect alloc] initWithX1: 0 y1: 100 x2: 200 y2: 150] field: sig_field];
[signature RefreshAppearance];
[blank_page AnnotPushBack: signature];

// Create a new checkbox field and checkbox widget/annotation (aka AcroForms)
PTCheckBoxWidget *checkbox = [PTCheckBoxWidget Create: doc pos: [[PTPDFRect alloc] initWithX1: 190 y1: 490 x2: 250 y2: 540] field_name: @"employee.checkbox"];
[checkbox SetBackgroundColor: [[PTColorPt alloc] initWithX: 1 y: 1 z: 1 w: 0] compnum: 3];
[checkbox SetBorderColor: [[PTColorPt alloc] initWithX: 0 y: 0 z: 0 w: 0] compnum: 3];
[checkbox SetChecked: true]; // Check the widget (by default it is unchecked).
[checkbox RefreshAppearance];
[blank_page AnnotPushBack: checkbox];

// Create a radio button group and add three radio button widget/annotation (aka AcroForms) in it.
PTRadioButtonGroup *radio_group = [PTRadioButtonGroup Create: doc field_name: @"employee.radiogroup"];
PTRadioButtonWidget *radiobutton1 = [radio_group Add: [[PTPDFRect alloc] initWithX1: 140 y1: 410 x2: 190 y2: 460] onstate: @""];
[radiobutton1 SetBackgroundColor: [[PTColorPt alloc] initWithX: 1 y: 1 z: 0 w: 0] compnum: 3];
[radiobutton1 RefreshAppearance];
PTRadioButtonWidget *radiobutton2 = [radio_group Add: [[PTPDFRect alloc] initWithX1: 310 y1: 410 x2: 360 y2: 460] onstate: @""];
[radiobutton2 SetBackgroundColor: [[PTColorPt alloc] initWithX: 0 y: 1 z: 0 w: 0] compnum: 3];
[radiobutton2 RefreshAppearance];
PTRadioButtonWidget *radiobutton3 = [radio_group Add: [[PTPDFRect alloc] initWithX1: 480 y1: 410 x2: 530 y2: 460] onstate: @""];
[radiobutton3 EnableButton]; // Enable the third radio button. By default the first one is selected
[radiobutton3 SetBackgroundColor: [[PTColorPt alloc] initWithX: 0 y: 1 z: 1 w: 0] compnum: 3];
[radiobutton3 RefreshAppearance];
[radio_group AddGroupButtonsToPage: blank_page];

// Add the page as the last page in the document.
[doc PagePushBack: blank_page];
```

{% endcode %}
{% endtab %}

{% tab title="Swift" %}
{% code lineNumbers="true" %}

```swift
// Create a blank page
let doc: PTPDFDoc = PTPDFDoc()
let blank_page: PTPage = doc.pageCreate(PTPDFRect(x1: 0, y1: 0, x2: 612, y2: 792))

// Create a new text field and text widget/annotation (aka AcroForms).
let text_field: PTField = doc.fieldCreate(with: "employee.name", type: e_pttext, field_value: "", def_field_value: "")
let text: PTTextWidget = PTTextWidget.create(withField: doc, pos: PTPDFRect(x1: 110, y1: 620, x2: 380, y2: 650) field: emp_first_name)
text.setFont(PTFont.create(doc.getSDFDoc(), type: e_pttimes_bold, embed: NO))
text.refreshAppearance()
blank_page.annotPushBack(text)

// Create a new signature field and signature annotation (aka AcroForms)
let sig_field: PTDigitalSignatureField = doc.createDigitalSignatureField("employee.signature")
let signature: PTSignatureWidget = PTSignatureWidget.create(withDigitalSignatureField: doc, pos: PTPDFRect(x1: 0, y1: 100, x2: 200, y2: 150), field: sig_field)
signature.refreshAppearance()
blank_page.annotPushBack(signature)

// Create a new checkbox field and checkbox widget/annotation (aka AcroForms)
let checkbox_field: PTField = doc.fieldCreate(with: "employee.checkbox", type:e_ptcheck, field_value: "Yes", def_field_value: "")
let checkbox: PTCheckBoxWidget = PTCheckBoxWidget.create(withField:doc, pos: PTPDFRect(x1: 190 , y1: 490 , x2: 250, y2:540) field:checkbox_field)
checkbox.setBackgroundColor(PTColorPt(x: 1, y: 1, z: 1), compnum: 3)
checkbox.setBorderColor(PTColorPt(0.0, 0.0, 0.0), compnum: 3)
checkbox.setChecked(true) // Check the widget (by default it is unchecked).
checkbox.refreshAppearance()
blank_page.annotPushBack(checkbox)

// Create a radio button group and add three radio button widget/annotation (aka AcroForms) in it.
let radio_group: PTRadioButtonGroup = PTRadioButtonGroup.create(doc, "employee.radiogroup")
let radiobutton1: PTRadioButtonWidget = radio_group.add(PTPDFRect(x1: 140, y1: 410, x2: 190, y2: 460), onstate: "")
radiobutton1.setBackgroundColor(PTColorPt(x: 1, y: 1, z: 1), compnum: 3)
radiobutton1.refreshAppearance()
let radiobutton2: PTRadioButtonWidget = radio_group.add(PTPDFRect(x1: 310, y1: 410, x2: 360, y2: 460), onstate: "")
radiobutton2.setBackgroundColor(PTColorPt(x: 0, y: 1, z: 0), compnum: 3)
radiobutton2.refreshAppearance()
let radiobutton3: PTRadioButtonWidget = radio_group.add(PTPDFRect(x1: 480, y1: 410, x2: 530, y2: 460), onstate: "")
radiobutton3.enableButton() // Enable the third radio button. By default the first one is selected
radiobutton3.setBackgroundColor(PTColorPt(x: 0, y: 1, z: 1), compnum: 3)
radiobutton3.refreshAppearance()
radio_group.addGroupButtonsToPage(blank_page)

// Add the page as the last page in the document.
doc.pagePushBack(blank_page)
```

{% endcode %}
{% endtab %}

{% tab title="PHP" %}
{% code lineNumbers="true" %}

```php
// Create a blank page
$doc = new PDFDoc();
$blank_page = $doc->PageCreate();

// Create a new text field and text widget/annotation (aka AcroForms).
$text_field = $doc->FieldCreate("employee.name", Field::e_text, "");
$text = TextWidget::Create($doc, new Rect(110.0, 620.0, 380.0, 650.0), $text_field);
$text->SetFont(Font::Create($doc->GetSDFDoc(), Font::e_times_bold));
$text->RefreshAppearance();
$blank_page->AnnotPushBack($text);

// Create a new signature field and signature annotation (aka AcroForms)
$sig_field = $doc->CreateDigitalSignatureField("employee.signature");
$signature = SignatureWidget::Create($doc, new Rect(0.0, 100.0, 200.0, 150.0), $sig_field);
$signature->RefreshAppearance();
$blank_page->AnnotPushBack($signature);

// Create a new checkbox field and checkbox widget/annotation (aka AcroForms)
$checkbox = CheckBoxWidget::Create($doc, new Rect(190.0, 490.0, 250.0, 540.0), "employee.checkbox");
$checkbox->SetBackgroundColor(new ColorPt(1.0, 1.0, 1.0), 3);
$checkbox->SetBorderColor(new ColorPt(0.0, 0.0, 0.0), 3);
$checkbox->SetChecked(true); // Check the widget (by default it is unchecked).
$checkbox->RefreshAppearance();
$blank_page->AnnotPushBack($checkbox);

// Create a radio button group and add three radio button widget/annotation (aka AcroForms) in it.
$radio_group = RadioButtonGroup::Create($doc, "employee.radiogroup");
$radiobutton1 = $radio_group->Add(new Rect(140.0, 410.0, 190.0, 460.0));
$radiobutton1->SetBackgroundColor(new ColorPt(1.0, 1.0, 0.0), 3);
$radiobutton1->RefreshAppearance();
$radiobutton2 = $radio_group->Add(new Rect(310.0, 410.0, 360.0, 460.0));
$radiobutton2->SetBackgroundColor(new ColorPt(0.0, 1.0, 0.0), 3);
$radiobutton2->RefreshAppearance();
$radiobutton3 = $radio_group->Add(new Rect(480.0, 410.0, 530.0, 460.0));
$radiobutton3->EnableButton(); // Enable the third radio button. By default the first one is selected
$radiobutton3->SetBackgroundColor(new ColorPt(0.0, 1.0, 1.0), 3);
$radiobutton3->RefreshAppearance();
$radio_group->AddGroupButtonsToPage($blank_page);

// Add the page as the last page in the document.
$doc->PagePushBack($blank_page);
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code lineNumbers="true" %}

```python
# Create a blank page
doc = PDFDoc()
blank_page = doc.PageCreate()

# Create a new text field and text widget/annotation (aka AcroForms).
text_field = doc.FieldCreate("employee.name", Field.e_text, "")
text = TextWidget.Create(doc, Rect(110, 620, 380, 650), text_field)
text.SetFont(Font.Create(doc.GetSDFDoc(), Font.e_times_bold))
text.RefreshAppearance()
blank_page.AnnotPushBack(text)

# Create a new signature field and signature annotation (aka AcroForms)
sig_field = doc.CreateDigitalSignatureField("employee.signature")
signature = SignatureWidget.Create(doc, Rect(0, 100, 200, 150), sig_field)
signature.RefreshAppearance()
blank_page.AnnotPushBack(signature)

# Create a new checkbox field and checkbox widget/annotation (aka AcroForms)
checkbox = CheckBoxWidget.Create(doc, Rect(190, 490, 250, 540), "employee.checkbox")
checkbox.SetBackgroundColor(ColorPt(1, 1, 1), 3)
checkbox.SetBorderColor(ColorPt(0, 0, 0), 3)
checkbox.SetChecked(True) # Check the widget (by default it is unchecked).
checkbox.RefreshAppearance()
blank_page.AnnotPushBack(checkbox)

# Create a radio button group and add three radio button widget/annotation (aka AcroForms) in it.
radio_group = RadioButtonGroup.Create(doc, "employee.radiogroup")
radiobutton1 = radio_group.Add(Rect(140, 410, 190, 460))
radiobutton1.SetBackgroundColor(ColorPt(1, 1, 0), 3)
radiobutton1.RefreshAppearance()
radiobutton2 = radio_group.Add(Rect(310, 410, 360, 460))
radiobutton2.SetBackgroundColor(ColorPt(0, 1, 0), 3)
radiobutton2.RefreshAppearance()
radiobutton3 = radio_group.Add(Rect(480, 410, 530, 460))
radiobutton3.EnableButton() # Enable the third radio button. By default the first one is selected
radiobutton3.SetBackgroundColor(ColorPt(0, 1, 1), 3)
radiobutton3.RefreshAppearance()
radio_group.AddGroupButtonsToPage(blank_page)

# Add the page as the last page in the document.
doc.PagePushBack(blank_page)
```

{% endcode %}
{% endtab %}

{% tab title="Ruby" %}
{% code lineNumbers="true" %}

```ruby
# Create a blank page
doc = PDFDoc.new()
blank_page = doc.PageCreate()

# Create a new text field and text widget/annotation (aka AcroForms).
text_field = doc.FieldCreate("employee.name", Field::E_text, "John")
text = TextWidget.Create(doc, Rect.new(110, 620, 380, 650), text_field)
text.SetFont(Font.Create(doc.GetSDFDoc, Font::E_times_bold))
text.RefreshAppearance
blank_page.AnnotPushBack(text)

# Create a new signature field and signature annotation (aka AcroForms)
sig_field = doc.CreateDigitalSignatureField("employee.signature");
signature = SignatureWidget.Create(doc, Rect.new(0, 100, 200, 150), sig_field);
signature.RefreshAppearance
page1.AnnotPushBack(signature);

# Create a new checkbox field and checkbox widget/annotation (aka AcroForms)
checkbox = CheckBoxWidget.Create(doc, Rect.new(190, 490, 250, 540), "employee.checkbox")
checkbox.SetBackgroundColor(ColorPt.new(1, 1, 1), 3)
checkbox.SetBorderColor(ColorPt.new(0, 0, 0), 3)
checkbox.SetChecked(true) # Check the widget (by default it is unchecked).
checkbox.RefreshAppearance
blank_page.AnnotPushBack(checkbox)

# Create a radio button group and add three radio button widget/annotation (aka AcroForms) in it.
radio_group = RadioButtonGroup.Create(doc, "employee.radiogroup")
radiobutton1 = radio_group.Add(Rect.new(140, 410, 190, 460))
radiobutton1.SetBackgroundColor(ColorPt.new(1, 1, 0), 3)
radiobutton1.RefreshAppearance
radiobutton2 = radio_group.Add(Rect.new(310, 410, 360, 460))
radiobutton2.SetBackgroundColor(ColorPt.new(0, 1, 0), 3)
radiobutton2.RefreshAppearance
radiobutton3 = radio_group.Add(Rect.new(480, 410, 530, 460))
radiobutton3.EnableButton # Enable the third radio button. By default the first one is selected
radiobutton3.SetBackgroundColor(ColorPt.new(0, 1, 1), 3)
radiobutton3.RefreshAppearance
radio_group.AddGroupButtonsToPage(blank_page)

# Add the page as the last page in the document.
doc.PagePushBack(blank_page)
```

{% endcode %}
{% endtab %}

{% tab title="VB" %}
{% code lineNumbers="true" %}

```vb
' Create a blank page
Dim doc As PDFDoc = New PDFDoc()
Dim blank_page As Page = doc.PageCreate()

' Create a new text field and text widget/annotation (aka AcroForms).
Dim text_field As Field = doc.FieldCreate("employee.name", Field.Type.e_text, "John")
Dim text As TextWidget = TextWidget.Create(doc, New Rect(110, 620, 380, 650), text_field)
text.SetFont(Font.Create(doc, Font.StandardType1Font.e_times_bold))
text.RefreshAppearance()
blank_page.AnnotPushBack(text)

' Create a new signature field and signature annotation (aka AcroForms)
Dim sig_field As DigitalSignatureField = doc.CreateDigitalSignatureField("employee.signature")
Dim signature As SignatureWidget = SignatureWidget.Create(doc, New Rect(0, 100, 200, 150), sig_field)
signature.RefreshAppearance()
page1.AnnotPushBack(signature)

' Create a new checkbox field and checkbox widget/annotation (aka AcroForms)
Dim checkbox As CheckBoxWidget = CheckBoxWidget.Create(doc, New Rect(190, 490, 250, 540), "employee.checkbox")
checkbox.SetBackgroundColor(New ColorPt(1, 1, 1), 3)
checkbox.SetBorderColor(New ColorPt(0, 0, 0), 3)
checkbox.SetChecked(True) ' Check the widget (by default it Is unchecked).
checkbox.RefreshAppearance()
blank_page.AnnotPushBack(checkbox)

' Create a radio button group and add three radio button widget/annotation (aka AcroForms) in it.
Dim radio_group As RadioButtonGroup = RadioButtonGroup.Create(doc, "employee.radiogroup")
Dim radiobutton1 As RadioButtonWidget = radio_group.Add(New Rect(140, 410, 190, 460))
radiobutton1.SetBackgroundColor(New ColorPt(1, 1, 0), 3)
radiobutton1.RefreshAppearance()
Dim radiobutton2 As RadioButtonWidget = radio_group.Add(New Rect(310, 410, 360, 460))
radiobutton2.SetBackgroundColor(New ColorPt(0, 1, 0), 3)
radiobutton2.RefreshAppearance()
Dim radiobutton3 As RadioButtonWidget = radio_group.Add(New Rect(480, 410, 530, 460))
radiobutton3.EnableButton() ' Enable the third radio button. By default the first one is selected.
radiobutton3.SetBackgroundColor(New ColorPt(0, 1, 1), 3)
radiobutton3.RefreshAppearance()
radio_group.AddGroupButtonsToPage(blank_page)

' Add the page as the last page in the document.
doc.PagePushBack(blank_page)
```

{% endcode %}
{% endtab %}
{% endtabs %}

[PDF interactive forms (AcroForms)](/core/get-started/samples/interactiveformstest.md) Full code sample which illustrates some basic PDFNet capabilities related to interactive forms (also known as AcroForms). Code sample is available in C++, C#, Java, Python, Go, PHP, Ruby & VB.

## About creating form fields

Regardless of which field type you create, you must provide a Field name:

{% tabs %}
{% tab title="C#" %}
{% code lineNumbers="true" %}

```csharp
Field myField = doc.FieldCreate("address", Field.Type.e_text);
```

{% endcode %}
{% endtab %}

{% tab title="C++" %}
{% code lineNumbers="true" %}

```cpp
Field my_field = doc.FieldCreate("address", Field::e_text);
```

{% endcode %}
{% endtab %}

{% tab title="Go" %}
{% code lineNumbers="true" %}

```go
myField := doc.FieldCreate("address", FieldE_text)
```

{% endcode %}
{% endtab %}

{% tab title="Java" %}
{% code lineNumbers="true" %}

```java
Field my_field = doc.FieldCreate("address", Field.e_text);
```

{% endcode %}
{% endtab %}

{% tab title="JavaScript" %}
{% code lineNumbers="true" %}

```js
const my_field = await doc.fieldCreate(
  "address",
  PDFNet.Field.Type.e_text,
  null
);
```

{% endcode %}
{% endtab %}

{% tab title="Kotlin" %}
{% code lineNumbers="true" %}

```kotlin
val my_field = doc.fieldCreate("address", Field.e_text)
```

{% endcode %}
{% endtab %}

{% tab title="Obj-C" %}
{% code lineNumbers="true" %}

```objc
PTField *my_field = [doc FieldCreate: @"address" type: e_pttext];
```

{% endcode %}
{% endtab %}

{% tab title="Swift" %}
{% code lineNumbers="true" %}

```swift
let my_field: PTField = doc.fieldCreate("address", type: e_pttext)
```

{% endcode %}
{% endtab %}

{% tab title="PHP" %}
{% code lineNumbers="true" %}

```php
$my_field = $doc->FieldCreate("address", Field::e_text);
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code lineNumbers="true" %}

```python
my_field = doc.FieldCreate("address", Field.e_text)
```

{% endcode %}
{% endtab %}

{% tab title="Ruby" %}
{% code lineNumbers="true" %}

```ruby
my_field = doc.FieldCreate("address", Field::E_text)
```

{% endcode %}
{% endtab %}

{% tab title="VB" %}
{% code lineNumbers="true" %}

```vb
Dim my_field As Field = doc.FieldCreate("address", Field.Type.e_text)
```

{% endcode %}
{% endtab %}
{% endtabs %}

Under most circumstances, field names must be unique. If you have a field you name as "address" and you create a second field you likewise call "address", you cannot supply different data in the two fields.

Field names can use alphanumeric characters to identify a field. All field names are case-sensitive. For example, you can use names such as empFirstName, empSecondName, empNumber, and so on for a group of fileds that are related to the same concept (in our sample employee entity).

Another technique for naming fields is to use a parent and child name. For example, you could name the above fields as follows: `employee.name.first`, `employee.name.second`, `employee.number`.

This naming convention is not only useful for organizing purposes but is well-suited for automatic operations on Fields. In the Apryse SDK, `Field.GetName()` returns a string representing the fully qualified name of the field (e.g. "employee.name.first"). To get the child name ("first") use the `Field.GetPartialName()` method.

For more information about adding Fields, see the [FDF code sample ](/core/get-started/samples/fdftest.md).

## Understand field types

PDF offers six different field types. Each type of form field is used for a different purpose, and they have different properties, appearances, options, and actions that can be associated with the fields. In this section, we will explain how to create all the seven field types and some attributes specific to each one.

Common field types are text-box, checkbox, radio-button, combo-box, and push-button. To find out the type of the Field use `Field.GetType()` method:

{% tabs %}
{% tab title="C#" %}
{% code lineNumbers="true" %}

```csharp
FieldType type = field.GetType();
switch(type)
{
case Field.FieldType.e_button:
  Console.WriteLine("Button");
  break;
case Field.FieldType.e_check:
  Console.WriteLine("Check");
  break;
case Field.FieldType.e_radio:
  Console.WriteLine("Radio");
  break;
case Field.FieldType.e_text:
  Console.WriteLine("Text");
  break;
case Field.FieldType.e_choice:
  Console.WriteLine("Choice");
  break;
case Field.FieldType.e_signature:
  Console.WriteLine("Signature");
  break;
}
```

{% endcode %}
{% endtab %}

{% tab title="C++" %}
{% code lineNumbers="true" %}

```cpp
Field::Type type = field.GetType();
switch(type)
{
  case Field::e_button:
    printf("Button");
    break;
  case Field::e_check:
    printf("Check");
    break;
  case Field::e_radio:
    printf("Radio");
    break;
  case Field::e_text:
    printf("Text");
    break;
  case Field::e_choice:
    printf("Choice");
    break;
  case Field::e_signature:
    printf("Signature");
    break;
}
```

{% endcode %}
{% endtab %}

{% tab title="Go" %}
{% code lineNumbers="true" %}

```go
fieldType := itr.Current().GetType()
if (fieldType == FieldE_button){
  fmt.Println("Button")
}else if (fieldType == FieldE_radio){
  fmt.Println("Check")
}else if (fieldType == FieldE_check){
  fmt.Println("Radio")
}else if (fieldType == FieldE_text){
  fmt.Println("Text")
}else if (fieldType == FieldE_choice){
  fmt.Println("Choice")
}else if (fieldType == FieldE_signature){
  fmt.Println("Signature")
}
```

{% endcode %}
{% endtab %}

{% tab title="Java" %}
{% code lineNumbers="true" %}

```java
int type = field.GetType();
switch (type)
{
  case Field.e_button:
    System.out.println("Button");
    break;
  case Field.e_check:
    System.out.println("Check");
    break;
  case Field.e_radio:
    System.out.println("Radio");
    break;
  case Field.e_text: {
    System.out.println("Text");
    break;
  case Field.e_choice:
    System.out.println("Choice");
    break;
  case Field.e_signature:
    System.out.println("Signature");
    break;
}
```

{% endcode %}
{% endtab %}

{% tab title="JavaScript" %}
{% code lineNumbers="true" %}

```js
const type = await field.getType();
switch (type) {
  case PDFNet.Field.Type.e_button:
    console.log("Button");
    break;
  case PDFNet.Field.Type.e_check:
    console.log("Check");
    break;
  case PDFNet.Field.Type.e_radio:
    console.log("Radio");
    break;
  case PDFNet.Field.Type.e_text:
    console.log("Text");
    break;
  case PDFNet.Field.Type.e_choice:
    console.log("Choice");
    break;
  case PDFNet.Field.Type.e_signature:
    console.log("Signature");
    break;
}
```

{% endcode %}
{% endtab %}

{% tab title="Kotlin" %}
{% code lineNumbers="true" %}

```kotlin
val type = field.getType()
when (type)
{
  Field.e_button -> println("Button")
  Field.e_check -> println("Check")
  Field.e_radio -> println("Radio")
  Field.e_text -> println("Text")
  Field.e_choice -> println("Choice")
  Field.e_signature -> println("Signature")
}
```

{% endcode %}
{% endtab %}

{% tab title="Obj-C" %}
{% code lineNumbers="true" %}

```objc
PTFieldType type = [field GetType];
switch(type)
{
  case e_ptbutton:
    printf("Button");
    break;
  case e_ptcheck:
    printf("Check");
    break;
  case e_ptradio:
    printf("Radio");
    break;
  case e_pttext:
    printf("Text")
    break;
  case e_ptchoice:
    printf("Choice");
    break;
  case e_ptsignature:
    printf("Signature");
    break;
  default:
    break;
}
```

{% endcode %}
{% endtab %}

{% tab title="Swift" %}
{% code lineNumbers="true" %}

```swift
let type: PTFieldType = field.getType()
switch type
{
  case e_ptbutton:
      print("Button")
  case e_ptcheck:
      print("Check")
  case e_ptradio:
      print("Radio")
  case e_pttext:
      print("Text")
  case e_ptchoice:
      print("Choice")
  case e_ptsignature:
      print("Signature")
  default:
      break
}
```

{% endcode %}
{% endtab %}

{% tab title="PHP" %}
{% code lineNumbers="true" %}

```php
$type = $field->GetType();
switch($type)
{
  case Field::e_button:
    echo "Button";
    break;
  case Field::e_check:
    echo "Check";
    break;
  case Field::e_radio:
    echo "Radio";
    break;
  case Field::e_text:
    echo "Text";
    break;
  case Field::e_choice:
    echo "Choice";
    break;
  case Field::e_signature:
    echo "Signature";
    break;
  default:
    break;
}
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code lineNumbers="true" %}

```python
type = field.GetType()
if type == Field.e_button:
    print("Button")
elif type == Field.e_check:
    print("Check")
elif type == Field.e_radio:
    print(" Radio")
elif type == Field.e_text:
    print("Text")
elif type == Field.e_choice:
    print("Choice")
elif type == Field.e_signature:
    print("Signiture")
```

{% endcode %}
{% endtab %}

{% tab title="Ruby" %}
{% code lineNumbers="true" %}

```ruby
type = field.GetType
if type == Field::E_button
  puts "Button"
elsif type == Field::E_check
  puts "Check"
elsif type == Field::E_radio
  puts " Radio"
elsif type == Field::E_text
  puts "Text"
elsif type == Field::E_choice
  puts "Choice"
elsif type == Field::E_signature
  puts "Signiture"
end
```

{% endcode %}
{% endtab %}

{% tab title="VB" %}
{% code lineNumbers="true" %}

```vb
Dim type As Field.Type = field.GetType()
If type = Field.Type.e_button Then
  Console.WriteLine("Button")
ElseIf type = Field.Type.e_check Then
  Console.WriteLine("Check")
ElseIf type = Field.Type.e_radio Then
  Console.WriteLine("Radio")
ElseIf type = Field.Type.e_text Then
  Console.WriteLine("Text")
ElseIf type = Field.Type.e_choice Then
  Console.WriteLine("Choice")
ElseIf type = Field.Type.e_signature Then
  Console.WriteLine("Signature")
End If
```

{% endcode %}
{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.apryse.com/core/forms/new-fields.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
