Link to home
Start Free TrialLog in
Avatar of trifecta2k
trifecta2k

asked on

View PDF Form Fields

I am using ColdFusion to fill out PDF forms.  I am using the cfpdfform tag and everything seems to work just fine.  I take a blank PDF form and then fill it out with data from a query and then save the file with a new name.  The problem I am having is that the PDF form keeps changing.  This is a 5 page form so when field names change it's a real problem.  Is there anyway I can display the PDF form with the field names next to the field?  So for example

Name: [                               ] name_field
Addres: [                                               ] addr_field

Something like that.  This way I can quickly see which field name is changed.  Or are their any other suggestions?  Thanks.
Avatar of _agx_
_agx_
Flag of United States of America image

Use action="read" to get the form fields.  

<!---- use the "result" or "XMLData" attributes --->
<cfpdfform action="read"
      source="#pathToYourFile#"
        result="formData"
      >
<cfdump var="#formData#">

Then either dump that data for viewing or use it "populate" the form. So the form field _values_ are the
field names:

Name: [  name_field ]
Address: [ addr_field ]
....



Avatar of trifecta2k
trifecta2k

ASKER

I did that, but the it dumps the form fields in what seems to be a random order.  Here is an example of the dump..
c1_1(0) Yes  
c1_1a(0) [empty string]  
c1_1b(0) [empty string]  
c1_1c(0) [empty string]  
c1_5(0) Yes  
c1_6(0) [empty string]  
c1_6a(0) Yes  
c2_01(0) [empty string]  
c2_01a(0) [empty string]  
c2_01b(0) [empty string

I have no idea what c2_01b(0) is?  The only way I can figure that out is if I fill out the form with dummy information and then check the dump.  That's why I was wondering if I can have the field names show up next the fields on the form.  
The "read" action should return a structure containing the actual form field names, whatever they are. I can't see your form, so I don't know the naming convention for your fields. They could be names like "name_field", "addr_field" or possibly "c1_1(0)", "c1_1a(0)".

But just use those names to populate one of your blank forms.  In other words, instead of populating it with an actuall name, addresses, use the field names as the "values".  So the field names will show up in the text boxes next to each label. Make sense?

Name: [  c1_1(0) ]
Address: [ c1_1a(0)  ]
ASKER CERTIFIED SOLUTION
Avatar of _agx_
_agx_
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
i see what you are saying and I like that idea.  I have one question.  Once I do something like:
<cfpdfform action="read" source="f941.pdf" result="formData" />

How can I use that data?  What I mean is that I would like to then do something like this:

<cfpdfform action="populate" source="f941.pdf" destination="test.pdf">
<cfloop #formdata#>
  <cfpdfformparam name="#field#" value="#field#" />
</cfloop>
</cfpdfform>

How can I loop through the formdata?

Did my last comment answer that question (ie Use <cfloop collection="..." ...>) ?