HabibS
HabibS

Reputation: 382

How to print webpage contains flash

Is it possible to print a webpage that contains flash content? Maybe using jQuery?

I have a page with some SWF objects that need to be printed, but I can't find a way to print them in Firefox.

I could use plugins, but I don't want to force visitors to use any plugin in order to be able to print the page.

Upvotes: 0

Views: 2413

Answers (2)

Flassari
Flassari

Reputation: 1229

Well, this is quite a complex method but it just might work. For this to work you will have to be able to edit all flash files on the page though, AND this will have to be a browser that supports Base64 encoded image sources (I don't think IE supports it).

  • User presses print button on the web page
  • Your custom Javascript calls "getScreenshot" function in every flash object using ExternalInterface.
  • Flash file's getScreenshot function (that you create) creates a BitmapData as big as the stage is, draws itself on it using the BitmapData.draw(..) method, encodes it with Base64 and returns it.
  • Javascript hides the flash object and puts an image element on top and populates it with the Base64 encoded string.
  • Now since all the flash objects have been replaced by images, call the document print function via javascript.
  • When user is done printing she can press a button on the webpage to "resume" the flash content, which removes the dynamically created image elements and shows the flash objects again.

This is quite an overkill though, but if you really really need people to be able to print the page AND the flash objects, this would be one way to make that happen.

Upvotes: 1

Farhan Ahmad
Farhan Ahmad

Reputation: 5198

Like ThiefMaster said. Not using flash is probably the best way.

But if you still want to print flash. You could try to ping a server-side script (php) which would snap shot the page you want and display the image which flash can then print using flash's printjob functionality.

  • Load the page that will display the url snapshot (snapshot taken with php) using a Loader class. Make sure the headers are correct on the php page (so browsers think it's an image).
  • Use the flash printjob to print the image

Hope that helps!

Upvotes: 2

Related Questions