To create new form fields and widget annotations within a new document.
1// Create a blank page
2PDFDoc doc = new PDFDoc();
3Page blank_page = doc.PageCreate();
4
5// Create a new text field and text widget/annotation (aka AcroForms).
6Field text_field = doc.FieldCreate("employee.name", Field.Type.e_text);
7TextWidget text = TextWidget.Create(doc, new Rect(110, 660, 380, 690), text_field);
8text.SetFont(Font.Create(doc, Font.StandardType1Font.e_times_bold));
9text.RefreshAppearance();
10blank_page.AnnotPushBack(text);
11
12// Create a new signature field and signature annotation (aka AcroForms)
13DigitalSignatureField sig_field = doc.CreateDigitalSignatureField("employee.signature");
14SignatureWidget signature = SignatureWidget.Create(doc, new Rect(0, 100, 200, 150), sig_field);
15signature.RefreshAppearance();
16blank_page.AnnotPushBack(signature);
17
18// Create a new checkbox field and checkbox widget/annotation (aka AcroForms)
19Field checkbox_field = doc.FieldCreate("employee.checkbox", Field.Type.e_check);
20CheckBoxWidget checkbox = CheckBoxWidget.Create(doc, new Rect(190, 490, 250, 540), checkbox_field);
21checkbox.SetBackgroundColor(new ColorPt(1, 1, 1), 3);
22checkbox.SetBorderColor(new ColorPt(0, 0, 0), 3);
23checkbox.SetChecked(true); // Check the widget (by default it is unchecked).
24checkbox.RefreshAppearance();
25blank_page.AnnotPushBack(checkbox);
26
27// Create a radio button group and add three radio button widget/annotation (aka AcroForms) in it.
28RadioButtonGroup radio_group = RadioButtonGroup.Create(doc, "employee.radiogroup");
29RadioButtonWidget radiobutton1 = radio_group.Add(new Rect(140, 410, 190, 460));
30radiobutton1.SetBackgroundColor(new ColorPt(1, 1, 0), 3);
31radiobutton1.RefreshAppearance();
32RadioButtonWidget radiobutton2 = radio_group.Add(new Rect(310, 410, 360, 460));
33radiobutton2.SetBackgroundColor(new ColorPt(0, 1, 0), 3);
34radiobutton2.RefreshAppearance();
35RadioButtonWidget radiobutton3 = radio_group.Add(new Rect(480, 410, 530, 460));
36radiobutton3.EnableButton(); // Enable the third radio button. By default the first one is selected
37radiobutton3.SetBackgroundColor(new ColorPt(0, 1, 1), 3);
38radiobutton3.RefreshAppearance();
39radio_group.AddGroupButtonsToPage(blank_page);
40
41// Add the page as the last page in the document.
42doc.PagePushBack(blank_page);
1// Create a blank page
2PDFDoc doc;
3Page blank_page = doc.PageCreate();
4
5// Create a new text field and text widget/annotation (aka AcroForms).
6Field text_field = doc.FieldCreate("employee.name", Field::e_text);
7TextWidget text = TextWidget::Create(doc, Rect(110, 660, 380, 690), text_field);
8text.SetFont(Font::Create(doc, Font::e_times_bold));
9text.RefreshAppearance();
10blank_page.AnnotPushBack(text);
11
12// Create a new signature field and signature annotation (aka AcroForms)
13DigitalSignatureField sig_field = doc.CreateDigitalSignatureField("employee.signature");
14SignatureWidget signature = SignatureWidget::Create(doc, Rect(0, 100, 200, 150), sig_field);
15signature.RefreshAppearance();
16blank_page.AnnotPushBack(signature);
17
18// Create a new checkbox field and checkbox widget/annotation (aka AcroForms)
19Field checkbox_field = doc.FieldCreate("employee.checkbox", Field::e_check);
20CheckBoxWidget checkbox = CheckBoxWidget::Create(doc, Rect(190, 490, 250, 540), checkbox_field);
21checkbox.SetBackgroundColor(ColorPt(1, 1, 1), 3);
22checkbox.SetBorderColor(ColorPt(0, 0, 0), 3);
23checkbox.SetChecked(true); // Check the widget (by default it is unchecked).
24checkbox.RefreshAppearance();
25blank_page.AnnotPushBack(checkbox);
26
27// Create a radio button group and add three radio button widget/annotation (aka AcroForms) in it.
28RadioButtonGroup radio_group = RadioButtonGroup::Create(doc, "employee.radiogroup");
29RadioButtonWidget radiobutton1 = radio_group.Add(Rect(140, 410, 190, 460));
30radiobutton1.SetBackgroundColor(ColorPt(1, 1, 0), 3);
31radiobutton1.RefreshAppearance();
32RadioButtonWidget radiobutton2 = radio_group.Add(Rect(310, 410, 360, 460));
33radiobutton2.SetBackgroundColor(ColorPt(0, 1, 0), 3);
34radiobutton2.RefreshAppearance();
35RadioButtonWidget radiobutton3 = radio_group.Add(Rect(480, 410, 530, 460));
36radiobutton3.EnableButton(); // Enable the third radio button. By default the first one is selected
37radiobutton3.SetBackgroundColor(ColorPt(0, 1, 1), 3);
38radiobutton3.RefreshAppearance();
39radio_group.AddGroupButtonsToPage(blank_page);
40
41// Add the page as the last page in the document.
42doc.PagePushBack(blank_page);
1// Create a blank page
2doc := NewPDFDoc()
3blankPage := doc.PageCreate()
4
5// Create a new text field and text widget/annotation (aka AcroForms).
6textField := doc.FieldCreate("employee.name", FieldE_text)
7text := TextWidgetCreate(doc, NewRect(110.0, 660.0, 380.0, 690.0), textField)
8text.SetFont(FontCreate(doc.GetSDFDoc(), FontE_times_bold))
9text.RefreshAppearance()
10blankPage.AnnotPushBack(text)
11
12// Create a new signature field and signature annotation (aka AcroForms)
13sigField := doc.CreateDigitalSignatureField("employee.signature")
14signature := SignatureWidgetCreate(doc, NewRect(0.0, 100.0, 200.0, 150.0), sigField)
15signature.RefreshAppearance()
16blankPage.AnnotPushBack(signature)
17
18// Create a new checkbox field and checkbox widget/annotation (aka AcroForms)
19checkField := doc.FieldCreate("employee.checkbox", FieldE_check)
20checkbox := CheckBoxWidgetCreate(doc, NewRect(190.0, 490.0, 250.0, 540.0), checkField)
21checkbox.SetBackgroundColor(NewColorPt(1.0, 1.0, 1.0), 3)
22checkbox.SetBorderColor(NewColorPt(0.0, 0.0, 0.0), 3)
23checkbox.SetChecked(true) // Check the widget (by default it is unchecked).
24checkbox.RefreshAppearance()
25blankPage.AnnotPushBack(checkbox)
26
27// Create a radio button group and add three radio button widget/annotation (aka AcroForms) in it.
28radioGroup := RadioButtonGroupCreate(doc, "employee.radiogroup")
29radiobutton1 := radioGroup.Add(NewRect(140.0, 410.0, 190.0, 460.0))
30radiobutton1.SetBackgroundColor(NewColorPt(1.0, 1.0, 0.0), 3)
31radiobutton1.RefreshAppearance()
32radiobutton2 := radioGroup.Add(NewRect(310.0, 410.0, 360.0, 460.0))
33radiobutton2.SetBackgroundColor(NewColorPt(0.0, 1.0, 0.0), 3)
34radiobutton2.RefreshAppearance()
35radiobutton3 := radioGroup.Add(NewRect(480.0, 410.0, 530.0, 460.0))
36radiobutton3.EnableButton() // Enable the third radio button. By default the first one is selected
37radiobutton3.SetBackgroundColor(NewColorPt(0.0, 1.0, 1.0), 3)
38radiobutton3.RefreshAppearance()
39radioGroup.AddGroupButtonsToPage(blankPage)
40
41// Add the page as the last page in the document.
42doc.PagePushBack(blankPage)
1// Create a blank page
2PDFDoc doc = new PDFDoc();
3Page blank_page = doc.pageCreate();
4
5// Create a new text field and text widget/annotation (aka AcroForms).
6Field text_field = doc.FieldCreate("employee.name", Field.e_text);
7TextWidget text = TextWidget.Create(doc, new Rect(110, 660, 380, 690), text_field);
8text.SetFont(Font.Create(doc, Font.StandardType1Font.e_times_bold));
9text.RefreshAppearance();
10blank_page.AnnotPushBack(text);
11
12// Create a new signature field and signature annotation (aka AcroForms)
13DigitalSignatureField sig_field = doc.CreateDigitalSignatureField("employee.signature");
14SignatureWidget signature = SignatureWidget.Create(doc, new Rect(0, 100, 200, 150), sig_field);
15signature.RefreshAppearance();
16blank_page.AnnotPushBack(signature);
17
18// Create a new checkbox field and checkbox widget/annotation (aka AcroForms)
19Field checkbox_field = doc.FieldCreate("employee.checkbox", Field.e_check);
20CheckBoxWidget checkbox = CheckBoxWidget.Create(doc, new Rect(190, 490, 250, 540), checkbox_field);
21checkbox.SetBackgroundColor(new ColorPt(1, 1, 1), 3);
22checkbox.SetBorderColor(new ColorPt(0, 0, 0), 3);
23checkbox.SetChecked(true); // Check the widget (by default it is unchecked).
24checkbox.RefreshAppearance();
25blank_page.AnnotPushBack(checkbox);
26
27// Create a radio button group and add three radio button widget/annotation (aka AcroForms) in it.
28RadioButtonGroup radio_group = RadioButtonGroup.Create(doc, "employee.radiogroup");
29RadioButtonWidget radiobutton1 = radio_group.Add(new Rect(140, 410, 190, 460));
30radiobutton1.SetBackgroundColor(new ColorPt(1, 1, 0), 3);
31radiobutton1.RefreshAppearance();
32RadioButtonWidget radiobutton2 = radio_group.Add(new Rect(310, 410, 360, 460));
33radiobutton2.SetBackgroundColor(new ColorPt(0, 1, 0), 3);
34radiobutton2.RefreshAppearance();
35RadioButtonWidget radiobutton3 = radio_group.Add(new Rect(480, 410, 530, 460));
36radiobutton3.EnableButton(); // Enable the third radio button. By default the first one is selected
37radiobutton3.SetBackgroundColor(new ColorPt(0, 1, 1), 3);
38radiobutton3.RefreshAppearance();
39radio_group.AddGroupButtonsToPage(blank_page);
40
41// Add the page as the last page in the document.
42doc.pagePushBack(blank_page);
1async function main() {
2 // Create a blank page
3 const doc = await PDFNet.PDFDoc.create();
4 const blankPage = await doc.pageCreate();
5
6 // Create a new text field and text widget/annotation (aka AcroForms).
7 const textField = await doc.fieldCreate(
8 "employee.name",
9 PDFNet.Field.Type.e_text
10 );
11 const text = await PDFNet.TextWidget.createWithField(
12 doc,
13 await PDFNet.Rect.init(110, 660, 380, 690),
14 textField
15 );
16 await text.setFont(
17 await PDFNet.Font.Create(doc, PDFNet.Font.StandardType1Font.e_times_bold)
18 );
19 await text.refreshAppearance();
20 await blankPage.annotPushBack(text);
21
22 // Create a new signature field and signature annotation (aka AcroForms)
23 const sigField = await doc.createDigitalSignatureField("employee.signature");
24 const signature = await PDFNet.SignatureWidget.createWithField(
25 doc,
26 await PDFNet.Rect.init(0, 100, 200, 150),
27 sigField
28 );
29 await signature.refreshAppearance();
30 await blankPage.annotPushBack(signature);
31
32 // Create a new checkbox field and checkbox widget/annotation (aka AcroForms)
33 const checkboxField = await doc.fieldCreate(
34 "employee.checkbox",
35 PDFNet.Field.Type.e_check
36 );
37 const checkbox = await PDFNet.CheckBoxWidget.createWithField(
38 doc,
39 await PDFNet.Rect.init(190, 490, 250, 540),
40 checkboxField
41 );
42 await checkbox.setBackgroundColor(await PDFNet.ColorPt.init(1, 1, 1), 3);
43 await checkbox.setBorderColor(await PDFNet.ColorPt.init(0, 0, 0), 3);
44 await checkbox.setChecked(true); // Check the widget (by default it is unchecked).
45 await checkbox.refreshAppearance();
46 await blankPage.annotPushBack(checkbox);
47
48 // Create a radio button group and add three radio button widget/annotation (aka AcroForms) in it.
49 const radioGroup = await PDFNet.RadioButtonGroup.Create(
50 doc,
51 "employee.radiogroup"
52 );
53 const radiobutton1 = await radioGroup.add(
54 await PDFNet.Rect.init(140, 410, 190, 460)
55 );
56 await radiobutton1.setBackgroundColor(await PDFNet.ColorPt.init(1, 1, 0), 3);
57 await radiobutton1.refreshAppearance();
58 const radiobutton2 = await radioGroup.add(
59 await PDFNet.Rect.init(310, 410, 360, 460)
60 );
61 await radiobutton2.setBackgroundColor(await PDFNet.ColorPt.init(0, 1, 0), 3);
62 await radiobutton2.refreshAppearance();
63 const radiobutton3 = await radioGroup.add(
64 await PDFNet.Rect.init(480, 410, 530, 460)
65 );
66 await radiobutton3.enableButton(); // Enable the third radio button. By default the first one is selected
67 await radiobutton3.setBackgroundColor(await PDFNet.ColorPt.init(0, 1, 1), 3);
68 await radiobutton3.refreshAppearance();
69 await radioGroup.addGroupButtonsToPage(blankPage);
70
71 // Add the page as the last page in the document.
72 await doc.pagePushBack(blankPage);
73}
74PDFNet.runWithCleanup(main);
1// Create a blank page
2PTPDFDoc *doc = [[PTPDFDoc alloc] init];
3PTPage *blank_page = [doc PageCreate: [[PTPDFRect alloc] initWithX1: 0 y1: 0 x2: 612 y2: 792]];
4
5// Create a new text field and text widget/annotation (aka AcroForms).
6PTField *text_field = [doc FieldCreateWithString: @"employee.name" type: e_pttext field_value: @"" def_field_value: @""];
7PTTextWidget *text = [PTTextWidget CreateWithField: doc pos: [[PTPDFRect alloc] initWithX1: 110 y1: 620 x2: 380 y2: 650] field: text_field];
8[text SetFont: [PTFont Create: [doc GetSDFDoc] type: e_pttimes_bold embed: NO]];
9[text RefreshAppearance];
10[blank_page AnnotPushBack: text];
11
12// Create a new signature field and signature annotation (aka AcroForms)
13PTDigitalSignatureField* sig_field = [doc CreateDigitalSignatureField: @"employee.signature"];
14PTSignatureWidget* signature = [PTSignatureWidget CreateWithDigitalSignatureField: doc pos: [[PTPDFRect alloc] initWithX1: 0 y1: 100 x2: 200 y2: 150] field: sig_field];
15[signature RefreshAppearance];
16[blank_page AnnotPushBack: signature];
17
18// Create a new checkbox field and checkbox widget/annotation (aka AcroForms)
19PTCheckBoxWidget *checkbox = [PTCheckBoxWidget Create: doc pos: [[PTPDFRect alloc] initWithX1: 190 y1: 490 x2: 250 y2: 540] field_name: @"employee.checkbox"];
20[checkbox SetBackgroundColor: [[PTColorPt alloc] initWithX: 1 y: 1 z: 1 w: 0] compnum: 3];
21[checkbox SetBorderColor: [[PTColorPt alloc] initWithX: 0 y: 0 z: 0 w: 0] compnum: 3];
22[checkbox SetChecked: true]; // Check the widget (by default it is unchecked).
23[checkbox RefreshAppearance];
24[blank_page AnnotPushBack: checkbox];
25
26// Create a radio button group and add three radio button widget/annotation (aka AcroForms) in it.
27PTRadioButtonGroup *radio_group = [PTRadioButtonGroup Create: doc field_name: @"employee.radiogroup"];
28PTRadioButtonWidget *radiobutton1 = [radio_group Add: [[PTPDFRect alloc] initWithX1: 140 y1: 410 x2: 190 y2: 460] onstate: @""];
29[radiobutton1 SetBackgroundColor: [[PTColorPt alloc] initWithX: 1 y: 1 z: 0 w: 0] compnum: 3];
30[radiobutton1 RefreshAppearance];
31PTRadioButtonWidget *radiobutton2 = [radio_group Add: [[PTPDFRect alloc] initWithX1: 310 y1: 410 x2: 360 y2: 460] onstate: @""];
32[radiobutton2 SetBackgroundColor: [[PTColorPt alloc] initWithX: 0 y: 1 z: 0 w: 0] compnum: 3];
33[radiobutton2 RefreshAppearance];
34PTRadioButtonWidget *radiobutton3 = [radio_group Add: [[PTPDFRect alloc] initWithX1: 480 y1: 410 x2: 530 y2: 460] onstate: @""];
35[radiobutton3 EnableButton]; // Enable the third radio button. By default the first one is selected
36[radiobutton3 SetBackgroundColor: [[PTColorPt alloc] initWithX: 0 y: 1 z: 1 w: 0] compnum: 3];
37[radiobutton3 RefreshAppearance];
38[radio_group AddGroupButtonsToPage: blank_page];
39
40// Add the page as the last page in the document.
41[doc PagePushBack: blank_page];
1// Create a blank page
2$doc = new PDFDoc();
3$blank_page = $doc->PageCreate();
4
5// Create a new text field and text widget/annotation (aka AcroForms).
6$text_field = $doc->FieldCreate("employee.name", Field::e_text, "");
7$text = TextWidget::Create($doc, new Rect(110.0, 620.0, 380.0, 650.0), $text_field);
8$text->SetFont(Font::Create($doc->GetSDFDoc(), Font::e_times_bold));
9$text->RefreshAppearance();
10$blank_page->AnnotPushBack($text);
11
12// Create a new signature field and signature annotation (aka AcroForms)
13$sig_field = $doc->CreateDigitalSignatureField("employee.signature");
14$signature = SignatureWidget::Create($doc, new Rect(0.0, 100.0, 200.0, 150.0), $sig_field);
15$signature->RefreshAppearance();
16$blank_page->AnnotPushBack($signature);
17
18// Create a new checkbox field and checkbox widget/annotation (aka AcroForms)
19$checkbox = CheckBoxWidget::Create($doc, new Rect(190.0, 490.0, 250.0, 540.0), "employee.checkbox");
20$checkbox->SetBackgroundColor(new ColorPt(1.0, 1.0, 1.0), 3);
21$checkbox->SetBorderColor(new ColorPt(0.0, 0.0, 0.0), 3);
22$checkbox->SetChecked(true); // Check the widget (by default it is unchecked).
23$checkbox->RefreshAppearance();
24$blank_page->AnnotPushBack($checkbox);
25
26// Create a radio button group and add three radio button widget/annotation (aka AcroForms) in it.
27$radio_group = RadioButtonGroup::Create($doc, "employee.radiogroup");
28$radiobutton1 = $radio_group->Add(new Rect(140.0, 410.0, 190.0, 460.0));
29$radiobutton1->SetBackgroundColor(new ColorPt(1.0, 1.0, 0.0), 3);
30$radiobutton1->RefreshAppearance();
31$radiobutton2 = $radio_group->Add(new Rect(310.0, 410.0, 360.0, 460.0));
32$radiobutton2->SetBackgroundColor(new ColorPt(0.0, 1.0, 0.0), 3);
33$radiobutton2->RefreshAppearance();
34$radiobutton3 = $radio_group->Add(new Rect(480.0, 410.0, 530.0, 460.0));
35$radiobutton3->EnableButton(); // Enable the third radio button. By default the first one is selected
36$radiobutton3->SetBackgroundColor(new ColorPt(0.0, 1.0, 1.0), 3);
37$radiobutton3->RefreshAppearance();
38$radio_group->AddGroupButtonsToPage($blank_page);
39
40// Add the page as the last page in the document.
41$doc->PagePushBack($blank_page);
1# Create a blank page
2doc = PDFDoc()
3blank_page = doc.PageCreate()
4
5# Create a new text field and text widget/annotation (aka AcroForms).
6text_field = doc.FieldCreate("employee.name", Field.e_text, "")
7text = TextWidget.Create(doc, Rect(110, 620, 380, 650), text_field)
8text.SetFont(Font.Create(doc.GetSDFDoc(), Font.e_times_bold))
9text.RefreshAppearance()
10blank_page.AnnotPushBack(text)
11
12# Create a new signature field and signature annotation (aka AcroForms)
13sig_field = doc.CreateDigitalSignatureField("employee.signature")
14signature = SignatureWidget.Create(doc, Rect(0, 100, 200, 150), sig_field)
15signature.RefreshAppearance()
16blank_page.AnnotPushBack(signature)
17
18# Create a new checkbox field and checkbox widget/annotation (aka AcroForms)
19checkbox = CheckBoxWidget.Create(doc, Rect(190, 490, 250, 540), "employee.checkbox")
20checkbox.SetBackgroundColor(ColorPt(1, 1, 1), 3)
21checkbox.SetBorderColor(ColorPt(0, 0, 0), 3)
22checkbox.SetChecked(True) # Check the widget (by default it is unchecked).
23checkbox.RefreshAppearance()
24blank_page.AnnotPushBack(checkbox)
25
26# Create a radio button group and add three radio button widget/annotation (aka AcroForms) in it.
27radio_group = RadioButtonGroup.Create(doc, "employee.radiogroup")
28radiobutton1 = radio_group.Add(Rect(140, 410, 190, 460))
29radiobutton1.SetBackgroundColor(ColorPt(1, 1, 0), 3)
30radiobutton1.RefreshAppearance()
31radiobutton2 = radio_group.Add(Rect(310, 410, 360, 460))
32radiobutton2.SetBackgroundColor(ColorPt(0, 1, 0), 3)
33radiobutton2.RefreshAppearance()
34radiobutton3 = radio_group.Add(Rect(480, 410, 530, 460))
35radiobutton3.EnableButton() # Enable the third radio button. By default the first one is selected
36radiobutton3.SetBackgroundColor(ColorPt(0, 1, 1), 3)
37radiobutton3.RefreshAppearance()
38radio_group.AddGroupButtonsToPage(blank_page)
39
40# Add the page as the last page in the document.
41doc.PagePushBack(blank_page)
1# Create a blank page
2doc = PDFDoc.new()
3blank_page = doc.PageCreate()
4
5# Create a new text field and text widget/annotation (aka AcroForms).
6text_field = doc.FieldCreate("employee.name", Field::E_text, "John")
7text = TextWidget.Create(doc, Rect.new(110, 620, 380, 650), text_field)
8text.SetFont(Font.Create(doc.GetSDFDoc, Font::E_times_bold))
9text.RefreshAppearance
10blank_page.AnnotPushBack(text)
11
12# Create a new signature field and signature annotation (aka AcroForms)
13sig_field = doc.CreateDigitalSignatureField("employee.signature");
14signature = SignatureWidget.Create(doc, Rect.new(0, 100, 200, 150), sig_field);
15signature.RefreshAppearance
16page1.AnnotPushBack(signature);
17
18# Create a new checkbox field and checkbox widget/annotation (aka AcroForms)
19checkbox = CheckBoxWidget.Create(doc, Rect.new(190, 490, 250, 540), "employee.checkbox")
20checkbox.SetBackgroundColor(ColorPt.new(1, 1, 1), 3)
21checkbox.SetBorderColor(ColorPt.new(0, 0, 0), 3)
22checkbox.SetChecked(true) # Check the widget (by default it is unchecked).
23checkbox.RefreshAppearance
24blank_page.AnnotPushBack(checkbox)
25
26# Create a radio button group and add three radio button widget/annotation (aka AcroForms) in it.
27radio_group = RadioButtonGroup.Create(doc, "employee.radiogroup")
28radiobutton1 = radio_group.Add(Rect.new(140, 410, 190, 460))
29radiobutton1.SetBackgroundColor(ColorPt.new(1, 1, 0), 3)
30radiobutton1.RefreshAppearance
31radiobutton2 = radio_group.Add(Rect.new(310, 410, 360, 460))
32radiobutton2.SetBackgroundColor(ColorPt.new(0, 1, 0), 3)
33radiobutton2.RefreshAppearance
34radiobutton3 = radio_group.Add(Rect.new(480, 410, 530, 460))
35radiobutton3.EnableButton # Enable the third radio button. By default the first one is selected
36radiobutton3.SetBackgroundColor(ColorPt.new(0, 1, 1), 3)
37radiobutton3.RefreshAppearance
38radio_group.AddGroupButtonsToPage(blank_page)
39
40# Add the page as the last page in the document.
41doc.PagePushBack(blank_page)
1' Create a blank page
2Dim doc As PDFDoc = New PDFDoc()
3Dim blank_page As Page = doc.PageCreate()
4
5' Create a new text field and text widget/annotation (aka AcroForms).
6Dim text_field As Field = doc.FieldCreate("employee.name", Field.Type.e_text, "John")
7Dim text As TextWidget = TextWidget.Create(doc, New Rect(110, 620, 380, 650), text_field)
8text.SetFont(Font.Create(doc, Font.StandardType1Font.e_times_bold))
9text.RefreshAppearance()
10blank_page.AnnotPushBack(text)
11
12' Create a new signature field and signature annotation (aka AcroForms)
13Dim sig_field As DigitalSignatureField = doc.CreateDigitalSignatureField("employee.signature")
14Dim signature As SignatureWidget = SignatureWidget.Create(doc, New Rect(0, 100, 200, 150), sig_field)
15signature.RefreshAppearance()
16page1.AnnotPushBack(signature)
17
18' Create a new checkbox field and checkbox widget/annotation (aka AcroForms)
19Dim checkbox As CheckBoxWidget = CheckBoxWidget.Create(doc, New Rect(190, 490, 250, 540), "employee.checkbox")
20checkbox.SetBackgroundColor(New ColorPt(1, 1, 1), 3)
21checkbox.SetBorderColor(New ColorPt(0, 0, 0), 3)
22checkbox.SetChecked(True) ' Check the widget (by default it Is unchecked).
23checkbox.RefreshAppearance()
24blank_page.AnnotPushBack(checkbox)
25
26' Create a radio button group and add three radio button widget/annotation (aka AcroForms) in it.
27Dim radio_group As RadioButtonGroup = RadioButtonGroup.Create(doc, "employee.radiogroup")
28Dim radiobutton1 As RadioButtonWidget = radio_group.Add(New Rect(140, 410, 190, 460))
29radiobutton1.SetBackgroundColor(New ColorPt(1, 1, 0), 3)
30radiobutton1.RefreshAppearance()
31Dim radiobutton2 As RadioButtonWidget = radio_group.Add(New Rect(310, 410, 360, 460))
32radiobutton2.SetBackgroundColor(New ColorPt(0, 1, 0), 3)
33radiobutton2.RefreshAppearance()
34Dim radiobutton3 As RadioButtonWidget = radio_group.Add(New Rect(480, 410, 530, 460))
35radiobutton3.EnableButton() ' Enable the third radio button. By default the first one is selected.
36radiobutton3.SetBackgroundColor(New ColorPt(0, 1, 1), 3)
37radiobutton3.RefreshAppearance()
38radio_group.AddGroupButtonsToPage(blank_page)
39
40' Add the page as the last page in the document.
41doc.PagePushBack(blank_page)
PDF interactive forms (AcroForms)
Full code sample which illustrates some basic PDFNet capabilities related to interactive forms (also known as AcroForms).
Regardless of which field type you create, you must provide a Field name:
1Field myField = doc.FieldCreate("address", Field.Type.e_text);
1Field my_field = doc.FieldCreate("address", Field::e_text);
1myField := doc.FieldCreate("address", FieldE_text)
1Field my_field = doc.FieldCreate("address", Field.e_text);
1const my_field = await doc.fieldCreate(
2 "address",
3 PDFNet.Field.Type.e_text,
4 null
5);
1PTField *my_field = [doc FieldCreate: @"address" type: e_pttext];
1$my_field = $doc->FieldCreate("address", Field::e_text);
1my_field = doc.FieldCreate("address", Field.e_text)
1my_field = doc.FieldCreate("address", Field::E_text)
1Dim my_field As Field = doc.FieldCreate("address", Field.Type.e_text)
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 .
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:
1FieldType type = field.GetType();
2switch(type)
3{
4case Field.FieldType.e_button:
5 Console.WriteLine("Button");
6 break;
7case Field.FieldType.e_check:
8 Console.WriteLine("Check");
9 break;
10case Field.FieldType.e_radio:
11 Console.WriteLine("Radio");
12 break;
13case Field.FieldType.e_text:
14 Console.WriteLine("Text");
15 break;
16case Field.FieldType.e_choice:
17 Console.WriteLine("Choice");
18 break;
19case Field.FieldType.e_signature:
20 Console.WriteLine("Signature");
21 break;
22}
1Field::Type type = field.GetType();
2switch(type)
3{
4 case Field::e_button:
5 printf("Button");
6 break;
7 case Field::e_check:
8 printf("Check");
9 break;
10 case Field::e_radio:
11 printf("Radio");
12 break;
13 case Field::e_text:
14 printf("Text");
15 break;
16 case Field::e_choice:
17 printf("Choice");
18 break;
19 case Field::e_signature:
20 printf("Signature");
21 break;
22}
1fieldType := itr.Current().GetType()
2if (fieldType == FieldE_button){
3 fmt.Println("Button")
4}else if (fieldType == FieldE_radio){
5 fmt.Println("Check")
6}else if (fieldType == FieldE_check){
7 fmt.Println("Radio")
8}else if (fieldType == FieldE_text){
9 fmt.Println("Text")
10}else if (fieldType == FieldE_choice){
11 fmt.Println("Choice")
12}else if (fieldType == FieldE_signature){
13 fmt.Println("Signature")
14}
1int type = field.GetType();
2switch (type)
3{
4 case Field.e_button:
5 System.out.println("Button");
6 break;
7 case Field.e_check:
8 System.out.println("Check");
9 break;
10 case Field.e_radio:
11 System.out.println("Radio");
12 break;
13 case Field.e_text: {
14 System.out.println("Text");
15 break;
16 case Field.e_choice:
17 System.out.println("Choice");
18 break;
19 case Field.e_signature:
20 System.out.println("Signature");
21 break;
22}
1const type = await field.getType();
2switch (type) {
3 case PDFNet.Field.Type.e_button:
4 console.log("Button");
5 break;
6 case PDFNet.Field.Type.e_check:
7 console.log("Check");
8 break;
9 case PDFNet.Field.Type.e_radio:
10 console.log("Radio");
11 break;
12 case PDFNet.Field.Type.e_text:
13 console.log("Text");
14 break;
15 case PDFNet.Field.Type.e_choice:
16 console.log("Choice");
17 break;
18 case PDFNet.Field.Type.e_signature:
19 console.log("Signature");
20 break;
21}
1PTFieldType type = [field GetType];
2switch(type)
3{
4 case e_ptbutton:
5 printf("Button");
6 break;
7 case e_ptcheck:
8 printf("Check");
9 break;
10 case e_ptradio:
11 printf("Radio");
12 break;
13 case e_pttext:
14 printf("Text")
15 break;
16 case e_ptchoice:
17 printf("Choice");
18 break;
19 case e_ptsignature:
20 printf("Signature");
21 break;
22 default:
23 break;
24}
1$type = $field->GetType();
2switch($type)
3{
4 case Field::e_button:
5 echo "Button";
6 break;
7 case Field::e_check:
8 echo "Check";
9 break;
10 case Field::e_radio:
11 echo "Radio";
12 break;
13 case Field::e_text:
14 echo "Text";
15 break;
16 case Field::e_choice:
17 echo "Choice";
18 break;
19 case Field::e_signature:
20 echo "Signature";
21 break;
22 default:
23 break;
24}
1type = field.GetType()
2if type == Field.e_button:
3 print("Button")
4elif type == Field.e_check:
5 print("Check")
6elif type == Field.e_radio:
7 print(" Radio")
8elif type == Field.e_text:
9 print("Text")
10elif type == Field.e_choice:
11 print("Choice")
12elif type == Field.e_signature:
13 print("Signiture")
1type = field.GetType
2if type == Field::E_button
3 puts "Button"
4elsif type == Field::E_check
5 puts "Check"
6elsif type == Field::E_radio
7 puts " Radio"
8elsif type == Field::E_text
9 puts "Text"
10elsif type == Field::E_choice
11 puts "Choice"
12elsif type == Field::E_signature
13 puts "Signiture"
14end
1Dim type As Field.Type = field.GetType()
2If type = Field.Type.e_button Then
3 Console.WriteLine("Button")
4ElseIf type = Field.Type.e_check Then
5 Console.WriteLine("Check")
6ElseIf type = Field.Type.e_radio Then
7 Console.WriteLine("Radio")
8ElseIf type = Field.Type.e_text Then
9 Console.WriteLine("Text")
10ElseIf type = Field.Type.e_choice Then
11 Console.WriteLine("Choice")
12ElseIf type = Field.Type.e_signature Then
13 Console.WriteLine("Signature")
14End If
Did you find this helpful?
Trial setup questions?
Ask experts on DiscordNeed other help?
Contact SupportPricing or product questions?
Contact Sales