In this hands on, you are going to create an image file upload. Once the image is uploaded, you are going to resize it to fit specific measurements.
Tags Used: <cffile>, <cfif>, <cfset>
Functions Used: listFindNoCase, getReadableImageFormats,
In this hands on, you are going to create an image file upload. Once the image is uploaded, you are going to resize it to fit specific measurements.
Tags Used: <cffile>, <cfif>, <cfset>
Functions Used: listFindNoCase, getReadableImageFormats,
In this next hands on, you are going to add functionality that will allow you to export a blog post in PDF format. We will also add a watermark to the PDF.
Tags Used: <cfparam>, <cfset>, <cfif>, <cfdocument>, <cfdocumentitem>,
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
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.
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.
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.
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.
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.
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.
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:
<cfdocument format="PDF">
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.
There are many attributes that the cfhttp tag can take. The simplest cfhttp call can be done like this: