Thank you in advance to anyone who can help this coldfusion noob.

What I am trying to do seems easy enough but clearly I am having very serious problems. ;D

I am trying to populate a pdf with data from a database.


//Here is the page that lists all the users and allows a link to the user details
//this is working fine

<cfquery name="GetUsers" datasource="[ommitted]"> 
    SELECT ChildAssessmentID,FirstName, LastName
    FROM ChildAssessments 
   
</cfquery> 
<h4>Child Assessment List</h4> 
<table> 
<tr> 
<th>User ID</th>
<th>First Name</th> 
<th>Last Name</th> 

</tr> 
<cfoutput query="GetUsers"> 
<tr> 
<td><a href="pdf.cfm?ChildAssessmentID=#ChildAssessmentID#">#ChildAssessmentID#</a></td>
<td>#FirstName#</td> 
<td>#LastName#</td> 

</tr> 
</cfoutput> 
</table>

//end page

//Here is my query getting the details of user with the ChildAssessmentID
//this seems to be making the correct query but is not working with the pdf

<cfquery name="getuserdetails" datasource="[omitted]">
  select FirstName, LastName
  from ChildAssessments where ChildAssessmentID=#URL.ChildAssessmentID#
</cfquery>

Here is my cfpdfform code
//pdf.cfm

<cfpdfform action="populate" source="pdf/testform.pdf" overwrite="yes">
	<cfpdfsubform name="form1" >
		<cfpdfformparam name="ChildAssessmentID"  value="#URL.ChildAssessmentID#">
		 <cfpdfformparam name="FirstName" value="#getuserdetails.FirstName#">
            <cfpdfformparam name="LastName" value="#getuserdetails.LastName#">
		
	</cfpdfsubform>
</cfpdfform>

The form I am trying to populate (pdftestform.pdf) displays the top record in LiveCycleDesigner using "Preview Mode", but does not display data using the coldfusion.

I hope this makes sense.

Recommended Answers

All 15 Replies

Have you tried cfdocument? You can generate PDF files using that tag. Let me know.

Thank you cfwebedeveloper.
Yes, I've tried the cfdocument tag, and it is creating pdf forms for me, but I'd like to get data from a database to populate the pdf form based on the user id that is passed in the url.

Dumb question but are you sure the query is dumping out data? Try a cfdump on the query.

Not a dumb question. Thank you. I had to double check. Yes. It is dumping the query based on userID passed in URL. I can't figure out why it won 't appear in a pdf. It seems like I'm so close.

thanks again!

Are you sure you are getting results back from the database? Sounds like you are getting no results back from the database. Do a quick cfoutput of getuserdetails.recordcount and see if it 0 or 1.

I'm getting "1"

Weird...I will try to replicate this once I get home from work. I havn't messed with cfpdfform before but would be nice to figure out this issue.

Thanks for your help! I really appreciate it!

Totally did not get around to this, busy studying for a certification. Did you resolve your issue yet?

Yes, I've tried the cfdocument tag, and it is creating pdf forms for me, but I'd like to get data from a database to populate the pdf form based on the user id that is passed in the url.

Huh? ;) cfdocument doesn't create or populate forms. But you can populate forms with cfpdfform.

Hi - Thanks for everyones help. I did resolve my problem. Using the example from adobe cfdeveloper pointed out.
Complete Total user error. The Adobe documentation is correct.

Hi - Thanks for everyones help. I did resolve my problem. Using the example from adobe cfdeveloper pointed out.
Complete Total user error. The Adobe documentation is correct.

Oh, I believed cfpdfform would work. It was the talk about cfdocument and forms that had me scratching my head ;-) Glad it's resolved.

Wrap the whole page, query and all, in the cfdocument tag. It should be the first line and last lines of the whole page. Make sure your variables that are passed are scoped with the url/cookie/session. I create dynamic pdf's all the time and this problem the first time I tried it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.