Print Page | Close Window

GetFormFieldPage - Checkbox

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=3699
Printed Date: 04 May 24 at 4:27PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: GetFormFieldPage - Checkbox
Posted By: waynefulcher
Subject: GetFormFieldPage - Checkbox
Date Posted: 23 Apr 19 at 7:20PM
OK, I know you guys are probably tired of hearing from me, but I am hopeful if I can resolve any one of my issues that it may lead to resolving other issues.

I am using FoxIt PhantomPDF 9.4.1 to edit some pdfs. 
In my Delphi 7 app using the QuickPDF 16.x and running the following code to list all the fields in this PDF.

    for FieldIX := 1 to qpdf.FormFieldCount do begin
      sLine := ' Pg: '+IntToStr(qpdf.GetFormFieldPage(FieldIX))+
               ' Ht: '+FloatToStr(qpdf.GetFormFieldBound(FieldIX, PDF_Bound_Height))+
               ' Wd: '+FloatToStr(qpdf.GetFormFieldBound(FieldIX, PDF_Bound_Width));
      
      sortedFields.Add(PadR(qpdf.GetFormFieldTitle(FieldIX), maxFldWidth) + sLine) ;
    end ;

What I am finding is that for every checkbox I added to the form I am getting 0 from the GetFormFieldPage() method. Of course 0 means:
 
The form field could not be found, or the form field does not have valid page
information


I have much logic to ignore fields that return 0 for the Page but this is a valid field.
Here is a snippet of the output from the above code:
LC_DateMaturity                     Pg: 1 Ht: 12.658 Wd: 104.794
LC_InterestMethod_30360or360360_Chk Pg: 0 Ht: 0 Wd: 0
LC_InterestMethod_Actual360_Chk     Pg: 0 Ht: 0 Wd: 0
LC_InterestMethod_Actual365_Chk     Pg: 0 Ht: 0 Wd: 0
LC_InterestRateFixed_Chk            Pg: 0 Ht: 0 Wd: 0
LC_InterestRateFixedRate            Pg: 1 Ht: 10.436 Wd: 42.41
LC_InterestRateVariable_Chk         Pg: 0 Ht: 0 Wd: 0
LC_InterestRateVariableIndexRate    Pg: 1 Ht: 10.4359999999999 Wd: 42.41

All the field names with _Chk are my checkbox fields.

I was gonna upload a screenshot of phantom editor with field highlighted but I can't figure out how to insert image into the post.






Replies:
Posted By: Ingo
Date Posted: 23 Apr 19 at 10:07PM
Hi Wayne,

you can upload your sample files and images to drop box or any other file hoster and post the link for us here in the forum.
To your actual issue:
What tool was used to generate the pdf?
Are there already XFA-fields inside?
As far as i understand GetFormFieldPage you can use it this way:
First you check the form field count...
Then you're in a loop working on your form fields...
The GetFormFieldPage(form field number) in the loop returns the page where the current form field is inside.
What i THINK is:
The GetFormFieldPage doesn't know your new checkbox right after creation?



-------------
Cheers,
Ingo



Posted By: waynefulcher
Date Posted: 23 Apr 19 at 10:24PM
Yes, Yes and No.

What you described is exactly the sample code I pasted before.
But before that, the PDF is being modified by PhantomPDF 9.x.
I am not aware of what XFA-fields are in terms of how I would use them.

So my delphi code is working with an existing PDF, it is not trying to create a pdf just read info from it.

It is looping through based on FormFieldCount.
The fact that it gets the field name of the checkbox with GetFormFieldTitle(FieldIX) tells me it knows the checkbox is there. but then you call GetFormFieldPage(FieldIX) and that returns 0.



Posted By: Ingo
Date Posted: 23 Apr 19 at 10:32PM
What form fields you or the phantom are creating?
Acro or XFA?
For XFA QuickPDF offers only a small subset of functionalities.
A visible XFA field needs internally always two fields and not one - there could be the reason for your issue.
About the problem acro and xfa there is a kb-article on the Debenu pages.



-------------
Cheers,
Ingo



Posted By: Ingo
Date Posted: 23 Apr 19 at 10:34PM
This isn't the solution for your issue but it will give you an idea about the probs using acro and xfa...

https://www.debenu.com/kb/can-debenu-quick-pdf-library-print-pdf-forms-use-xfa-form-fields/



-------------
Cheers,
Ingo



Posted By: waynefulcher
Date Posted: 24 Apr 19 at 2:02PM
apparently the only fields in the pdf are the Acro fields:

when I call pdf.GetXFAFormFieldCount() I get back 0
when I call pdf.FormFieldCount I get back 66.

So to simplify the issue is simply why when I call:
pdf.GetFormFieldPage(FieldIX) do I get back a 0?

FieldIX is the incrementer in the following for loop:
    for FieldIX := 1 to pdf.FormFieldCount do begin






Posted By: Ingo
Date Posted: 24 Apr 19 at 5:54PM
Hi Wayne,

now i've understand ;-)
For my routines it's the same.
Perhaps with checkboxes it's the same but i know it from radio buttons.
Normal form fields have the index on the field itself - form fields with options have the index one level below (please think on my sample with "sex" and "male"/"female").
I think there is functionality as well in the library... the functions with "...kid..." or "...sub..." in the name could be worth a try.
I've helped myself while going through all form fields that a missing form field page number would be filled with the page number from the form field before or after.



-------------
Cheers,
Ingo



Posted By: waynefulcher
Date Posted: 24 Apr 19 at 8:48PM
ahhhh, sub-fields and kid-fields.... Thanks for the pointer...

Let me research everything I can about that and hopefully I can figure it out and how I should implement it. Then I will comeback and try to explain how its used, when and why for future developers.





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