PDF Creator Pilot documentation |
Download CHM version of this manual. |
|
![]() ![]() Collapse AllThis method creates a button control in a PDF document.
|
| LONG AddButton ( FLOAT left, FLOAT top, FLOAT right, FLOAT bottom, BSTR name ) |
Parameters
left
X coordinate of the top-left corner of the bounding rectangle
top
Y coordinate of the top-left corner of the bounding rectangle
right
X coordinate of the bottom-right corner of the bounding rectangle
bottom
Y coordinate of the bottom-right corner of the bounding rectangle
name
Name of the control.
Return value
Index of the button
Remarks
This method creates a button control with the name name on the current PDF page in an area bounded by the specified coordinates.
The return value is an annotation/control identifier in the document's annotations collection and can be used in AddControlToAction and CurrentAnnotation.
Example
Adding Form Controls to a PDF Document
Delphi
[copy to clipboard]
{ PDF object is supposed to be created }
btn1 := PDF.AddButton(20, 10, 100, 25, 'btn1');
PDF.AnnotUnicodeCaption := 'Button 1';
ch1 := PDF.AddCheckBox(120, 13, 180, 23, 'ch1');
PDF.AnnotUnicodeCaption := 'Checkbox 1';
cb1 := PDF.AddComboBox(190, 10, 280, 25, 'cb1');
PDF.AnnotUnicodeText := 'Select value...';
PDF.ComboBoxUnicodeItems := 'Item1' + #13#10 + 'Item2' + #13#10 + 'Item3';
ed1 := PDF.AddEditBox(20, 35, 120, 50, 'ed1');
PDF.AnnotUnicodeText := 'Enter text here...';
rd1 := PDF.AddRadioButton(150, 35, 200, 43, 'radio_grp');
PDF.AnnotUnicodeCaption := 'Option 1';
PDF.RadioButtonExportValue := 'value1';
PDF.ControlChecked := true;
rd2 := PDF.AddRadioButton(150, 48, 200, 56, 'radio_grp');
PDF.AnnotUnicodeCaption := 'Option 2';
PDF.RadioButtonExportValue := 'value2';
PDF.ControlChecked := false;
PDF.SaveToFile('test.pdf', true);
C/C++
[copy to clipboard]
// PDF object is supposed to be created
long btn1 = PDF->AddButton(20, 10, 100, 25, "btn1");
PDF->AnnotUnicodeCaption = L"Button 1";
long ch1 = PDF->AddCheckBox(120, 13, 180, 23, "ch1");
PDF->AnnotUnicodeCaption = L"Checkbox 1";
long cb1 = PDF->AddComboBox(190, 10, 280, 25, "cb1");
PDF->AnnotUnicodeText = L"Select value...";
PDF->ComboBoxUnicodeItems = L"Item1\nItem2\nItem3";
long ed1 = PDF->AddEditBox(20, 35, 120, 50, "ed1")
PDF->AnnotUnicodeText = L"Enter text here...";
long rd1 = PDF->AddRadioButton(150, 35, 200, 43, "radio_grp");
PDF->AnnotUnicodeCaption = L"Option 1";
PDF->RadioButtonExportValue = "value1";
PDF->ControlChecked = true;
long rd2 = PDF->AddRadioButton(150, 48, 200, 56, "radio_grp");
PDF->AnnotUnicodeCaption = L"Option 2";
PDF->RadioButtonExportValue = "value2";
PDF->ControlChecked = false;
PDF->SaveToFile("test.pdf", true);
C#
[copy to clipboard]
// PDF object is supposed to be created
long btn1 = PDF.AddButton(20, 10, 100, 25, "btn1");
PDF.AnnotUnicodeCaption = "Button 1";
long ch1 = PDF.AddCheckBox(120, 13, 180, 23, "ch1");
PDF.AnnotUnicodeCaption = "Checkbox 1";
long cb1 = PDF.AddComboBox(190, 10, 280, 25, "cb1");
PDF.AnnotUnicodeText = "Select value...";
PDF.ComboBoxUnicodeItems = "Item1\nItem2\nItem3";
long ed1 = PDF.AddEditBox(20, 35, 120, 50, "ed1")
PDF.AnnotUnicodeText = "Enter text here...";
long rd1 = PDF.AddRadioButton(150, 35, 200, 43, "radio_grp");
PDF.AnnotUnicodeCaption = "Option 1";
PDF.RadioButtonExportValue = "value1";
PDF.ControlChecked = true;
long rd2 = PDF.AddRadioButton(150, 48, 200, 56, "radio_grp");
PDF.AnnotUnicodeCaption = "Option 2";
PDF.RadioButtonExportValue = "value2";
PDF.ControlChecked = false;
PDF.SaveToFile("test.pdf", true);
Visual Basic
[copy to clipboard]
' PDF object is supposed to be created btn1 = PDF.AddButton(20, 10, 100, 25, "btn1") PDF.AnnotUnicodeCaption = "Button 1" ch1 = PDF.AddCheckBox(120, 13, 180, 23, "ch1") PDF.AnnotUnicodeCaption = "Checkbox 1" cb1 = PDF.AddComboBox(190, 10, 280, 25, "cb1") PDF.AnnotUnicodeText = "Select value..." PDF.ComboBoxUnicodeItems = "Item1" & vbCrLf & "Item2" & vbCrLf & "Item3" ed1 = PDF.AddEditBox(20, 35, 120, 50, "ed1") PDF.AnnotUnicodeText = "Enter text here..." rd1 = PDF.AddRadioButton(150, 35, 200, 43, "radio_grp") PDF.AnnotUnicodeCaption = "Option 1" PDF.RadioButtonExportValue = "value1" PDF.ControlChecked = True rd2 = PDF.AddRadioButton(150, 48, 200, 56, "radio_grp") PDF.AnnotUnicodeCaption = "Option 2" PDF.RadioButtonExportValue = "value2" PDF.ControlChecked = False PDF.SaveToFile "test.pdf", true
See Also
Reference


