We help IT Professionals succeed at work.

How do I populate PDF with cfpdfformparam

trifecta2k
trifecta2k used Ask the Experts™
on
I am trying to populate a pdf with ColdFusion.  I've done this before using cfpdfformparam and it was fairly easy, however this time I just can seem to get it to work.   The PDF has an array inside it and I don't know how to access it to place my data there.  I've attached an image of the dump.  I want to put something in the dob and name fields.  I've also attached my code.  Thanks for the help Image of the pdf dump
<cfpdfform action="populate" source="RAF_final.pdf" destination="r_form_withData.pdf" overwrite="true" overwritedata="yes">
    <cfpdfsubform name="form1">
        <cfpdfsubform name="page1">
            <cfpdfsubform name="resInfo1">    
                <cfpdfsubform name="Row1">
                   <cfpdfformparam name="dob" value="12/7/1954" />
                   <cfpdfformparam name="name" value="John Morgan" />
                </cfpdfsubform>   		
           </cfpdfsubform>
       </cfpdfsubform>
   </cfpdfsubform>
</cfpdfform>

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Brijesh ChauhanStaff IT Engineer

Commented:
Can you also attach you PDF ?

Author

Commented:
I've attached the PDF
RAF-final.pdf
Brijesh ChauhanStaff IT Engineer

Commented:
You have to defined an XML structure according to above .. remember ROW1 is an array which contains 2 items, and the second one contains the DOB and NAME..

Below is working.. it is not the fields that you are looking for though.. but you need to change the XML to define your structure...

<cfprocessingdirective suppresswhitespace="yes">
<cfxml variable="pdfxml">
	<form1>
    	<page1>
         <resInfo2> 
         	<Row1>
            	<divorced>1</divorced>
                <female>1</female>
            </Row1>
         </resInfo2>
       </page1>
    </form1>
</cfxml>
</cfprocessingdirective>


<cfpdfform action="populate" source="RAF-final.pdf" destination="r_form_withData.pdf" overwrite="true" overwritedata="yes" xmldata="#pdfxml#">
</cfpdfform>

Open in new window

Author

Commented:
I tried that but I don't know how to access the array.  I can do what you did, but resInfo2 doesn't have an array.  Can you give me an example of how to add the DOB and Name using XML
Brijesh ChauhanStaff IT Engineer

Commented:
My XML knowledge is limited, but you can

1. Wait for other Experts to help you out with it

2. Add XML ZONE to this question and XML experts can help you in building the correct structure.

3. Open another question regarding how to have the XML created.

Most Valuable Expert 2015
Commented:
<cfpdfform action="populate" source="RAF_final.pdf" destination="r_form_withData.pdf" overwrite="true" overwritedata="yes">
    <cfpdfsubform name="form1">
        <cfpdfsubform name="page1">
            <cfpdfsubform name="resInfo1">    
                <cfpdfsubform name="Row1" index="1">
                   <cfpdfformparam name="dob" value="" />
                   <cfpdfformparam name="name" value=""/>
                </cfpdfsubform>   		
                <cfpdfsubform name="Row1" index="2">
                   <cfpdfformparam name="dob" value="12/7/1954" />
                   <cfpdfformparam name="name" value="John Morgan"/>
                </cfpdfsubform>   		
           </cfpdfsubform>
       </cfpdfsubform>
   </cfpdfsubform>
</cfpdfform>

Open in new window