<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Kalen Gibbons &#187; Coldfusion</title>
	<atom:link href="http://www.kalengibbons.com/blog/index.php/category/coldfusion/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.kalengibbons.com/blog</link>
	<description>The Dead Tree Blog</description>
	<lastBuildDate>Wed, 10 Mar 2010 07:28:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Presenting @ the IECFUG on Thursday</title>
		<link>http://www.kalengibbons.com/blog/index.php/2009/07/presenting-the-iecfug-on-thursday/</link>
		<comments>http://www.kalengibbons.com/blog/index.php/2009/07/presenting-the-iecfug-on-thursday/#comments</comments>
		<pubDate>Wed, 08 Jul 2009 04:34:41 +0000</pubDate>
		<dc:creator>Kalen Gibbons</dc:creator>
				<category><![CDATA[Coldfusion]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Miscellaneous]]></category>
		<category><![CDATA[IECFUG]]></category>

		<guid isPermaLink="false">http://www.kalengibbons.com/blog/?p=341</guid>
		<description><![CDATA[I&#8217;ll be presenting at the IECFUG this Thursday the 9th. The session will be a hands-on tutorial on connecting ColdFusion and Flex. It should be a good time, so come on down if you&#8217;re in the area. I&#8217;ll post the sample files here sometime after the meeting. It&#8217;s a little late, but here are the [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ll be presenting at the <a href="http://iecfug.com/">IECFUG</a> this Thursday the 9th.  The session will be a hands-on tutorial on connecting ColdFusion and Flex. It should be a good time, so come on down if you&#8217;re in the area.</p>
<p><del datetime="2009-10-09T19:47:39+00:00">I&#8217;ll post the sample files here sometime after the meeting.</del><br />
It&#8217;s a little late, but here are the links to the files and the presentation, enjoy <img src='http://www.kalengibbons.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /><br />
<a href="/assets/files/CF2FX.zip">Presentation Files</a><br />
<a href="http://experts.na3.acrobat.com/p45336977">Presentation on Adobe Connect</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.kalengibbons.com/blog/index.php/2009/07/presenting-the-iecfug-on-thursday/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Custom Printing with Flex, Part 3: Printing Data</title>
		<link>http://www.kalengibbons.com/blog/index.php/2009/04/custom-printing-with-flex-part-3-printing-data/</link>
		<comments>http://www.kalengibbons.com/blog/index.php/2009/04/custom-printing-with-flex-part-3-printing-data/#comments</comments>
		<pubDate>Thu, 02 Apr 2009 06:19:52 +0000</pubDate>
		<dc:creator>Kalen Gibbons</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Coldfusion]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[How-To]]></category>
		<category><![CDATA[AlivePDF]]></category>
		<category><![CDATA[Custom Printing with Flex]]></category>
		<category><![CDATA[series]]></category>

		<guid isPermaLink="false">http://www.kalengibbons.com/blog/?p=254</guid>
		<description><![CDATA[In the first article of this series, I discussed how to prevent users from printing directly from Flash&#8217;s default context menu. In the second article, I wrote about using the AlivePDF library to create PDFs from your application for printing or saving. Today I will be covering how to print application data from Flex. The [...]]]></description>
			<content:encoded><![CDATA[<p>In the <a href="http://www.kalengibbons.com/blog/index.php/2009/02/custom-printing-with-flex-part-1-overriding-flashs-built-in-printing/">first article</a> of this series, I discussed how to prevent users from printing directly from Flash&#8217;s default context menu.  In the <a href="http://www.kalengibbons.com/blog/index.php/2009/03/custom-printing-with-flex-part-2-generating-pdfs-with-alivepdf/">second article</a>, I wrote about using the <a href="http://alivepdf.org/" target="_blank">AlivePDF</a> library to create PDFs from your application for printing or saving. Today I will be covering how to print application data from Flex.</p>
<p>The Flex framework comes with several classes to assist you in printing; however, they don&#8217;t tend to produce the greatest results.  The <a href="http://livedocs.adobe.com/flex/3/langref/mx/printing/PrintDataGrid.html" target="_blank">PrintDataGrid</a> class is probably your best option when it comes to printing data, but whenever I&#8217;ve worked with it in the past I&#8217;ve always ended up disappointed.  Even after formatting, there are always issues; like rows getting cut off and pages breaks in weird places.</p>
<p>There have been talks about AlivePDF offering a Grid class to the library, which may be interesting, but it hasn&#8217;t been released and would probably only handle DataGrid data. So the best option I&#8217;ve found for printing data is to allow a server to generate a PDF, which can then be sent back to Flex and output however you want.</p>
<p>A great benefit of this option is the ability to easily format the print results.  You can use simple HTML and CSS to customize the printout much easier than you could using ActionScript.  You can also add custom styles, letterheads, and footers to fit your needs.</p>
<p>Here is an example, you can <a target="_blank" href="/assets/pages/srcview/PrintDataExample/index.html">view the source here</a>.<br />

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_PrintDataExample_1257206359"
			class="flashmovie"
			width="750"
			height="500">
	<param name="movie" value="/assets/flash/PrintDataExample.swf" />
	<param name="bgcolor" value="#000000" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/assets/flash/PrintDataExample.swf"
			name="fm_PrintDataExample_1257206359"
			width="750"
			height="500">
		<param name="bgcolor" value="#000000" />
	<!--<![endif]-->
		
<p><a href="http://adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>This will work with any server-side script that can generate PDF content.  In this demo I am using a ColdFusion script which simply generates an HTML table and returns it in PDF format.  You can view the ColdFusion code along with the rest of the source code <a target="_blank" href="/assets/pages/srcview/PrintDataExample/index.html">here</a>.</p>
<p>The data from the server is returned to Flex as a ByteArray.  You can take that ByteArray and output it to the user in several different ways:</p>
<h3>Using the Browser</h3>
<p>Similar to the last article in this series, you can send the results to a server-side script to either display the PDF in the browser or prompt the user to open or save the document. This time, however, the AlivePDF library is no longer necessary since the PDF binary has already been created.</p>
<div class="code">
<span class="asReserved">private</span> <span class="asFunction">function</span> generatePDF(pdfBinary:ByteArray, method:String):<span class="asReserved">void</span>{</p>
<div class="indent">
		<span class="asComment">//result comes back as binary, create a new URL request and pass it back to the server</span><br />
        <span class="asVar">var</span> header:URLRequestHeader = <span class="asReserved">new</span> URLRequestHeader(&quot;<span class="asString">Content-type</span>&quot;, &quot;<span class="asString">application/octet-stream</span>&quot;);<br />
        <span class="asVar">var</span> urlString:String = &quot;<span class="asString">http://kalengibbons.com/assets/pages/pdfCreator.cfm</span>&quot;;<br />
        <span class="asReserved">if</span>(method == &quot;<span class="asString">inline</span>&quot;)</p>
<div class="indent">
        urlString += &quot;<span class="asString">?method=inline</span>&quot;;		</div>
<p>        <span class="asReserved">else</span></p>
<div class="indent">
        urlString += &quot;<span class="asString">?method=attachment&amp;name=dataPrintSample.pdf</span>&quot;;		</div>
<p>        <span class="asVar">var</span> sendRequest:URLRequest = <span class="asReserved">new</span> URLRequest(urlString);<br />
        sendRequest.requestHeaders.push(header);<br />
        sendRequest.method = URLRequestMethod.POST;<br />
        sendRequest.data = pdfBinary;<br />
        navigateToURL(sendRequest, &quot;<span class="asString">_blank</span>&quot;);		</div>
<p>        }
</p></div>
<h3>Save locally from Flash</h3>
<p>Thanks to new capabilities in <a href="http://www.adobe.com/products/flashplayer/features/" target="_blank">Flash Player 10</a>, you can also provide users the option to save the PDF directly from Flash.  This eliminates the need for the second server-side script.</p>
<div class="code">
<span class="asReserved">private</span> <span class="asFunction">function</span> savePDF(pdfBinary:ByteArray):<span class="asReserved">void</span>{</p>
<div class="indent">
		<span class="asVar">var</span> fileRef:FileReference = <span class="asReserved">new</span> FileReference();<br />
        fileRef.save(pdfBinary, &quot;<span class="asString">yourPrintout.pdf</span>&quot;);		</div>
<p>        }
</p></div>
<p>If you plan to use the save functionality you&#8217;ll need to set the &#8220;Required Flash Player version&#8221; in your project preferences to 10.0.0 or higher or else Flex Builder will complain.  You have to remember that only users with Flash Player 10 or above will be able to use this functionality, so some type of version validation is a necessity.</p>
<p>Another caveat is that the save method must be triggered by some type of <a href="http://kb.adobe.com/selfservice/viewContent.do?externalId=kb405546" target="_blank">user interaction</a>, that&#8217;s why the sample application prompts for system access before saving.  Although the user has clicked the &#8220;Print Data&#8221; button, that event is lost when the server call is made, so we need another interaction from the user.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kalengibbons.com/blog/index.php/2009/04/custom-printing-with-flex-part-3-printing-data/feed/</wfw:commentRss>
		<slash:comments>38</slash:comments>
		</item>
		<item>
		<title>Custom Printing with Flex, Part 2: Generating PDFs with AlivePDF</title>
		<link>http://www.kalengibbons.com/blog/index.php/2009/03/custom-printing-with-flex-part-2-generating-pdfs-with-alivepdf/</link>
		<comments>http://www.kalengibbons.com/blog/index.php/2009/03/custom-printing-with-flex-part-2-generating-pdfs-with-alivepdf/#comments</comments>
		<pubDate>Sun, 01 Mar 2009 08:10:27 +0000</pubDate>
		<dc:creator>Kalen Gibbons</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Coldfusion]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[How-To]]></category>
		<category><![CDATA[AlivePDF]]></category>
		<category><![CDATA[Custom Printing with Flex]]></category>
		<category><![CDATA[series]]></category>

		<guid isPermaLink="false">http://www.kalengibbons.com/blog/?p=191</guid>
		<description><![CDATA[In the first article of this series, Overriding Flash’s Built-In Print Option, I discussed how to prevent users from printing directly from Flash, by replacing the default context menu. I demonstrated how poorly Flash handles printing directly, and now we will start discussing what alternatives are available to developers. In this article I will demonstrate [...]]]></description>
			<content:encoded><![CDATA[<p>In the first article of this series, <a href="http://www.kalengibbons.com/blog/index.php/2009/02/custom-printing-with-flex-part-1-overriding-flashs-built-in-printing/">Overriding Flash’s Built-In Print Option</a>, I discussed how to prevent users from printing directly from Flash, by replacing the default context menu.  I demonstrated how poorly Flash handles printing directly, and now we will start discussing what alternatives are available to developers.</p>
<p>In this article I will demonstrate how to print and save any part of your application by utilizing the <a href="http://www.alivepdf.org/" target="_blank">AlivePDF library</a>.  AlivePDF is  an ActionScript 3 open-source PDF library that easily creates PDF documents from your Flex application.  The library is pretty robust and offers much more functionality than I will be able to cover here.  In this article I want to demonstrate how simple it is to dynamically generate PDF documents using ActionScript and AlivePDF.</p>
<p>To give you a better understanding of what can be done with AlivePDF, let&#8217;s revisit one of the printing examples that was used in <a href="http://www.kalengibbons.com/blog/index.php/2009/02/custom-printing-with-flex-part-1-overriding-flashs-built-in-printing/">part 1</a> of the series.  The two images below are printouts of the The <a href="http://examples.adobe.com/flex2/inproduct/sdk/flexstore/flexstore.html" target="_blank">Flex Store</a> &#8211; one printed with Flash&#8217;s default print option and the other with AlivePDF.</p>
<table>
<tr>
<td>
<strong>Flex Store printed using Flash&#8217;s default print option</strong><br />
<img src="/assets/images/flexStore_printout.jpg" alt="Flex Store Printed from Flash" />
</td>
<td>
<strong>Flex Store printed using AlivePDF</strong><br />
<img src="/assets/images/flexStore_alivePDF.jpg" alt="Flex Store PDF created with AlivePDF" />
</td>
</tr>
</table>
<p>In addition, here is a sample application for you to play with some of AlivePDF&#8217;s options.  You can <a href="/assets/pages/srcview/AlivePDFExample/index.html" target="_blank">view the source here</a>.</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_AlivePDFExample_904267008"
			class="flashmovie"
			width="750"
			height="500">
	<param name="movie" value="/assets/flash/AlivePDFExample.swf" />
	<param name="bgcolor" value="#000000" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/assets/flash/AlivePDFExample.swf"
			name="fm_AlivePDFExample_904267008"
			width="750"
			height="500">
		<param name="bgcolor" value="#000000" />
	<!--<![endif]-->
		
<p><a href="http://adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>So now that you&#8217;ve had a taste of what AlivePDF can do, lets look at how it works:</p>
<h3>Adding AlivePDF to your project</h3>
<p>First, download the library from <a href="http://www.alivepdf.org/" target="_blank">www.AlivePDF.org</a>, and then add it to your project in one of two ways.  The easiest way is to copy the AlivePDF.swc into your project&#8217;s <em>lib</em> folder.  Flex Builder should automatically detect the swc and add it to the compile settings.  The second approach is to add it manually in Flex Builder, by clicking Project >> Properties >> Flex Build Path >> Library Path >> Add SWC&#8230; and selecting the swc from the file system.</p>
<h3>Displaying PDFs in the Browser</h3>
<p>After the swc has been added to your project you can begin working with the AlivePDF library.  The sample code below could be used to generate a PDF document from any UI component in your application.  We simply turn it into an image (think of it as a screenshot) and publish it to a PDF for the user to save or print.  </p>
<p>The code is fairly simple, we start by creating a new instance of the PDF class and adding a page to it. Then we add our UIComponent to the document as an image.  Finally, we tell AlivePDF how we want to generate the PDF with the save() method.  In this example, the third argument of the method, Download.INLINE, specifies that we want the PDF to be displayed in the browser instead of prompting the user to save (that will be covered in the next section).</p>
<div class="code">
<p><span class="asReserved">import</span> mx.core.UIComponent;</p>
<p>&nbsp;</p>
<p><span class="asReserved">import</span> org.alivepdf.display.Display;<br />
        <span class="asReserved">import</span> org.alivepdf.images.ResizeMode;<br />
        <span class="asReserved">import</span> org.alivepdf.layout.Layout;<br />
        <span class="asReserved">import</span> org.alivepdf.layout.Orientation;<br />
        <span class="asReserved">import</span> org.alivepdf.layout.Size;<br />
        <span class="asReserved">import</span> org.alivepdf.layout.Unit;<br />
        <span class="asReserved">import</span> org.alivepdf.pdf.PDF;<br />
        <span class="asReserved">import</span> org.alivepdf.saving.Download;</p>
<p><span class="asReserved">import</span> org.alivepdf.saving.Method;</p>
<p>&nbsp;</p>
<p>
        <span class="asReserved">private</span> <span class="asFunction">function</span> doPrint(whatToPrint:UIComponent):<span class="asReserved">void</span>{</p>
<div class="indent">
		<span class="asVar">var</span> printPDF:PDF = <span class="asReserved">new</span> PDF( Orientation.LANDSCAPE, Unit.MM, Size.A4 );<br />
        printPDF.setDisplayMode( Display.FULL_PAGE, Layout.SINGLE_PAGE );<br />
        printPDF.addPage();<br />
        printPDF.addImage( whatToPrint, 0, 0, 0, 0, <span class="asString">&#8216;PNG&#8217;</span>, 100, 1, ResizeMode.FIT_TO_PAGE );<br />
        printPDF.save( Method.REMOTE, <span class="asString">&quot;/includes/pdfCreator.cfm&quot;</span>, Download.INLINE, <span class="asString">&quot;test.pdf&quot;</span> );    </div>
<p>    }</p>
</div>
<h3>Prompting Users to Save</h3>
<p>Now that works great and all&#8230; but what if you want to prompt the user to save or open in Adobe Reader?  Fortunately, AlivePDF makes that easy; all you have have to do is change Download.INLINE to Download.ATTACHMENT.</p>
<div class="code">
printPDF.save( Method.REMOTE, <span class="asString">&quot;/includes/pdfCreator.cfm&quot;</span>, Download.ATTACHMENT, <span class="asString">&quot;test.pdf&quot;</span> );
</div>
<h3>Using AlivePDF with ColdFusion</h3>
<p>A PHP script is provided with the download of the AlivePDF library, but if you don&#8217;t like PHP you can use any other server-side language that can generate PDF content.  For those of you who are ColdFusion fans, like myself, here is a basic example of a ColdFusion script that can be used.</p>
<div class="code">
<p><span class="cfComment">&lt;!&ndash;&ndash;&ndash; establish parameters &ndash;&ndash;&ndash;&gt;</span><br />
        <span class="cfTag">&lt;cfparam name=</span><span class="cfString">&quot;URL.method&quot;</span><span class="cfTag"> default=</span><span class="cfString">&quot;&quot;</span><span class="cfTag"> /&gt;<br />
&lt;cfparam name=</span><span class="cfString">&quot;URL.name&quot;</span><span class="cfTag"> default=</span><span class="cfString">&quot;&quot;</span><span class="cfTag"> /&gt;</span></p>
<p>&nbsp;</p>
<p>        <span class="cfComment">&lt;&ndash;&ndash;&ndash; get the content from the http data &ndash;&ndash;&ndash;&gt;</span><br />
        <span class="cfTag">&lt;cfset</span> httpContent = <span class="cfReserved">GetHttpRequestData()</span><span class="cfTag">&gt;</span><br /><br/>
    </p>
<p><span class="cfComment">&lt;!&ndash;&ndash;&ndash; make sure content was passed in &ndash;&ndash;&ndash;&gt;</span><br />
        <span class="cfTag">&lt;cfif</span> <span class="cfReserved">len(</span>httpContent.content<span class="cfReserved">)</span> <span class="cfReserved">gt</span> <span class="cfNumber">0</span><span class="cfTag">&gt;</span></p>
<div class="indent">
			<span class="cfComment">&lt;!&ndash;&ndash;&ndash; write the content to local pdf &ndash;&ndash;&ndash;&gt;</span><br />
<span class="cfTag">&lt;cfheader name=</span><span class="cfString">&quot;Content-Disposition&quot;</span><span class="cfTag"> value=</span><span class="cfString">&quot;#URL.method#; filename=#URL.name#&quot;</span>&nbsp;<span class="cfTag">/&gt;</span><br />
			<span class="cfTag">&lt;cfcontent type=</span><span class="cfString">&quot;application/pdf&quot;</span> <span class="cfTag">variable=</span><span class="cfString">&quot;#httpContent.content#&quot;</span><span class="cfTag">&gt;</span></div>
<p>	    <span class="cfTag">&lt;cfelse&gt;</span></p>
<div class="indent">
		<span class="cfComment">&lt;!&ndash;&ndash;&ndash; redirect to home page &ndash;&ndash;&ndash;&gt;</span><br />
		<span class="cfTag">&lt;cflocation url=</span><span class="cfString">&quot;/&quot;</span><span class="cfTag"> /&gt;</span></div>
<p>	<span class="cfTag">&lt;/cfif&gt;</span> </p>
</div>
<p>AlivePDF has a wide range of capabilities and we&#8217;ve barely scratched the surface here.  I encourage you to take a good look at the library and utilize it to its full potential.</p>
<p>In the next article in this serious we will discuss how to print data from Flex.  See you soon!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kalengibbons.com/blog/index.php/2009/03/custom-printing-with-flex-part-2-generating-pdfs-with-alivepdf/feed/</wfw:commentRss>
		<slash:comments>67</slash:comments>
		</item>
		<item>
		<title>BlogCFC: Extend the life of your blog posts</title>
		<link>http://www.kalengibbons.com/blog/index.php/2008/07/blogcfc-extend-the-life-of-your-blog-posts/</link>
		<comments>http://www.kalengibbons.com/blog/index.php/2008/07/blogcfc-extend-the-life-of-your-blog-posts/#comments</comments>
		<pubDate>Sun, 13 Jul 2008 02:25:43 +0000</pubDate>
		<dc:creator>Kalen Gibbons</dc:creator>
				<category><![CDATA[Coldfusion]]></category>
		<category><![CDATA[How-To]]></category>
		<category><![CDATA[BlogCFC]]></category>

		<guid isPermaLink="false">http://www.kalengibbons.com/blog2/?p=38</guid>
		<description><![CDATA[If your a BlogCFC user but don&#8217;t post too often, like me, then you&#8217;ve probably seen the following message pop up on your blog: Sorry There are no blog entries available. By default, BlogCFC shows only entries posted within the last 30 days. If you&#8217;d like to extend this, simply locate the tags folder in [...]]]></description>
			<content:encoded><![CDATA[<p>If your a BlogCFC user but don&#8217;t post too often, like me, then you&#8217;ve probably seen the following message pop up on your blog:</p>
<div>
<strong>Sorry There are no blog entries available.</strong>
</div>
<p>
By default, BlogCFC shows only entries posted within the last 30 days.  If you&#8217;d like to extend this, simply locate the <span style="font-weight:bold; font-size:1.2em; font-style: italic;">tags</span> folder in your BlogCFC root and find <span style="font-weight:bold; font-size:1.2em; font-style: italic;">getmode.cfm</span>.  Around line 68 you&#8217;ll find the following declaration:
</p>
<p class="code">
params.lastxdays = 30
</p>
<p>
Simply change 30 to the number of days you&#8217;d like new entries to stay on the homepage and you&#8217;re set, your blog will no longer look sad and abandoned.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kalengibbons.com/blog/index.php/2008/07/blogcfc-extend-the-life-of-your-blog-posts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
