coldfusioncoldfusion-10cfdocument

ColdFusion - CFDOCUMENT Title in URL


I am creating a PDF document using ColdFusion cfdocument tag. Works fine, however instead of showing the document name in browser Title - it shows the .cfc file that I call to create the PDF.

Here is how I'm calling it.

<cfdocument format="pdf" marginbottom=".5" margintop=".25" marginright=".5" marginleft=".5" saveAsName="#filename#.pdf">
     <cfdocumentitem type="footer">
          <p style="font-size:11px; text-align:right; font-style:italic;">Page #cfdocument.currentpagenumber# of #cfdocument.totalpagecount#</p>
     </cfdocumentitem>
     <html>
          <head><title>#filename#.pdf</title></head>
          <body><img src="file:///#application.tempFolder#\#thisFilename#" /></body>
     </html>
</cfdocument>

What the heck am I missing? Why does it still show the filename.cfc file that I'm calling in the browser title instead of the filename I give to the PDF???


Solution

  • Figured it out. Had to create the document using CFDOCUMENT, then add a "Title" attribute to it using the CFPDF tag. Then output it to the browser.

    <!--- Create the PDF --->
    <cfdocument format="pdf" marginbottom=".5" margintop=".25" marginright=".5" marginleft=".5" filename="#application.tempFolder#\#thisSaveAsFilename#" overwrite="yes">
        <cfdocumentitem type="footer">
            <p style="font-size:11px; text-align:right; font-style:italic;">Page #cfdocument.currentpagenumber# of #cfdocument.totalpagecount#</p>
        </cfdocumentitem>
        <html>
            <head><title>#thisSaveAsFilename#</title></head>
            <body><img src="file:///#application.tempFolder#\#thisFilename#" /></body>
        </html>
    </cfdocument>
    <!--- Use CFPDF to add attributes to it --->
    <cfset thisInfo = StructNew()>
    <cfset thisInfo.Title = "pdf title goes here...">
    <cfpdf action="setinfo" info="#thisInfo#" source="#application.tempFolder#\#thisSaveAsFilename#" />
    <!--- Send it to the browser --->
    <cfcontent file="#application.tempFolder#\#thisSaveAsFilename#" type="application/pdf" />A