Raymond Camden's Blog Rss

Ask a Jedi: Can I Use a PDF in a Flash Form?

10

Posted in ColdFusion | Posted on 08-11-2005 | 2,834 views

Ryan asks:

Okay jedi, how about a slightly harder question. Can I embed a pdf inside a flashform? using something similar to the way I embed a pdf in an html page:
<OBJECT ID="PDF" CLASSID="clsid:CA8A9780-280D-11CF-A24D-444553540000" WIDTH="800" HEIGHT="450"> <PARAM NAME="SRC" VALUE="/testing/testpdf.pdf"> <OBJECT>

I have tried wraping it in a <cfformitem type="html"> but it doesnt seem to work. It doesnt throw an error, just nothing shows up. Any ideas?

The short answer is no. Flash's HTML support is pretty limited. From the documentation:

For Flash forms, you can use the following text formatting tags, most of which correspond to HTML tags, in the text: a, b, br, font, i, img, li, p, textformat, and u. For details on using these formatting tags, see the Flash documentation.

You could, of course, link to a PDF file, even with a popup, so a click on the link in the Flash Grid would pop up a window containing the PDF.

Comments

[Add Comment] [Subscribe to Comments]

Thanks, thats what I was expecting.

It is too bad that we cant embed html natively inside of a swf... I wouldn't even really want the ability to pass variables back and forth (although that would be sweet...) but just a frame of sorts I could put in a swf that I could just put a normal html page in.

Oh well, maybe in flash 9 ;)
Not on topic for this post, but I have been working on a project this week to embed dynamic flashpaper docs in flashforms. It has worked out great.

So if you are generating your pdf's, you might conisder generating them as flashpaper and going that route.
That is interesting simeon. Do you have a blogpost or something that shows that?
It should be rather simple. All you would need to do is use the trick I described about embedding charts in flash forms.
OK... side question. How do I load a flash movie into a flash form and have it communicate with or rather have the form communicate with it. (Both ways)
Yes, the HTML rendering inside the Macromedia Flash Player does not handle as many constructs as the HTML/JS/CSS rendering within a browser -- otherwise it would be as big as a browser, and harder to get on the audience's machines.

One other trick to display a foreign file "within" a Flash SWF presentation is to build a four-SWF frame around the other renderer... tables were used in the past, IFRAMES by others, depending on your audience's browsers you might choose other techniques today. With reasonable framerates the CPU hit is tolerable.

Authoring-time or server-time format translations are another option... like Simeon says, Macromedia FlashPaper is a pretty easy way to convert most any office format to SWF.

But embedding any ActiveX Control or Netscape Plugin within a SWF, that's still a difficult thing, agreed.

jd/mm
jd,
I completely understand that, I wouldnt want flash to actually render the html/css/js (although, wouldnt that be something!) because you're right, that would balloon the size of the flash player considerably. I was talking about something similar to your four flash swf method. Something like flash with a hole in it if you will. Let the browser do the rendering, just display it in the middle of the swf. Or on top of it would work as well...
John F - sorry - I'm not aware of any way of dong that. I can definitely make the Flash Forms talk to JS, but not the other way.
Ok, so is there a way to batch process .pdfs into Flash Paper? I recall reading about some kind of script that can be written. I have a lot of .pdfs to convert into .swfs, (read: 100 page catalogs) and have been forced to change them one by one. Any ideas?
If you need to <a href="http://print2flash.com">convert PDFs or other printable documents to flashpapers</a> the Print2Flash may be a better choice. Print2Flash has APIs for automated document conversion.

VBScript example:
P2F = CreateObject("P2F.Server")
P2F.ConvertDir "C:\docs", "*.pdf", "C:\inetpub\www.mysite.com\swf"

Command line example:
p2fserver.exe C:\ Docs\*.pdf C:\inetpub\www.mysite.com\swf

In the examples all PDFs in the "C:\docs" folder are converted to Flash. The output files are written to the "C:\inetpub\www.mysite.com\swf" folder.

Print2Flash OLE Automation API objects can run using rights of a user different from the user which creates and uses these objects. This allows converting documents from server-side scripts like ASP or PHP.

Print2Flash batch processing also allows you to fine-tune document options like paper size, page orientation, printing resolution, etc. Unlike with FlashPaper the document toolbar and functions can be customized, too.

Print2Flash website:
http://print2flash.com

[Add Comment] [Subscribe to Comments]