2 Replies Latest reply on Dec 9, 2006 11:58 AM by BKBK

    CFDOCUMENT with HTTP.REFERER

    Level 7
      I want to create a "print this page" link on every page of my site,
      and was thinking I could link them all to a single page
      that simply includes the referring page...

      But this doesnt seem to work

      <cfdocument format="pdf">
      <cfinclude template="#CGI.HTTP_REFERER#">
      </cfdocument>

      Any ideas?

      --

      Michael Evangelista
      Evangelista Design
      www.mredesign.com
      --




        • 1. Re: CFDOCUMENT with HTTP.REFERER
          jdeline Level 1
          There are several ways to do this. Here's one.
          • 2. CFDOCUMENT with HTTP.REFERER
            BKBK Adobe Community Professional & MVP
            If you wish to print every page as-is, that is, usually HTML, then follow Jdeline's suggestion. If, however, you want to first convert pages to PDF and then print them using the print facility in PDF, then there are some points to bear in mind.

            1) By default, cgi.http_referer is an empty string. It assumes a value only when we arrive at a page via a link. However, cfinclude's template attribute may not be empty, so Coldfusion will throw an error when you run a page containing the code <cfinclude template="#CGI.HTTP_REFERER#">.

            2) CGI.HTTP_REFERER, when it exists, is usually an absolute URL. Whereas, the value of the template-attribute must be a relative path or mapping.

            Points 1) and 2) suggest the following improvement:

            <cfif Len(trim(CGI.HTTP_REFERER)) GT 0>
            <cfdocument format="pdf">
            <cfinclude template="#GetFileFromPath(CGI.HTTP_REFERER)#">
            </cfdocument>
            </cfif>


            arbitraryPage.cfm
            ===============
            <p>This is a document rendered by the cfdocument tag.</p>
            <table width="50%" border="2" cellspacing="2" cellpadding="2">
            <tr>
            <td><strong>Name</strong></td>
            <td><strong>Role</strong></td>
            </tr>
            <tr>
            <td>Bill</td>
            <td>Lead</td>
            </tr>
            <tr>
            <td>Susan</td>
            <td>Principal Writer</td>
            </tr>
            <tr>
            <td>Adelaide</td>
            <td>Part Time Senior Writer</td>
            </tr>
            <tr>
            <td>Thomas</td>
            <td>Full Time for 6 months</td>
            </tr>
            <tr>
            <td>Michael</td>
            <td>Full Time for 4 months</td>
            </tr>
            </table>

            <br>

            <!--- Ensure that link does not appear on printed page --->
            <cfif getFileFromPath(CGI.SCRIPT_NAME) is not "PDFPrintPage.cfm">
            <p><a href="PDFPrintPage.cfm">Print current page</a> </p>
            </cfif>


            PDFPrintPage.cfm
            ================
            <cfif Len(trim(CGI.HTTP_REFERER)) GT 0>
            <cfdocument format="pdf">
            <cfinclude template="#GetFileFromPath(CGI.HTTP_REFERER)#">
            </cfdocument>
            </cfif>