Home >
Exploring New Features in CF9 Beta: PPT Generation
There are a lot of new features in the ColdFusion 9 beta on that was recently released on Adobe Labs. One of the things that caught my attention is the ability to read and generate MS Office documents on the fly, including PowerPoint Presentation files. In this example I decided to test out the PPT generation.
I have had projects in the past where we needed to generate presentations dynamically on the server, and in each case, the approach/result has varied. Sometimes a player SWF was created, which accepted XML based markup to generate the presentation content; other times content was embedded within a dynamically generated a SWF file; and other times Jasper Reports was used on a Java server to generate PDFs, and in some cases just haiving HTML content that interacted similar to a ppt file (click to advance) worked just fine.
Now, we can step it up a notch, and quickly & easily dynamically generate PPT content that is compatible with MS Office, and can be edited directly within MS Office for final tweaks by the presenter. Think about this scenario... You have a business management/CRM system, and your execs need weekly reporting on your business process. You can now generate these documents on-demand, and they can do any final customization on their own.
You can use the CFPresentaion tag with the new "PPT" output format, and pass in any HTML, which will be renderered into the PPT content. you can either dynamically generate the HTML content, or point it to a URL which will be included in the PPT content. I noticed that some HTML formatting gets lost when pointing it at a complete web site, however it still handles more than enough for a quality output. It will take some experimenting with the HTML to get everything right, but it can certainly be done, and can be extremely useful.
Oh, and did I mention that it is really easy? This is a cool feature. Below is sample code that will dynamically generate a PDF file. You can view the generated output here.:
<cfpresentation
format="ppt"
title="Sample"
destination="C:\ColdFusion9\wwwroot\cf9examples\sampleOutput.ppt"
overwrite="true" >
<cfpresentationslide advance="click" >
<h1>Sample CFPresentation PDF Output!</h1>
The time is <cfoutput>#now()#</cfoutput>
</cfpresentationslide>
<cfpresentationslide advance="click" >
<h1>Slide Two</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</cfpresentationslide>
<cfpresentationslide advance="click" >
<h1>Slide Three: Its a loop!</h1>
<cfloop from="1" to="12" index="current">
<cfoutput>#monthAsString(current)#<br/></cfoutput>
</cfloop>
</cfpresentationslide>
</cfpresentation>
The output is a 3 page PPT presentation that contains the specified HTML content. This was created using the CF 9 beta, currently available on Adobe labs, on the local development server instance.
You can read more about PPT generation in CF9 in the online documentation available at:
http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WS08731025-2134-4bc8-A7CF-4751AF3628BC.html
You can read more about working with office applications in ColdFusion 9 at:
http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WS56EA2935-FBD2-4089-8402-FDDA2BAF55FB.html
___________________________________
Andrew Trice
Principal Architect
Cynergy Systems
http://www.cynergysystems.com




Facebook Application Development
Comments
Leave a comment