Skip to main content
January 30, 2012
Question

CFHeader/CFContent is halting the rest of my page

  • January 30, 2012
  • 3 replies
  • 4050 views

I am posting to another page form information, and then spitting out a generated document.

<cfheader name="content-disposition" value="filename=#rejectSearchResults.RejectTempPath#">

<cfcontent type="application/msword"><cfoutput>#documentGen#</cfoutput>

This code right here pops open my RTF document to the user, but instead of going to the posted page it instead stays on the same page and halts further processing. How do I make the document open up and continue processing the rest of the code?

    This topic has been closed for replies.

    3 replies

    Participating Frequently
    March 24, 2014

    I want to create a Word doc so I am using cfcontent to create a word doc that I archive. I've left the default not to delete, but as cold_blue has explained above, CF server sends the doc to the requesting browser and no further code runs. Instead of sending the document back to the user I need to hash the saved document, enter that information into my database for later secure retrieval, and then send other html back to the requesting browser instead of the document that cfcontent rendered. I can do this operation with cfdocument format="pdf" and it works just fine: user submits to accept/commit the doc, CF server generates and stores the pdf, gets a hash of it, enters that and other info into my table_documents, returns to the requesting browser a link to the pdf and other updated html. I have not found any such analogous functionality with cfcontent.

    January 31, 2012

    Well, the stored procedure shoots out the paths to additional documents, which I want to supplement with my generated document. So all of this is coming from the same script/cfm file. Those additional files can't be displayed for download since cfheader/cfcontent wont allow that. I really don't know how I can use an iframe to circumvent this since the stored procedure that generates the document and additional paths to files for download has to be grouped togethor in the same script.

    Inspiring
    January 31, 2012

    shoots out the paths to additional documents ... my generated document

    Is there a reason you must do both in the same procedure? Because it sounds like it might be trying to do too much at once.

    If you really cannot separate them, one possibility is to write the main content to a temporary file which could be accessed from either location. Then display it with cfcontent's "file" attribute.

    Inspiring
    January 30, 2012

    cfthread might help, but what you are describing is very strange.  What exactly is supposed to happen once the user is presented with the document?

    January 30, 2012

    Well, what is happening is I have a page, index.cfm, that is basically a big form that users enter in information. Then I set the action page of that form to another .cfm file that is running stored procedures, and I'm using those queries plus the form paramaters to do a find/replace inside a RTF Word document.

    The thing is, as soon as they click the submit button, the generated document pops up right away (the browser never sends the user to the action page). I want the user to be able to go to the action page, where I have a table with additional documents to download.

    <table align="center">

       <h4>Document Created</h5>

       <cfoutput>

        <p>

         Document Downloads: [<a href="#pathToCover#">Cover Template</a>]

         [<a href="#pathToRedetermination#">Redetermination Template</a>] <br />

         Please click <a href="./index.cfm">here</a> to return to DocGen.

        </p>

       </cfoutput>

      

       <cfheader name="content-disposition" value="filename=#rejectSearchResults.RejectTempPath#">

       <cfcontent type="application/msword"><cfoutput>#documentGen#</cfoutput>

      </table>

    As you can see, on the page that is receiving the form paramaters, I have a table with the cfheader/cfcontent tags below. Above that is my Replace() commands, stored procedure, conitionals, etc. The user never even sees any of the HTML (they never even leave the form once they click submit, the generated document just pops up right away).

    Inspiring
    January 31, 2012

    That's how cfcontent works.  Maybe an iframe will give you what you want.