Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > General Discussion
  New Posts New Posts RSS Feed - FindFormFieldByTitle
  FAQ FAQ  Forum Search   Register Register  Login Login

FindFormFieldByTitle

 Post Reply Post Reply
Author
Message
jwhitham View Drop Down
Beginner
Beginner


Joined: 10 Jan 06
Location: United Kingdom
Status: Offline
Points: 11
Post Options Post Options   Thanks (0) Thanks(0)   Quote jwhitham Quote  Post ReplyReply Direct Link To This Post Topic: FindFormFieldByTitle
    Posted: 15 Mar 08 at 7:20PM
Hi all,
 
I've just come across some odd behaviour when calling FindFormFieldByTitle() using Delphi7/qpdf 5.11. I'm at home at the mo where I still have the dcu version, so I wont be able to look at the source till I'm at work tomorrow (Sunday Ouch).
 
From what I can make out this function does not return 'The index of the form field with the specified title' as stated in the documentation, but 1 for success and 0 for failure. It does however seem to select the field in question, either that or calling it changes the index of the field searched for to 1.
 
Follows Delphi code to test this:
 

procedure TForm1.Button1Click(Sender: TObject);
var
  qp: tisedquickpdf; f1, i: integer;
begin
  qp := tisedquickpdf.Create;
  try
    screen.Cursor := crhourglass;
    qp.UnlockKey(iPDF_ID);
    qp.SetPageSize('A4');
    qp.SetMeasurementUnits(1);
    qp.SetOrigin(1);
    f1 := qp.AddStandardFont(5);
    qp.SelectFont(f1);
    for i := 1 to 6 do begin
      qp.NewFormField('Field ' + inttostr(i),1);
      qp.SetFormFieldDescription(i,'Field ' + inttostr(i));
      qp.SetFormFieldTextSize(i,16);
      qp.SetFormFieldValue(i,'This is form field #' + inttostr(i));
      qp.SetFormFieldBounds(i,22,20*i,180,12);
      qp.SetFormFieldVisible(i,1);
    end;
    savedialog1.Filter := 'PDF|*.pdf';
    savedialog1.DefaultExt := 'pdf';
    savedialog1.FileName := '';
    if savedialog1.Execute then begin
      qp.SaveToFile(savedialog1.FileName);
    end;
  finally
    qp.Free;
    screen.Cursor := crdefault;
  end;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
  qp: tisedquickpdf; i,fieldindex: integer; s: string;
begin
  qp := tisedquickpdf.Create;
  try
    screen.Cursor := crhourglass;
    qp.UnlockKey(iPDF_ID);
    opendialog1.Filter := 'PDF|*.pdf';
    opendialog1.FileName := '';
    if opendialog1.Execute then begin
      qp.LoadFromFile(opendialog1.FileName);
      for i := 1 to qp.FormFieldCount do begin
        s := 'Field ' + inttostr(i);
        fieldindex := qp.FindFormFieldByTitle(s);
        qp.SetFormFieldValue(fieldindex,'No longer a form field! ' + inttostr(i) + ' ' +
          inttostr(fieldindex) + ' ' + s);
        qp.FlattenFormField(fieldindex);
      end;
      qp.SaveToFile(opendialog1.FileName);
    end;
  finally
    qp.Free;
    screen.Cursor := crdefault;
  end;
end;
 
Create a PDF with button1 and view it, then flatten the fields with button2 and take a look at the values for 'fieldindex'.
Back to Top
jwhitham View Drop Down
Beginner
Beginner


Joined: 10 Jan 06
Location: United Kingdom
Status: Offline
Points: 11
Post Options Post Options   Thanks (0) Thanks(0)   Quote jwhitham Quote  Post ReplyReply Direct Link To This Post Posted: 15 Mar 08 at 7:48PM
Argh no, I'm an idiot! Please ignore the above. Once flattened the field is of course no longer a field. Should have gone from count down to 1.

Edited by jwhitham - 15 Mar 08 at 7:49PM
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. AboutContactBlogSupportOnline Store