Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!--- FontList: Some installed fonts may work in both PDF & Flash formats, but there's no guarantee.
- This script will test available fonts using CFDocument and generates a PDF or Flash document.
- Requirement: ColdFusion 8 or 9 --->
- <CFSET CFPassword = "xxxxxxxxx">
- <CFSET PhysicalDir = GetDirectoryFromPath(GetCurrentTemplatePath())>
- <CFSET WebDir = "/FontList">
- <!--- Get Font Lists --->
- <cfinvoke component="cfide.adminapi.administrator" method="login" adminPassword="#CFPassword#">
- <CFSET FontStruct = createObject("component", "cfide.adminapi.runtime").getFonts()>
- <CFSET SystemFonts = ListSort(StructKeyList(FontStruct.SystemFonts), "textnocase")>
- <CFSET UserFonts = ListSort(StructKeyList(FontStruct.Userfonts), "textnocase")>
- <cfsavecontent variable="DefaultSample"><CFOUTPUT><h1>Header</h1>
- <div style="font-size:9px !important;">This text is set to 9px and should be small.</div>
- The <u>quick</u> <b>brown</b> <i>fox</i> jumped over the lazy dog.
- </CFOUTPUT></cfsavecontent>
- <CFPARAM NAME="Attributes.Content" DEFAULT="#DefaultSample#">
- <CFPARAM NAME="Attributes.Fonts" DEFAULT="#ListFirst(userFonts)#">
- <CFIF NOT LEN(Attributes.Fonts)><CFSET Attributes.Fonts = ListFirst(userFonts)></CFIF>
- <CFIF NOT LEN(trim(Attributes.Content))><CFSET Attributes.Content = DefaultSample></CFIF>
- <CFOUTPUT>
- <form action="./fontlist.cfm" method="post">
- <table class="vTable2">
- <tr><td><b>Fonts:</b></td><td><b>Sample Text/HTML:</b></td><tr>
- <tr valign="top"><td><div style="height:300px; overflow-y:scroll;"><CFLOOP LIST="#userFonts#" INDEX="this">
- <div><label for="#Request.KeyString(This)#"><input id="#Request.KeyString(This)#" type="checkbox" name="Fonts" value="#This#"<CFIF ListFindnocase(Attributes.Fonts,this)> checked</CFIF>>#This#</label></div></CFLOOP>
- <b>SYSTEM FONTS</b><CFLOOP LIST="#SystemFonts#" INDEX="this"><CFIF NOT Listfindnocase(userFonts,this)>
- <div><label for="#Request.KeyString(This)#"><input id="#Request.KeyString(This)#" type="checkbox" name="Fonts" value="#This#"<CFIF ListFindnocase(Attributes.Fonts,this)> checked</CFIF>>#This#</label></div></CFIF></CFLOOP>
- </div>
- </td><td><textarea name="Content" rows=#ListLen(userFonts)# cols=50 style="height:300px;">#trim(Attributes.Content)#</textarea></td></tr>
- <tr><td colspan=2 class="center" style="background-color:##c0c0c0;"><input name="go" type="submit" value="Test Fonts - PDF"> <input name="go" type="submit" value="Test Fonts - Flash"></td></tr>
- </table>
- </form>
- </CFOUTPUT>
- <CFIF NOT ISDefined("Attributes.Go")><CFEXIT></CFIF>
- <cfsavecontent variable="TheHTML"><CFOUTPUT><CFLOOP LIST="#Attributes.Fonts#" INDEX="this">
- <fieldset style="padding-bottom:25px;"><legend style="background-color:##e0e0e0;"><span style="font-family:Arial !important;">#This# (#DateFormat(Now(),'m/d/yyyy')# #timeFormat(Now(),'h:mm tt')#)</span></legend>
- <div style="font-family:#this# !important;">
- #Attributes.Content#</div>
- </fieldset></CFLOOP>
- </CFOUTPUT></CFSAVECONTENT>
- <CFIF Findnocase("Flash",Attributes.Go)>
- <cfdocument filename="#PhysicalDir#FontList.swf" format="flashpaper" pagetype="letter" margintop="0.1" marginbottom="0.1" marginright="0.1" marginleft="0.1" orientation="portrait" unit="in" encryption="none" fontembed="Yes" backgroundvisible="Yes" overwrite="yes"><CFOUTPUT>#TheHTML#</CFOUTPUT></cfdocument>
- <CFSET SWFWebPath = "#WebDir#/FontList.swf?a=#GetTickCount()#">
- <CFOUTPUT><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="https://active.macromedia.com/flash2/cabs/swflash.cab##version=4,0,2,0" id="test" name="test" width="800" height="400">
- <param name="movie" value="#SWFWebPath#">
- <param name="quality" value="high">
- <param name="bgcolor" value="##FFFFFF">
- <embed wmode="opaque" src="#SWFWebPath#" quality="high" bgcolor="##FFFFFF" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" width="800" height="400">
- </object></CFOUTPUT>
- <CFELSE>
- <cfheader name="content-disposition" value="attachment; filename=FontTest.pdf">
- <cfdocument format="pdf" pagetype="letter" margintop="0.1" marginbottom="0.1" marginright="0.1" marginleft="0.1" orientation="portrait" unit="in" encryption="none" fontembed="Yes" backgroundvisible="Yes" overwrite="yes"><CFOUTPUT>#TheHTML#</CFOUTPUT></cfdocument>
- </CFIF>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement