Skip to main content
MercuryNewt
Participating Frequently
April 22, 2009
Answered

cfpdfform inside cfdocument outbound as a pdf variable

  • April 22, 2009
  • 1 reply
  • 3373 views

OK, here's the scenario: I have a client who needs to populate a PDF form (1098) using data from a database.  Right now they have code that simply uses cfpdfform to output the finished "populated" PDF.  Now, here's the problem, we would like to abstract this and create a pdf variable, outbound from a function call, that we can then cfcontent to the screen as a PDF.  The docs indicate that you can create a pdf variable from a cfpdfform using cfdocument, however implementing it has been proven to be problematic.  Is it just not possible to create a pdf variable from a cfpdfform embedded in a cfdocument?  Creating a pdf file works fine, but we don't really need the physical file on the server, just the generated pdf output to the screen.  Any suggestions?

This topic has been closed for replies.
Correct answer -__cfSearching__-

Skip embedding and use cfsavecontent to capture the cfpdfform output in a variable.

<cfsavecontent >

     <cfpdfform  action="populate"  ... (omit destination) ... >

     </cfpdfform>

</cfsavecontent>

MercuryNewt wrote:

Is it just not possible to create a pdf variable from a cfpdfform embedded in a cfdocument?

Yes, you can.  Though you need to use at least on cfdocumentsection and apparently it must be before the cfpdfform tags or it does not work. At least not in my tests.

1 reply

-__cfSearching__-Correct answer
Inspiring
April 25, 2009

Skip embedding and use cfsavecontent to capture the cfpdfform output in a variable.

<cfsavecontent >

     <cfpdfform  action="populate"  ... (omit destination) ... >

     </cfpdfform>

</cfsavecontent>

MercuryNewt wrote:

Is it just not possible to create a pdf variable from a cfpdfform embedded in a cfdocument?

Yes, you can.  Though you need to use at least on cfdocumentsection and apparently it must be before the cfpdfform tags or it does not work. At least not in my tests.

MercuryNewt
Participating Frequently
April 28, 2009

That worked, but I'm still perplexed as to why it would not work within the cfdocument tag.  Thanks for your help!

Inspiring
April 28, 2009

I do not normally use embedding, but it did work for me as long as the cfdocumentsection was in the right place.  But, it probably would not be a good solution for this case anyway, because cfdocumentsection adds a page break. So you would have a blank first page.

http://cfsearching.blogspot.com/2009/04/embedding-pdf-form-in-cfdocument.html