Ask a Jedi: Embedding FlashPaper on a page

Rob wrote me yesterday asking about cfdocument and FlashPaper. FlashPaper? Yes, FlashPaper. FlashPaper was an alternative to PDF created back before Adobe swallowed up Macromedia. I thought the product was dead, but apparently you can still purchase it. As you can guess, it is a “document” type product, much like PDF, but it uses Flash for rendering into of the PDF engine. ColdFusion has supported generating FlashPaper ever since cfdocument was released. Here is a quick example. First, use the cfdocument tag with FlashPaper as a format.

<cfdocument format="flashpaper"> <img src="http://www.adobe.com/images/shared/product_logos/159x120/159x120_flashpaper.gif" align="left"> <cfloop index="x" from="1" to="10"> <p> <cfoutput><h1>Para #x#</h1></cfoutput> </p> </cfloop> </cfdocument>

This outputs Flash on the page with an embedded toolbar on top:

One of the cool things about FlashPaper is that it can more easily be embedded in a page. As far as I know, PDF can’t be. It either takes over the entire web page, or, at least on my machine, it just gets downloaded. However, if you try to use cfdocument/format=”flashpaper” with other HTML you will see that the FlashPaper takes over the entire page.

Here is one workaround. Don’t forget that cfdocument can take it’s generated binary data and store it to a variable. This is true for both PDF and FlashPaper.

<cfdocument format="flashpaper" name="f">

Once you have this data, you can save it to the file system and include it as you normally would with object/embed tags:

<h2>Test</h2>

<cfdocument format=”flashpaper” name=”f”> <cfloop index=”x” from=”1” to=”10”> <p> <cfoutput><h1>Para #x#</h1></cfoutput> </p> </cfloop> </cfdocument> <cffile action=”write” file=”#expandPath(‘./somefilename.swf’)#” output=”#f#”>

<object width=”550” height=”500”> <param name=”movie” value=”somefilename.swf”> <embed src=”somefilename.swf” width=”550” height=”400”> </embed> </object>

<p> Footer </p> </code>

Obviously you would probably use SWFObject, or another JavaScript library, to generate the HTML. You would also probably need to use a dynamic filename for the SWF. Here is the result:

After I sent Rob this version, I did a quick Google check and found the Terry Ryan had actually built a nice little CFC to make this even easier: Flashpaper Embedder

Raymond Camden's Picture

About Raymond Camden

Raymond is a developer advocate. He focuses on JavaScript, serverless and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support.

Lafayette, LA https://www.raymondcamden.com

Comments