Skip to content

Instantly share code, notes, and snippets.

@learncfinaweek
learncfinaweek / gist:4121349
Created November 20, 2012 21:37
Document Handling - Hands On 25
@learncfinaweek
learncfinaweek / gist:4121345
Created November 20, 2012 21:37
Document Handling - Hands On 24
@learncfinaweek
learncfinaweek / gist:4121341
Created November 20, 2012 21:36
Document Handling - Hands On 23

In this hands on example, you are going to make a call to Twitter to get a list of your latest tweets and output them to the contact page.

Tags Used: <cfhttp>, <cfloop>, <cfoutput>

Functions Used: dateFormat

@learncfinaweek
learncfinaweek / gist:4121338
Created November 20, 2012 21:35
Document Handling - Spreadsheets

When creating a website that generates reports, having the ability to generate Excel spreadsheets is a great feature to offer users. Allowing people to provide an Excel file of data rather than forcing them to manually enter everything into your system is also a great feature for users. ColdFusion allows for both the creation and reading of spreadsheets.

ColdFusion offers the ability to use tags and functions to manipulate spreadsheets. The cfspreadsheet tag is best used when reading in a spreadsheet; the spreadsheet functions are best used when manipulating the spreadsheet. There is the SpreadsheetRead function available to you, but it does not return the data contained in the spreadsheet. For this section, we will use the cfspreadsheet tag to read in data, but will use the spreadsheet functions for creation and manipulation.

Reading a Spreadsheet

@learncfinaweek
learncfinaweek / gist:4121334
Created November 20, 2012 21:35
Document Handling - Image Manipulation

A great feature set of ColdFusion is its image functionality. ColdFusion has the ability to easily manipulate images, create new images, draw images, and write them back to the file system. All this functionality comes right out of the box with ColdFusion without need of any extra plugins or installs.

There are so many pieces of image related functionality that it is not feasible to explain all of them in this section. For the purpose of this section, we will review a few of the more common functions used. To see a full list of image functionality available, go to: http://help.adobe.com/en_US/ColdFusion/10.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec1a60c-7ffc.html#WSc3ff6d0ea77859461172e0811cbec22c24-66e4.

Reading in an Image

@learncfinaweek
learncfinaweek / gist:4121330
Created November 20, 2012 21:34
Document Handling - File Manipulation

A common request when building a website is the ability to upload and manipulate files. ColdFusion offers a number of tags and functionality that allow you to control the files on the file system . The functionality offered ranges from the more simple process of creating a new file all the way up to manipulating a files meta data.

Let's take a look at the functionality in the order that you will probably use it.

Uploading Files

@learncfinaweek
learncfinaweek / gist:4121327
Created November 20, 2012 21:34
Document Handling - cfpdfform

cfpdfform is one of the most powerful yet overlooked features of ColdFusion. Until now you have been working with "flat" PDF files. cfpdfform is useful when you have to generate forms that combine boilerplate text and dynamic text; it can also be used to collect data. There are two options in creating the initial PDF form: Adobe Acrobat and Adobe LiveCycle Designer. For the purpose of Learn ColdFusion in a Week, we will only be covering PDF's created using Adobe Acrobat.

Read a PDF Form

The source of the PDF can be a path to a PDF file or a variable that holds the byte array of the PDF. You can store the results of this read in a variable.

@learncfinaweek
learncfinaweek / gist:4121322
Created November 20, 2012 21:33
Document Handling - cfpdf

Whereas cfdocument is used to create PDFs, the cfpdf tag is used to manipulate existing PDFs. With cfpdf, you can read an existing PDF, write meta-data to it, merge PDFs together, delete pages, create thumbnails of the pages, extract text & images, add or remove watermarks, manipulate headers & footers, create PDF portfolios, and deal with PDF passwords, permissions and Encryption.

Reading a PDF

@learncfinaweek
learncfinaweek / gist:4121316
Created November 20, 2012 21:32
Document Handling - cfdocument

cfdocument will take your combination of CFML and HTML and convert it to a PDF. At its simplest, you can stick some text between the opening and closing tags of cfdocument (there is currently no built-in cfdocument script equivalent) and it will render a PDF to the screen. Here is some sample code:

Creating a Simple PDF

<cfdocument format="PDF">
@learncfinaweek
learncfinaweek / gist:4121308
Created November 20, 2012 21:31
Document Handling - cfhttp

cfhttp makes HTTP calls from your ColdFusion server to an internet address of your choice. It is important to remember that it is the ColdFusion server that will be calling the URL, not the browser that is calling your ColdFusion page. Think of cfhttp as if you have proxy browser on your server that can send and receive information to any address on the internet. Imagine that this "virtual browser" on the server can save the information that it receives to a variable, so that it can be manipulated or passed to the user who has called your ColdFusion page.

Making a HTTP call

There are many attributes that the cfhttp tag can take. The simplest cfhttp call can be done like this: