Components for Developers
© 2000-2008, Two Pilots

PDF Library Download Features Manual Tutorials FAQ Pricing HTML2PDF Add-on History In the Lab

PDF Creator Pilot documentation

Download CHM version of this manual.
Actions
AddControlToAction

See Also Example
Collapse All

Associates an action with a control.

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 method associates a control (number can be retrieved from functions like AddButton or others) with an action (number can be retrieved from functions like CreateSubmitFormAction or others).

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

PDF Library Download Features Manual Tutorials FAQ Pricing HTML2PDF Add-on History In the Lab

 

 

PDF Library | Virtual Printer | Converters to PDF

Support | Blog | Forum | Contacts

© 2000-2008, Two Pilots