CFajaxproxy and sending content in CallbackHandler as PDF - it it possible?
Posted on 2009-02-21
Is it possible to do the following (CF8, ajax and cfdocument as PDF)? And if possible, any how to suggestions are appreciated!
The web user clicks on a link which fires a cfajax http post to a cfc. The cfc creates a pdf document using cfdocument. I have a working model for this. Using cfdebug and the CF Ajax Logger window, I can see the content being sent back is a PDF ("info:http: CFC invocation response: %PDF-1.4").
In the past I have used a cfc to create the PDF as a physical file in a temp location and sent the HTML link to a div on the template. The end user then clicks the link to download the file.
What I would like to do INSTEAD is push the pdf content back to the user, and have an alert to "open or save the file". In the cfc I have the cfdocument creation of the pdf (which, as noted, works) and then:
<!--- Make the generated pdf open as a separate file (not a cfm file) --->
<cfheader name="Content-Disposition" value="attachment;filename=#variables.filename#">
<!--- generate the pdf and send to the subscriber --->
<cfcontent type="application/pdf" reset="true" variable="#toBinary(thispdf)#" />
var instance = new pdfconn();
//populate cfwindow? push the pdf to the user
Is this doable?