cfpresentation and HTML slides

This post is more than 2 years old.

This topic came up from a cf-newbie discussion this weekend, but did you know that cfpresentation can be used to create HTML presentations? The reference is a bit confusing on the matter. If you look at the docs for the format attribute, it says this:

Specifies the file format for conversion:
  • ppt
    converts html input provided in cfpresentationslide to a PowerPoint file.
  • html
    converts ppt to an HTML presentation.

The implication being that you can use the tag just to convert a Powerpoint file into HTML. You can do that. But you can also create ad-hoc presentations and feed them right into html. So an example:

<cfset dest = expandPath("./mypreso")> <cfif not directoryExists(dest)> <cfset directoryCreate(dest)> </cfif>

<cfpresentation title="Ray's Presentation" format="html" destination="#dest#" overwrite="true"> <cfpresentationslide title="Slide One"> This is my first slide. Epic. </cfpresentationslide> <cfpresentationslide title="Slide Two"> This is my second slide. Epic. </cfpresentationslide> <cfpresentationslide title="Slide Three"> This is my third slide. Epic. </cfpresentationslide> </cfpresentation> Done.

In this code template, I'm saving the presentation to a directory. You don't have to do that. If you leave off the destination it will render in the browser. I've added "Done" to the end of the script just so I know, well, when the CFM is done. I've got three simple slides. Once done, the output is saved to a folder:

The result is a HTML/JavaScript slide viewer. I'll be honest. It isn't... stellar. You can view this yourself here:

Sexy, right? Ok, maybe not. But for a quick and dirty result, it's better than nothing. Be careful with it. I tried embedding a PNG chart and while it worked locally, it wasn't available when pushed to production.

Raymond Camden's Picture

About Raymond Camden

Raymond is a developer advocate for HERE Technologies. 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