Group of form fields?
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=2083
Printed Date: 21 May 26 at 5:20PM Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com
Topic: Group of form fields?
Posted By: DataCrypt
Subject: Group of form fields?
Date 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
|
Replies:
Posted By: Ingo
Date 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
|
Posted By: edvoigt
Date 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
|
Posted By: DataCrypt
Date 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
|
Posted By: edvoigt
Date 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
|
|