– Common Function Library Project

cfcToPrinter(cfcType[, outputType])

Last updated August 30, 2005


Jared Rypka-Hauer

Version: 1 | Requires: CF7 | Library: UtilityLib

This UDF takes a fully-qualified CFC name (i.e. "CFIDE.componentutils.cfcexplorer") as the only required parameter and displays the results of cfcexplorer.cfc's getCfcAsHtml() function as HTML, FlashPaper, or PDF.

Return Values:
Returns either a string or binary data.


<cfcontent type="application/x-shockwave-flash" reset="yes" variable="#cfcToPrinter('CFIDE.componentutils.cfcexplorer')#" />


Name Description Required
cfcType The CFC type. Yes
outputType Can be html, flashpaper, or pdf. Defaults to flashpaper. No

Full UDF Source:

 Given the fully-qualified path of a CFC, it renders the cfcexplorer.getcfcashtml() output to html, flahspaper, or PDF for printing as reference.
 @param cfcType      The CFC type. (Required)
 @param outputType      Can be html, flashpaper, or pdf. Defaults to flashpaper. (Optional)
 @return Returns either a string or binary data. 
 @author Jared Rypka-Hauer ( 
 @version 1, August 30, 2005 
<cffunction name="cfcToPrinter" access="public" output="false"  returntype="any">
    <cfargument name="cfcType" type="string" required="true" />
    <cfargument name="outputType" type="string" required="false" default="flashPaper" />
    <cfset var myCfc = structNew()>
    <cfset var myExplorer =  createObject("component","CFIDE.componentutils.cfcexplorer")>
    <cfset var cfcDocument = "">
    <cfset var cfceData = "">

    <cfset = arguments.cfcType>
    <cfset myCfc.path = "/" & replace(,".","/","all") & ".cfc">

    <!--- Trap CFCExplorer's output --->
    <cfsavecontent  variable="cfceData">

    <!--- Clean up the HTML a bit... there's a lotta crap in that output  stream... --->
    <cfset cfceData = reReplace(cfceData,"\t*?\n","","all")>
    <cfset cfceData = reReplace(cfceData,"\s{2,}",chr(10),"all")>

    <!--- Switch up the output stream based on outputType argument --->
    <cfswitch expression="#arguments.outputType#">
        <cfcase value="html">
            <!--- Return tidied HTML for cfoutputting --->
            <cfreturn cfceData />
        <cfcase value="flashpaper,pdf">
            <!--- Return !! object !! (use cfcontent to set the right mime  type!!) --->
            <cfdocument fontembed="true" name="cfcDocument"  format="#arguments.outputType#">
            <cfreturn cfcDocument />
        <cfthrow message="Invalid data for argument outputType:  #arguments.outputType#"
            detail="Your choices for outputType are pdf, flashpaper, or html." />


Latest Additions

Raymond Camden added
November 04, 2017

Leigh added
May 11, 2016

Raymond Camden added
May 10, 2016

Kevin Cotton added
May 05, 2016

Raymond Camden added
April 25, 2016

Created by Raymond Camden / Design by Justin Johnson