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 > I need help - I can help
  New Posts New Posts RSS Feed - Group of form fields?
  FAQ FAQ  Forum Search   Register Register  Login Login

Group of form fields?

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


Joined: 28 Dec 11
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote DataCrypt Quote  Post ReplyReply Direct Link To This Post Topic: Group of form fields?
    Posted: 28 Dec 11 at 5:46AM
Hello.  I'm need to create some form fields on a PDF and noticed that QuickPDF Library allows me to create form fields very easily.  The PDF that I need to place them on is a scanned document and the fields may not be exactly in the same place (x & y coordinates) each time - but should be close.  I can allow the user to adjust the field positions a little bit, but  I would like to know if I could put these fields in some "group"?  Then possibly "move" the group position so they all move together rather than having to move them one by one.  Hope that makes sense.  The fields are very close together (ie. Name, Address, Phone, etc...).  Any help or suggestions would be appreciated.

Thank you for your time.

Best Regards,

DataCrypt
Back to Top
Ingo View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 29 Oct 05
Status: Offline
Points: 3530
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ingo Quote  Post ReplyReply Direct Link To This Post Posted: 28 Dec 11 at 10:44AM
Hi!

Groupwise positioning isn't possible but
regarding scanned documents normally
all fields could be a bit outside ...
so you can take one factor valid for each field
for repositioning.

Cheers, Ingo
Back to Top
edvoigt View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 Mar 11
Location: Berlin, Germany
Status: Offline
Points: 111
Post Options Post Options   Thanks (0) Thanks(0)   Quote edvoigt Quote  Post ReplyReply Direct Link To This Post Posted: 29 Dec 11 at 6:37PM
Hi,

I'm not so familar with forms, but I see an easy solution. Build your group alone.

(with Delphi 7)


var
  ParentFormId, i: integer;
  Childs: array[1..2] of integer; // your group
begin
  QP := TQuickPDF.Create;
  QP.UnlockKey(...);
  QP.SetMeasurementUnits(1);
  ParentFormId := QP.NewFormField('Parent', 7);

  Childs[1] := QP.NewChildFormField(ParentFormId, 'Child1', 1);
  Childs[2] := QP.NewChildFormField(ParentFormId, 'Child2', 1);

  for i:=1 to 2
  do QP.SetFormFieldBounds(Childs, 25, 120+i*12, 160, 10);

The array Childs plays the role of a group. If the childfields differ in dimensions, the array childs needs as items records with this values.

But it is much easier possible, because it is enough, to change the position of the parent.

  QP.SetFormFieldBounds(ParentFormId, 10, 100, 160, 22);

does what you want.

Cheers

Werner




Edited by edvoigt - 29 Dec 11 at 6:46PM
Back to Top
DataCrypt View Drop Down
Beginner
Beginner


Joined: 28 Dec 11
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote DataCrypt Quote  Post ReplyReply Direct Link To This Post Posted: 31 Dec 11 at 1:58AM
Thank you for the replies.  My fields are currently different sizes, but I can make them all the same size.  If I can make the parent field and then do them as children, as suggested, this idea will work for me.  I'll give it a try.  I'm going to be using C# or the older VB6 for this one.

Thanks again,

DataCrypt
Back to Top
edvoigt View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 Mar 11
Location: Berlin, Germany
Status: Offline
Points: 111
Post Options Post Options   Thanks (0) Thanks(0)   Quote edvoigt Quote  Post ReplyReply Direct Link To This Post Posted: 31 Dec 11 at 10:50AM
Hi,

here is a better solution. The idea to deal with parents is not so good. Now different dimensions are handled and we build a group more free, so that you may manage so much different groups as you want. You may use them for more then only moving...

A small array contains for every formfield a groupnumber of our choice. It is our own and has no
relation to any kind of PDF-property. That's all.


var
  i: integer;
  l, t, w, h,        // bounds of a formfield
  dx, dy: double;    // to move the fields
  groups: array [1..4] of integer; // for every child the groupnumber it belongs to
  groupNo: integer;
begin
  QP := TQuickPDF.Create;
  QP.UnlockKey(...);
  QP.SetMeasurementUnits(1);       // I like mm
  QP.SetOrigin(0);                 // left, bottom

  QP.NewFormField('Field1', 1);
  QP.NewFormField('Field2', 1);
  QP.NewFormField('Field3', 1);
  QP.NewFormField('Button', 2);
  // we define in which group a field is a member
  groups[1] := 1;
  groups[2] := 0;
  groups[3] := 1;
  groups[4] := 1;

  QP.DrawLine(25, 0, 25, 297);   // only for orientation
  for i:=1 to QP.FormFieldCount
  do begin
    QP.SetFormFieldBorderColor(i, 0, 0, 0);
    if i=3
    then QP.SetFormFieldBounds(i, 25, 20+i*12,  60, 10)  // a shorter field
    else QP.SetFormFieldBounds(i, 25, 20+i*12, 160, 10);
  end;

  // show the membership as initial value in textfields
  for i:=1 to QP.FormFieldCount
  do case QP.GetFormFieldType(i) of
     1: QP.SetFormFieldvalue(i, Format('field%d is member of group %d',[i, groups]));
     2: QP.SetFormFieldCaption(i, Format('Buttonfield%d is member of group %d',[i, groups]));
     end;
  QP.SaveToFile('Forms0.pdf');       // before moving
// now let's move it
  dx := 10;
  dy := 80;
  groupNo := 1; // move for group 1
  for i:=1 to QP.FormFieldCount
  do begin // move all Fields with of group by dx and dy
    if groups=groupNo
    then begin               // this field shall be moved by dx, dy
      l := QP.GetFormFieldBound(i, 0);            // get old bounds
      t := QP.GetFormFieldBound(i, 1);
      w := QP.GetFormFieldBound(i, 2);
      h := QP.GetFormFieldBound(i, 3);
      QP.SetFormFieldBounds(i, l+dx, t+dy, w, h); // set the new position
    end;
  end;
  QP.SaveToFile('Forms.pdf');        // after moving
  QP.Free;
end;


There is a small issue in the post. It switches all text to italic, because the use of brakets in the format-statements.


Enjoy and a happy new year,

Werner
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