Ask a Jedi: Issue with cfdocument and name

Eugene asks:

Hi, I am learning from you article and havea a requirement to create and email/print PDF file out of an online html report. I am trying the code bellow, but it doesn't work. What am I doing wrong? Would you let me know, please, how to make it work?

Let’s take a look at his code:

<cfdocument format="PDF" name="c:\temp\myReport"> <html> ... my html report is here ... </html> </cfdocument>

<cfpdf action=”write” source=”c:\temp\myReport” destination=”c:\temp\myPDF.pdf”> </code>

I hate to say RTFM, but this is a perfect case where it would have helped. The docs for CFDOCUMENT state that the name attribute allows you to specify a variable to store the PDF created. It isn’t a filename, but rather a variable name. If you run the code, the error makes mention of it: The string c:\temp\myReport is not a valid ColdFusion variable name.

The solution is simple - switch to filename.

Raymond Camden's Picture

About Raymond Camden

Raymond is a developer advocate. He focuses on JavaScript, serverless and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA https://www.raymondcamden.com

Comments