cfcToPrinter(cfcType [, outputType])
Last updated August 30, 2005
Version: 1 | Requires: ColdFusion MX7 | Library: UtilityLib
Description:
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.
Example:
Parameters:
| 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 (jared@web-relevant.com)
@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 myCfc.name = arguments.cfcType>
<cfset myCfc.path = "/" & replace(myCfc.name,".","/","all") & ".cfc">
<!--- Trap CFCExplorer's output --->
<cfsavecontent variable="cfceData">
<cfoutput>#myExplorer.getcfcinhtml(myCfc.name,myCfc.path)#</cfoutput>
</cfsavecontent>
<!--- 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>
<cfcase value="flashpaper,pdf">
<!--- Return !! object !! (use cfcontent to set the right mime type!!) --->
<cfdocument fontembed="true" name="cfcDocument" format="#arguments.outputType#">
<cfoutput>#cfceData#</cfoutput>
</cfdocument>
<cfreturn cfcDocument />
</cfcase>
<cfdefaultcase>
<cfthrow message="Invalid data for argument outputType: #arguments.outputType#"
detail="Your choices for outputType are pdf, flashpaper, or html." />
</cfdefaultcase>
</cfswitch>
</cffunction>
Search CFLib.org
Latest Additions
Tayo Akinmade added
arrayTrim
10 day(s) ago
Will Belden added
longTime
16 day(s) ago
James Sleeman added
quickSort
26 day(s) ago
Ben Forta added
GetHostAddress
29 day(s) ago
Top Rated
EksporSQLData
Rated 5.0, 16 time(s)
backupDatabase
Rated 5.0, 13 time(s)
indentXml
Rated 5.0, 10 time(s)
generateSsccAsn
Rated 5.0, 4 time(s)