Components for Developers
© 2000-2012, Two Pilots

PDF Library Download Features Manual Tutorials FAQ Pricing HTML2PDF-X Pilot History In the Lab

PDF Creator Pilot documentation

Download CHM version of this manual.
Actions
AddControlToAction

See Also Example
Collapse All

This function associates an action with a control.

Syntax

LONG AddControlToAction (
LONG actionIndex,
LONG controlIndex
)
Parameters
actionIndex
Index of an existing action.

controlIndex
Index of an existing control.

Return value
If successful, this function returns the number of associated control-action pairs. If an error occurred, it returns -1.

Remarks

AddControlToAction associates a control (index from functions like PDFPAGE_CreateControl_Button or others) with an action (index from functions like CreateSubmitFormAction or others).

Equivalent in new interface: IPDFDocument4::AddControlToAction.

Example

AddControlToAction Example

Delphi
[copy to clipboard]
{ PDF object is supposed to be created }
PDF.BeginDoc;

e1 := PDF.PDFPAGE_CreateControl_Edit('field1', 20, 20, 120, 32);
PDF.PDFANNOTATION_Text := 'Some text';

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

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

b1 := PDF.PDFPAGE_CreateControl_Button('but1', 180, 60, 240, 80);
PDF.PDFANNOTATION_Caption := 'Submit';
PDF.PDFANNOTATION_OnMouseUp := PDF.CreateSubmitFormAction('http://127.0.0.1', true, stGet);

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

a_hide := PDF.CreateVisibleControlAction(false);
a_show := PDF.CreateVisibleControlAction(true);

{ 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.PDFANNOTATION_OnMouseDown := a_hide;
PDF.PDFANNOTATION_OnMouseUp := a_show;

PDF.EndDoc;
C/C++
[copy to clipboard]
// PDF object is supposed to be created
PDF->BeginDoc();

LONG e1 = PDF->PDFPAGE_CreateControl_Edit("field1", 20, 20, 120, 32);
PDF->PDFANNOTATION_Text = "Some text";

LONG e2 = PDF->PDFPAGE_CreateControl_Edit("field2", 140, 20, 240, 32);
PDF->PDFANNOTATION_Text = "Other text";

LONG c1 = PDF->PDFPAGE_CreateControl_Checkbox("check1", 250, 20, 262, 32);

LONG b1 = PDF->PDFPAGE_CreateControl_Button("but1", 180, 60, 240, 80);
PDF->PDFANNOTATION_Caption = "Submit";
PDF->PDFANNOTATION_OnMouseUp = PDF->CreateSubmitFormAction("http://127.0.0.1", TRUE, stGet);

LONG b2 = PDF->PDFPAGE_CreateControl_Button("but2", 260, 60, 320, 80);
PDF->PDFANNOTATION_Caption = "Hide some...";

LONG a_hide = PDF->CreateVisibleControlAction(FALSE);
LONG a_show = PDF->CreateVisibleControlAction(TRUE);

// 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->PDFANNOTATION_OnMouseDown = a_hide;
PDF->PDFANNOTATION_OnMouseUp = a_show;

PDF->EndDoc();
C#
[copy to clipboard]
// PDF object is supposed to be created
PDF.BeginDoc();

long e1 = PDF.PDFPAGE_CreateControl_Edit("field1", 20, 20, 120, 32);
PDF.PDFANNOTATION_Text = "Some text";

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

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

long b1 = PDF.PDFPAGE_CreateControl_Button("but1", 180, 60, 240, 80);
PDF.PDFANNOTATION_Caption = "Submit";
PDF.PDFANNOTATION_OnMouseUp = PDF.CreateSubmitFormAction("http://127.0.0.1", true, TxPDFSubmitType.stGet);

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

long a_hide = PDF.CreateVisibleControlAction(false);
long a_show = PDF.CreateVisibleControlAction(true);

// 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.PDFANNOTATION_OnMouseDown = a_hide;
PDF.PDFANNOTATION_OnMouseUp = a_show;

PDF.EndDoc();
Visual Basic
[copy to clipboard]
' PDF object is supposed to be created
PDF.BeginDoc

e1 = PDF.PDFPAGE_CreateControl_Edit("field1", 20, 20, 120, 32)
PDF.PDFANNOTATION_Text = "Some text"

e2 = PDF.PDFPAGE_CreateControl_Edit("field2", 140, 20, 240, 32)
PDF.PDFANNOTATION_Text = "Other text"

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

b1 = PDF.PDFPAGE_CreateControl_Button("but1", 180, 60, 240, 80)
PDF.PDFANNOTATION_Caption = "Submit"
PDF.PDFANNOTATION_OnMouseUp = PDF.CreateSubmitFormAction("http://127.0.0.1", True, 0)

b2 = PDF.PDFPAGE_CreateControl_Button("but2", 260, 60, 320, 80)
PDF.PDFANNOTATION_Caption = "Hide some..."

a_hide = PDF.CreateVisibleControlAction(False)
a_show = PDF.CreateVisibleControlAction(True)

' 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.PDFANNOTATION_OnMouseDown = a_hide
PDF.PDFANNOTATION_OnMouseUp = a_show

PDF.EndDoc

See Also

Reference

PDF Library Download Features Manual Tutorials FAQ Pricing HTML2PDF-X Pilot History In the Lab

 

 

PDF Library | Virtual Printer | Converters to PDF

Support | Blog | Forum | Contacts

© 2000-2012, Two Pilots