1 Reply Latest reply on Aug 17, 2008 5:08 AM by Dan Bracuk

    Populate and email custom PDF in one step?

    lizard626
      Hi everyone,

      I'm working on a job applicant tracking system, and I would like to add a button that allows the administrator to populate a PDF employment application template with basic applicant information, then email the populated PDF to the applicant.

      I already have a working button to populate the template and display it in a browser:

      <cfpdfform action="populate" source="Employment_Application_2007_write.pdf" overwrite="no" overwritedata="no">
      <cfpdfformparam name="position" value="Firefighter/Paramedic">
      <cfpdfformparam name="name" value="#FORM.LastName#, #FORM.FirstName#, #FORM.MiddleName#">
      <cfpdfformparam name="home address" value="#FORM.HomeAddressStreet#, #FORM.HomeAddressCity#, #FORM.HomeAddressState#, #FORM.HomeAddressZipcode#">
      <cfpdfformparam name="home phone" value="#FORM.HomePhone#">
      <cfpdfformparam name="alt phone" value="#FORM.MobilePhone#">
      <cfpdfformparam name="email address" value="#FORM.Email#">
      <cfpdfformparam name="cert type" value="#FORM.EMSLevel#">
      <cfpdfformparam name="lic ##" value="#FORM.CertNum#">
      <cfpdfformparam name="agency" value="#FORM.CertIssuingAgency#">
      <cfpdfformparam name="print name 1" value="#FORM.FirstName# #FORM.LastName#">
      <cfpdfformparam name="print name 2" value="#FORM.FirstName# #FORM.LastName#">
      <cfpdfformparam name="print name 3" value="#FORM.FirstName# #FORM.LastName#">
      <cfpdfformparam name="print name 4" value="#FORM.FirstName# #FORM.LastName#">
      </cfpdfform>

      What I can't figure out is how to create the custom PDF, email it, then delete it off the server without turning the process into a 3-stage "wizard".

      IE: Stage 1, create PDF with temporary filename, then click Next.
      Stage 2, verify temporary PDF file has been created, then email it as an attachment, then click Next.
      Stage 3, Click Finish to trigger deleting the temporary file.

      Is there an elegant way to do this all in one step? Maybe delay each step until the last one is verified completed? And/or keep the temporary PDF in RAM instead writing it to disk then deleting it?

      Thanks for all your help!

      -Ian in LA
        • 1. Re: Populate and email custom PDF in one step?
          Dan Bracuk Level 5
          I would use an html form myself. The user completes and submits it to an action page that:
          a. validates and processes the form input.
          b. uses cfdocument to create a pdf file
          c. uses cfmail to mail said file.
          d. uses cffile to delete said file.

          You have to create the file if you are going to send it as an attachment. The alternative would be to try to send something in pdf format as the email body, but that might not work so well on the email client.