954,585 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Help populating a pdf with coldfusion

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.

dottomm
Junior Poster in Training
89 posts since Nov 2007
Reputation Points: 9
Solved Threads: 5
 

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

cfwebdeveloper
Junior Poster in Training
78 posts since May 2011
Reputation Points: 19
Solved Threads: 8
 

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.

dottomm
Junior Poster in Training
89 posts since Nov 2007
Reputation Points: 9
Solved Threads: 5
 

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

cfwebdeveloper
Junior Poster in Training
78 posts since May 2011
Reputation Points: 19
Solved Threads: 8
 

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!

dottomm
Junior Poster in Training
89 posts since Nov 2007
Reputation Points: 9
Solved Threads: 5
 

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.

cfwebdeveloper
Junior Poster in Training
78 posts since May 2011
Reputation Points: 19
Solved Threads: 8
 

I'm getting "1"

dottomm
Junior Poster in Training
89 posts since Nov 2007
Reputation Points: 9
Solved Threads: 5
 

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.

cfwebdeveloper
Junior Poster in Training
78 posts since May 2011
Reputation Points: 19
Solved Threads: 8
 

What does your testform.pdf look like?
This might help too, http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=formsPDF_04.html

cfwebdeveloper
Junior Poster in Training
78 posts since May 2011
Reputation Points: 19
Solved Threads: 8
 

Thanks for your help! I really appreciate it!

dottomm
Junior Poster in Training
89 posts since Nov 2007
Reputation Points: 9
Solved Threads: 5
 

Yes. I saw that example, and it's basically where I started.

What does your testform.pdf look like? This might help too, http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=formsPDF_04.html
dottomm
Junior Poster in Training
89 posts since Nov 2007
Reputation Points: 9
Solved Threads: 5
 

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

cfwebdeveloper
Junior Poster in Training
78 posts since May 2011
Reputation Points: 19
Solved Threads: 8
 
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 youcan populate forms with cfpdfform.

arrgh
Posting Whiz
381 posts since Dec 2008
Reputation Points: 32
Solved Threads: 47
 

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.

dottomm
Junior Poster in Training
89 posts since Nov 2007
Reputation Points: 9
Solved Threads: 5
 
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.

arrgh
Posting Whiz
381 posts since Dec 2008
Reputation Points: 32
Solved Threads: 47
 

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.

jsmall26
Light Poster
36 posts since Jan 2008
Reputation Points: 10
Solved Threads: 3
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: