Sam Farmer

Growing up I never imagined I would play bass guitar for the Dave Matthews Band. And indeed it never happened.

But I have become passionate about making software.

Ten ColdFusion 9 One-Liners

July 23, 2009

All great performers have repertoire of one-liners. ColdFusion is no different and here are some cool new ColdFusion 9 one-liners:

1. Take a Word document and convert it to PDF
<cfdocument format="pdf" srcfile="/mydoc.docx" filename="mydoc.pdf" />

2. Take a PDF and optimize it (remove extra images, bookmarks, etc that are not needed)
<cfpdf action="optimize" source="bigpdf.pdf" algo="Bicubic" destination="smallpdf.pdf">

3. Get an object/record of an artist based on the key
<cfset artist = entityLoad('artists',1,true)>

(Change it <cfset artist.setLastName('McCoy')>)

4. Save the object back to the database
<cfset entitySave(artist)>

5. Add a map to a page
<cfmap centeraddress="275 Grove Street Newton, MA 02466" zoomlevel="8" type="hybrid" />


6. Connect to an imap server
<cfimap action="open" server="" username="" secure="yes" port="993" password="" connection="gmail">

7. Add a message box
<cfmessagebox type="prompt" name="mes" message="Enter Message" labelok="Send" multiline="true" width="400" />

8. Add a media player to a Flash video file
<cfmediaplayer source="/phone.flv" >

9. Put a query into a spreadsheet
<cfspreadsheet action="write" filename="test.xls" query="getArtists">

10. Create a multiple file upload UI
<cffileupload url="multiUploadProcess.cfm">

Ah, what the heck, here's a bonus one:

11. Process those files and save to the file system
<cffile action="uploadall" destination="#getTempDirectory()#">

Pretty cool stuff. All of these new features have a lot of other attributes and possibilities for customization.

There are even a few (creating a progress bar, converting a PowerPoint presentation) that I left off.

No Comments

Some comments have been lost over the years due to moving hosts.


More blog entries that I have written.

Code coloring by PRISM.