AddControlToAction
IPDFDocument4 :: Actions

See Also Example
Collapse All

This method associates a control with an action.

Syntax

HRESULT AddControlToAction (
LONG actionNumber,
LONG controlNumber
)
Parameters
actionNumber
Number of an existing action

controlNumber
Number of an existing control

Return value
If successful, this method returns S_OK. If it fails, this method should return one of the error values.

Remarks

The associated control's number can be retrieved from AddButton and other methods. The associated action's number can be retrieved from CreateSubmitFormAction and other methods.

Example

PDF Form Example

Delphi
[copy to clipboard]
{ PDF object is supposed to be created }
e1 := PDF.AddEditBox(20, 20, 120, 32, 'field1');
PDF.AnnotUnicodeText := 'Some text';

e2 := PDF.AddEditBox(140, 20, 240, 32, 'field2');
PDF.AnnotUnicodeText := 'Other text';

c1 := PDF.AddCheckBox(250, 20, 262, 32, 'check1');

b1 := PDF.AddButton(180, 60, 240, 80, 'but1');
PDF.AnnotUnicodeCaption := 'Submit';

submit := PDF.CreateSubmitFormAction('http://127.0.0.1', true, smPost);
PDF.OnControlMouseUp := submit;

b2 := PDF.AddButton(260, 60, 320, 80, 'but2');
PDF.AnnotUnicodeCaption := 'Hide some...';

a_hide := PDF.CreateHideControlAction();
a_show := PDF.CreateShowControlAction();

// Now add needed controls to be hidden/shown on button pressed/released
PDF.AddControlToAction(a_hide, e1);
PDF.AddControlToAction(a_hide, c1);
PDF.AddControlToAction(a_hide, b1);
PDF.AddControlToAction(a_show, e1);
PDF.AddControlToAction(a_show, c1);
PDF.AddControlToAction(a_show, b1);

PDF.OnControlMouseDown := a_hide;
PDF.OnControlMouseUp := a_show;

PDF.SaveToFile('test.pdf', true);
C/C++
[copy to clipboard]
// PDF object is supposed to be created
long e1 = PDF->AddEditBox(20, 20, 120, 32, "field1");
PDF->AnnotUnicodeText = L"Some text";

long e2 = PDF->AddEditBox(140, 20, 240, 32, "field2");
PDF->AnnotUnicodeText = L"Other text";

long c1 = PDF->AddCheckBox(250, 20, 262, 32, "check1");

long b1 = PDF->AddButton(180, 60, 240, 80, "but1");
PDF->AnnotUnicodeCaption = L"Submit";

long submit = PDF->CreateSubmitFormAction("http://127.0.0.1", true, smPost);
PDF->OnControlMouseUp = submit;

long b2 = PDF->AddButton(260, 60, 320, 80, "but2");
PDF->AnnotUnicodeCaption = L"Hide some...";

long a_hide = PDF->CreateHideControlAction();
long a_show = PD->CreateShowControlAction();

// Now add needed controls to be hidden/shown on button pressed/released
PDF->AddControlToAction(a_hide, e1);
PDF->AddControlToAction(a_hide, c1);
PDF->AddControlToAction(a_hide, b1);
PDF->AddControlToAction(a_show, e1);
PDF->AddControlToAction(a_show, c1);
PDF->AddControlToAction(a_show, b1);

PDF->OnControlMouseDown = a_hide;
PDF->OnControlMouseUp = a_show;

PDF->SaveToFile("test.pdf", true);
C#
[copy to clipboard]
// PDF object is supposed to be created
long e1 = PDF.AddEditBox(20, 20, 120, 32, "field1");
PDF.AnnotUnicodeText = "Some text";

long e2 = PDF.AddEditBox(140, 20, 240, 32, "field2");
PDF.AnnotUnicodeText = "Other text";

long c1 = PDF.AddCheckBox(250, 20, 262, 32, "check1");

long b1 = PDF.AddButton(180, 60, 240, 80, "but1");
PDF.AnnotUnicodeCaption = "Submit";

long submit = PDF.CreateSubmitFormAction("http://127.0.0.1", true, SubmitMethod.smPost);
PDF.OnControlMouseUp = submit;

long b2 = PDF.AddButton(260, 60, 320, 80, "but2");
PDF.AnnotUnicodeCaption = "Hide some...";

long a_hide = PDF.CreateHideControlAction();
long a_show = PDF.CreateShowControlAction();

// Now add needed controls to be hidden/shown on button pressed/released
PDF.AddControlToAction(a_hide, e1);
PDF.AddControlToAction(a_hide, c1);
PDF.AddControlToAction(a_hide, b1);
PDF.AddControlToAction(a_show, e1);
PDF.AddControlToAction(a_show, c1);
PDF.AddControlToAction(a_show, b1);

PDF.OnControlMouseDown = a_hide;
PDF.OnControlMouseUp = a_show;

PDF.SaveToFile("test.pdf", true);
Visual Basic
[copy to clipboard]
' PDF object is supposed to be created
e1 = PDF.AddEditBox(20, 20, 120, 32, "field1")
PDF.AnnotUnicodeText = "Some text"

e2 = PDF.AddEditBox(140, 20, 240, 32, "field2")
PDF.AnnotUnicodeText = "Other text"

c1 = PDF.AddCheckBox(250, 20, 262, 32, "check1")

b1 = PDF.AddButton(180, 60, 240, 80, "but1")
PDF.AnnotUnicodeCaption = "Submit"

submit = PDF.CreateSubmitFormAction("http://127.0.0.1", true, 1) 'SubmitMethod.smPost
PDF.OnControlMouseUp = submit

b2 = PDF.AddButton(260, 60, 320, 80 ,"but2")
PDF.AnnotUnicodeCaption = "Hide some..."

a_hide = PDF.CreateHideControlAction()
a_show = PDF.CreateShowControlAction()

' Now add needed controls to be hidden/shown on button pressed/released
PDF.AddControlToAction a_hide, e1
PDF.AddControlToAction a_hide, c1
PDF.AddControlToAction a_hide, b1
PDF.AddControlToAction a_show, e1
PDF.AddControlToAction a_show, c1
PDF.AddControlToAction a_show, b1

PDF.OnControlMouseDown = a_hide
PDF.OnControlMouseUp = a_show

PDF.SaveToFile "test.pdf", true

See Also

Reference