Last Updated: 09/15/2011 11:54:00 AM

Embedding a SWF in a PDF with ColdFusion and iText

Embedding a SWF in a PDF with ColdFusion and iText

At a recent presentation that I did on "Working with PDFs made easy with ColdFusion"  for Adobe ColdFusion Developer week an attendee asked me if it was possible to embed a SWF into a page on a PDF with ColdFusion.  I had never tried, so I told him I would find out.  Turns out you can. Sort Of.

ColdFusion itself can not embed it directly, you can embed it as part of PDF Portfolio. PDF portfolios do not get enough attention, in my opinion. Click here to read more about them  However I think the attendee was more asking about a SWF showing in the middle of the text of a PDF. This is possible, but you must use the underlying iText java library to do so.  My code example can be found here on github: 

https://github.com/boltz/iTextCFC/blob/master/Presentation/PDFBlackMagic/slides/SWF/index.cfm

 

Note: you will need to update the iText Jar on your Coldfusion server. Download the latest jar from http://itextpdf.com  drop it in your ColdFusion/Lib folder and restart the ColdFusion service (this is for versions 9.01 and below that are still using the 1.2.0 version of Itext)

 

If you are just interested in seeing what such a PDF looks like the link is below:

https://github.com/boltz/iTextCFC/blob/master/Presentation/PDFBlackMagic/slides/SWF/bacon.pdf?raw=true

 

Next up, embedding a Flex enabled SWF file!

 

Comments

Mike Collins
Gravatar

Thanks for your presentation this week. Well done.

I think you mean to say package above, portfolio is basically a flash skin to view a package. You can create packages quite easily with CF, but you really can't creat portfolios that I know of.

I hope CF X will allow for us to create portfolios since they create a super cool final product for offline viewing.

September 16, 2011, 9:24 AM
Tim Cunningham
Gravatar

Thanks Mike!

As to PDF Portfolios, I was basing my wording off of page 189 of the Adobe ColdFusion 9 Web Application Construction Kit Volume 2. (WACK) They used Portfolio and Package as synonyms. I will research the different and be careful in my future wording.

Tim

September 28, 2011, 4:50 PM
Post a Comment
  1. Leave this field empty

Required Field