What about invoking a cfc?
can you give me example code.
This is CERTAINLY not the most elegant solution, but it shows the intention, at least.
First, on the calling page, we have the following CFC invocation (it assumes a folder structure of root/com/excel.cfc):
<cfinvoke component="com.excel" method="makePDF" firstname="Douglas" lastname="Adams" />
The "component" attribute tells CF where to look for the cfc file and the "method" attribute tells CF which "method" to run once it finds the cfc. Next, I simply pass in a couple arguments: firstname and lastname in this example. Of course, these could just as easily be FORM or URL variables (or any other kind, for that matter.
Next, here's the CFC:
<cffunction name="makePDF" access="public" output="yes">
<cfargument name="firstname" required="yes">
<cfargument name="lastname" required="yes">
<cfheader name="content-disposition" value="attachment; filename=mypdf.pdf">
You'll notice at the top I have the arguments expected for this method specified--the same two that I passed from the calling page. Next, I simply create the document content.
The most important part is the <cfheader>--by setting the "value" to what it is, it will force a download of the pdf, rather than trying to load it in the same page. Finally, I just output the document content between <cfdocument> tags with a format of "pdf" which will take care of the pdf generation.
Again, not the most elegant solution, but I think it will work. Hope it helps.
Thanks for taking time and replying to my post.
I am not sure how can i use your example but here is what i have. i have a coldfusion file2 that uses cfdocumentitem to generate pdf. for this file i need to just pass one value(ex like emp id) from another file. not only passing value. but the file2 should be called from file1 with that parameter. until unless it
(file2) calls the file(file1) with parameter, pdf file will not be generated. like cflocation how it calls another cfpage with parameters. is there anyway. i cannot use cflocation bec it is redirecting.
let me know if i am clear to you or not.