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>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???

1 Answer

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>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

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like