Ask a Jedi: Mixing CFLAYOUT and PDF/Flash

Michael Brennan-White asks:

I am attempting to create a new RIA app using the new Ajax tools in CF8. Is there a special trick needed to display a FlashPaper or PDF in a cflayoutarea? I am calling the report with this link:
<a href="javaScript:ColdFusion.navigate('DebtMFReport.pdf','center')">Agency Scheduled Payments Report</a> All that displays is text like this:
(freaky stuff here) It doesn't matter if I am using an existing PDF file or a PDF generated by a cfr file. Any suggestions?

What you have to remember is that when you run ColdFusion.navigate, the JavaScript will request the remote URL and take the resultant HTML and place it in the container (whether it be cflayout, cfdiv, etc). When you pointed to a binary file, ColdFusion attempted to write out the binary data to the container, which obviously won’t work well. PDFs can’t be embedded in a page. They must take over the complete page to work. So you are out of luck.

Flash is a different story. Since Flash can be embedded in a page, you should be able to use Flash Paper easily enough. Unfortunately, when you create the Flash Paper via CFDOCUMENT, ColdFusion makes it act the same as a CFDOCUMENT/PDF call. It takes over the entire page.

You can get around this though. Don’t forget CFDOCUMENT lets you save the resultant binary data into a variable. You can generate your FlashPaper, save it, and then point to a HTML/CFML file that uses the object/embed tags to load the Flash.

Now for the funky part. Normally when folks load Flash, they use the JavaScript libraries that Adobe ships, or the other OS ones out there. Any JavaScript you load into a CF8 Ajax container must use the foo = function() format, and not the function foo() format. If you use this route, then you need to ensure the JavaScript code you uses follows this format, otherwise things won’t work right.

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. You can even buy me a coffee!

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

Comments