Skip to main content
Participant
February 17, 2019
Answered

Using form output to create .pdf, send .pfd as email attachment, or write form output to disk in html/cfm format

  • February 17, 2019
  • 2 replies
  • 879 views

Hi, here's my problem. My web server uses CF MX 7. I want to get form output, create a .pdf from it, and send the .pdf as an email attachment. This seems to be easy using CF MX 8 and beyond: use cfdocument to create a .pdf and attach the .pdf to an email usig cfmailparam, without writing to disk first. This cannot be done in CF MX 7.

So, to accomplish what I want in CF MX 7, I need a way of doing the following:

1) Output form data to the browser. (Done)

2) Save the format to disk *in the format in which it is outputted to the browser*. (CFFILE does not help in this regard)

3) Convert the file on disk to .pdf format. (I assume CFdocument will do this.)

4) Send the .pdf file as an attachment to an email.

Is this possible? If so, how can it be achieved? Thanks very much.

Best wishes

Chris

    This topic has been closed for replies.
    Correct answer BKBK

    What about something along the lines of:

    <!--- Here, generateFormOutput.cfm is the page that generates the form output --->

    <cfdocument format="PDF" src="http://127.0.0.1:8500/workspace/CF_Project/generateFormOutput.cfm" filename="#expandPath('myDocument.pdf')#" overwrite="true" />

    <cfmail from = "BKBK@localhost" To = "BKBK@localhost" Subject = "Test - Reply including PDF Attachment" username="BKBK@localhost" password="X1y2Z3">

        <cfmailparam file ="#expandPath('myDocument.pdf')#" type="application/pdf">

        Reply, bla bla bla

    </cfmail>

    2 replies

    Charlie Arehart
    Community Expert
    Community Expert
    February 17, 2019

    Check out webkit, which Adobe leveraged under the covers in cf11 as a new alternative to cfdocument (a new tag called cfhtmltopdf). If you Google about, you'll find you can implement the webkit engine yourself and call it from cfml--as people have also called it from php,. Net, etcI can offer more than that general pointer, though. /CharlieSent via the Samsung Galaxy S7 active, an AT&T 4G LTE smartphone

    /Charlie (troubleshooter, carehart. org)
    BKBK
    Community Expert
    BKBKCommunity ExpertCorrect answer
    Community Expert
    February 17, 2019

    What about something along the lines of:

    <!--- Here, generateFormOutput.cfm is the page that generates the form output --->

    <cfdocument format="PDF" src="http://127.0.0.1:8500/workspace/CF_Project/generateFormOutput.cfm" filename="#expandPath('myDocument.pdf')#" overwrite="true" />

    <cfmail from = "BKBK@localhost" To = "BKBK@localhost" Subject = "Test - Reply including PDF Attachment" username="BKBK@localhost" password="X1y2Z3">

        <cfmailparam file ="#expandPath('myDocument.pdf')#" type="application/pdf">

        Reply, bla bla bla

    </cfmail>