Printing in Flash with LayoutUtils September 19, 2008
Printing movie clips from Flash becomes extremely easy with the printImage functions of the LayoutUtils package from Troyworks.
Two functions printImagePortrait and printImageLandscape will place your image portrait like or landscape like. Moreover, it doesn’t matter for this printing function if the paper is set to Portrait or Landscape. The image will be scaled to the size of paper (using the scaleTo function in the crop mode of the LayoutUtils) and centered; however, margins are left to fit the standard printer settings. To use the printing functions we need a movie clip, say “mc”, and then we create a snapshot object for it.
-
-
var snapObject:IDisplayObjectSnapShot = LayoutUtil.snapshotDimensions(mc);
Now, using the snapObject, we can print our image in portrait mode:
-
-
LayoutUtil.printImagePortrait(mc, snapObject);
Or in landscape:
-
-
LayoutUtil.printImageLandscape(mc, snapObject);
The other useful function is to print all the frames of the movie clip. To do that you can call one of the two functions
-
-
LayoutUtil.printImageLandscapeFrames(mc, snapObject, true);
-
-
LayoutUtil.printImagePortraitFrames(mc, snapObject, true);
The last boolean parameter indicating if you want to print all the frames of the movie clip (true) or just the first one (false). Each new frame would be printed on a new page.
If you need the reverse process, printing from PDF to SWF, you can use the PDF2SWF Converter from SWFTools, which is a free collection of SWF manipulation and creation utilities. PDF2SWF converts every page of the PDF document into a frame in the SWF file. The last version of the converter supports Flash 9 output format.
That’s it!
You can find LayoutUtil.as source code on GoogleCode or you can have a look here

1 responses to 'Printing in Flash with LayoutUtils'
Test
Add a Comment: