Cfdocument – different behavior in CF7 vs CF8

Written on 26 October 2011, 02:26pm

Tagged with: , ,

The simple code below should write a PDF file on disk. This file should contain an image and two lines of text – next to the image (ignore the use of tables for layout 😛 ):

<cfsetting enablecfoutputonly="yes" showdebugoutput="no">

<cfdocument filename="output#Left(server.ColdFusion.ProductVersion,1)#.pdf" 
		format="pdf" overwrite="yes">
	<cfdocumentsection marginleft="1">
                <td><img src='../images/image.gif'></td>
                <td>This is a simple text<br>spanning on two lines.</td>

The result is quite different in ColdFusion 7 vs ColdFusion 8, as the following image shows:

In CF8, the PDF text and image appear visible smaller than in CF7.
Now the strange part: if I add unit attribute to cfdocument tag (with any value, ‘cm’ or ‘in’) – the CF8 version shows exactly the same size as CF7.

Anyone has any idea why this happens?

Cfexecute tag: a few useful notes

Written on 20 October 2011, 04:50pm

Tagged with: ,

Some quick notes about cfexecute tag:

  1. It is async.
  2. You cannot put other ColdFusion tags or functions between the start and end tags of cfexecute.
  3. You cannot nest cfexecute tags.
  4. In CF8 or less, only stdout output is captured, not stderr. If you need to capture the error, redirect stderr to stdout using 2>&1 – as described here.
  5. In CF9, you can use errorVariable and errorFile attributes to store (into a variable or file respectively) the result of an error. [#]
  6. To capture the output, use variable or outputFile attributes. If no outputFile or variable attribute is specified, output is displayed on page from which it was called.

How to read ColdFusion log files directly from your app

Written on 16 October 2011, 01:41am

Tagged with: ,

CFLOG is a very useful tool for debugging. Along with CFDUMP, it is probably one most used tags in development 🙂
Logging with CFLOG is extremely simple:

<cflog file="myLogFile" text="#TimeFormat(Now(),'hh:mm:ss.l')#: log message" />

I am usually prepending the timestamp to get the milliseconds (by default, CF only logs the time down to the seconds):

"Information","web-261","10/13/11","06:03:21","APP","06:03:21.319: log message"

About the other attribute of the CFLOG: file, the CF documentation says:

Message file. Specify only the main part of the filename. For example, to log to the Testing.log file, specify “Testing”.
The file must be located in the default log directory. You cannot specify a directory path. If the file does not exist, it is created automatically, with the extension .log.

The log file is created inside the ColdFusion default log directory. You can see the content of this file using the ‘Log files’ screen of your CF Admin interface:

But what do you do when you don’t have access to the CF Admin interface? Luckily, you can still see the contents of your log file. You just have to locate the log folder contents and then output the log file contens, as the following script shows: