Print Page | Close Window

Form fields visible, not accessible

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=2769
Printed Date: 10 May 24 at 2:37PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Form fields visible, not accessible
Posted By: JohnT
Subject: Form fields visible, not accessible
Date Posted: 24 Oct 13 at 5:11AM
I loop through a table and create radio button and checkbox form fields.

The fields appear on the displayed PDF.

However, if I programmatically try to access certain fields either by title or index, they are not available.

Even checking with the following Delphi diagnostic loop reveals that certain fields are not there.

    TotalFormFields := DPL.FormFieldCount();
      for i := 1  to TotalFormFields do
      Begin
         FieldValue := DPL.GetFormFieldValue(i);
         FormFieldTitle := DPL.GetFormFieldTitle(i);
         Showmessage(inttostr(i) + ' ' + FormFieldTitle + ' ' + FieldValue);
      end;

And of course DPL.SetFormFieldValueByTitle and DPL.SetFormFieldValue do not work since the fields
seemingly disapear. The confusing part is that the fields are visually available and their titles display.

Thanks for any hints. Hope this gives at least enough to point me in the right direction.

John 



Replies:
Posted By: JohnT
Date Posted: 24 Oct 13 at 5:00PM
Update...

As expected it appears to be my problem.

When creating simple checkboxes for all fields everything is fine.

I have some sort of problem when creating subfields for radiobuttons.
The subfields are visible and a call to:
DPL.DrawText(500,Vertical, DPL.GetFormFieldTitle(r1));
shows the expected result.
More later when I find the cause.
Sorry for the "static."

John


Posted By: AndrewC
Date Posted: 28 Oct 13 at 12:48AM
John,

Here is some sample code that you might find useful

http://www.debenu.com/kb/create-pdf-form-fields-programmatically/" rel="nofollow - http://www.debenu.com/kb/create-pdf-form-fields-programmatically/

Andrew.



Posted By: JohnT
Date Posted: 28 Oct 13 at 6:22PM
Thanks Andrew.

Unfortunately, I am still having a problem.

Hopefully a brief read of this Delphi excerpt by a set of fresh eyes will tell me what I am doing wrong.

I loop through a table and make a decision whether a field should be a radio button, (mutually exclusive) or simply a checkbox. The checkboxes work fine. Only the first radio button can actually have its value set. All subsequent attempts to set a value fail.

The raw code with the diagnostics included are shown. I test to see if the value can be set on
the radiobutton field. It is successful if it happens to be the FIRST radiobutton in a group. After that
it will not set the value.

Thanks for any insight anyone might have.

Sincerely,

John

if OptionsBookMasterQuery.FieldByName('MutuallyExclusive').value = True then
begin
   r2 := DPL.NewFormField(OptionsBookMasterQuerySelectionName.value, 4);
MarkNone := True; ///variable used to decide if a "None" radiobutton will be shown/value set
Showmessage('Created: ' + inttostr(r2)); ///diagnostic confirms the index number is there
end;

...
while not Form1.OptionsBookQuery.eof do
Begin
ProspectusPriceListCheckQuery.close;
ProspectusPriceListCheckQuery.Params[0].Value := Form1.CustomerLocalcustnmr.value;
ProspectusPriceListCheckQuery.Params[1].Value := Form1.OptionsBookQueryRecord.value;
ProspectusPriceListCheckQuery.Open;

 if ((OptionsBookMasterQuery.FieldByName('MutuallyExclusive').value <> True) or (OptionsBookQuery.RecordCount = 1)) then
begin /// checkboxes work fine...problem down below with radio buttons
r0 := DPL.NewFormField(Trim(FloatToStr(OptionsBookQueryRecord.value)), 3); ///checkbox
DPL.SetFormFieldBounds(r0, 50, Vertical - 15, 20, 20);
DPL.SetFormFieldCheckStyle(r0, csCheck, 1);
DPL.SetFormFieldBorderColor(r0,0,0,0);

end;// else

if OptionsBookMasterQuery.FieldByName('MutuallyExclusive').value = True then

begin
Showmessage('Field: ' +OptionsBookQueryName.value + ' ' + Trim(FloatToStr(OptionsBookQueryRecord.value)) + ' '+  inttostr(r2));

r1 := DPL.AddFormFieldSub(r2, Trim(FloatToStr(OptionsBookQueryRecord.value)));
Showmessage('SubField: ' +OptionsBookQueryName.value + ' ' + Trim(FloatToStr(OptionsBookQueryRecord.value)) + ' '+  inttostr(r1));

DPL.SetFormFieldBounds(r1, 50, Vertical - 15, 20, 20);
DPL.SetFormFieldCheckStyle(r1, csCheck, 1);
DPL.SetFormFieldBorderColor(r1,0,0,0);
If ProspectusPriceListCheckQuery.recordcount = 1 then
begin
c1 := 0;
c1 := DPL.SetFormFieldValue(r1,'Yes');
if c1 <> 0 then  showmessage('SUCCESS');
c2 := 0;
c2 := DPL.SetFormFieldValueByTitle(Trim(FloatToStr(ProspectusPriceListCheckQuery.fieldbyname('PriceListRecordNumber').value)),'Yes');// 
if c2 <> 0 then  showmessage('SUCCESS 2');
Showmessage('R1 ' + DPL.GetFormFieldValue(R1));
MarkNone := False;
end;
end;




Posted By: JohnT
Date Posted: 28 Oct 13 at 7:38PM
PROBLEM SOLVED!

I misunderstood how the SetFormFieldValue function works.

Thanks for "listening."

John



Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk