Michael Brennan-White asks:
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.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?
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.
Archived Comments
Load the pdf/flash into an iframe inside the cflayout. This should solve the problem.
--Dave
Not working for me. This is what I used for the CFM requested:
<iframe src="test.pdf" height="100%" width="100%"></iframe>
I get an empty iframe.
This is what I did and it seems to work. I also did it without an iframe by generating thumbnails at 100% from the source pdf.
---- index.cfm -----
<CFSETTING SHOWDEBUGOUTPUT="NO">
<CFLAYOUT TYPE="BORDER">
<CFLAYOUTAREA POSITION="LEFT" STYLE="width:300px;">
<a href="javaScript:ColdFusion.navigate('./loadPDF.cfm?pdf=test.pdf','vewer')">VIEW PDF</A>
</CFLAYOUTAREA>
<CFLAYOUTAREA POSITION="center" NAME="vewer">
</CFLAYOUTAREA>
</CFLAYOUT>
------ loadPDF.cfm -----
<CFOUTPUT>
<iframe src="#url.pdf#" height="90%" width="90%"></iframe>
</CFOUTPUT>
--Dave
Well wait - if you use thumbnails, its JPGs. I consider that cheating. ;)
I don't call it cheating. I call it creative problem solving. :)
--Dave
Thanks for all the help.
I am so appreciative that I will be able to implement either solution based on user input.
FlashPaper is "different"
You can embed PDF using <EMBED src="ekgbin/#PDFFileName#.pdf" width="100%" height="825px" href="ekgbin/#PDFFileName#.pdf"></EMBED>.
Have been using that for a couple of years with a prototype.js powered Ajax site. Have not tried with cflayout though. Just FYI.
Just tested embed a pdf using cflayout and it works fine.
For some reason, this is now broke with CF 9.0.1 (with hotfix installed) in IE 6,7,8, it still works fine on our CF 8, development server.
Sorry, should have mentioned, "broke" in regards to using the embed tag for the PDF, inside a cflayoutarea. The PDF doesn't show up at all. Does anyone know if there is a newer way in CF9 to accomplish this.
Which part is broken? You mean the embed from comment 7?
Yes, for some reason, it will no longer show in the cflayoutarea now that we have upgraded to CF9. I found a way around it, using the <object> tag, and embedding that way, but I had to strip my page of all cflayout, and redo the page in a standard table layout 100% width and height, and that works. It is just odd, that in the CF8 environment, the embed tag still works fine. No changes, all we did was update the server to CF9, since then, it hasn't worked on the server. Very odd. But then again, the <object> embed doesn't work either. Has CFlayout changed (ie. some new required parameters, that 8 didn't need)?
Well, the Ajax code behind the scenes was updated significantly between 8 and 9.