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

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

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?

HTML5 geolocation demo

Written on 20 October 2011, 05:39pm

Tagged with: ,

1. Test if the browser supports navigation:

if (navigator.geolocation) {  
  /* geolocation available */  
} else {  
  /* geolocation not supported by this browser */  
} 
//---or use Modernizr
 if (Modernizr.geolocation) {
...
//---or be geek
if(!!navigator.geolocation){
...

2. Getting the current position: navigator.geolocation.getCurrentPosition()

The getCurrentPosition() method initiates an asynchronous request to detect the user’s position, and queries the positioning hardware to get up-to-date information. When the position is determined, a specified callback routine is executed. You can optionally provide a second callback to be executed if an error occurs. A third, optional, parameter is an options interface where you can set the maximum age of the position returned and the time to wait for a request. [#]

navigator.geolocation.getCurrentPosition( 
		geo_success, 
		geo_error, 
		{enableHighAccuracy:true, timeout:30000, maximumAge:60000 }
	);

3. Geolocation success callback function

The success callback function will be called with a single parameter, an object with two properties: coords and timestamp.
(more…)

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.