views:

381

answers:

1

I've set up an application to print the current state of the control I'm using (in this case an ArcGIS server map), but I'd like to set up a print function that uses it's own template to print rather than grabbing the state of the application.

I've attempted to do this by setting up a flex component that lays out the items I want to print and instantiating it when I call the FlexPrintJob. Unfortunately, simply instantiating it results in getting a blank green square.

There are two main questions about this that I'd like to put out there. First, what needs to be done to print a newly instantiated template rather than just grabbing already existing controls from the screen? Second, for more controls that need to load complicated data from multiple sources, like an ArcGIS map, is it possible to instantiate them in that kind of environment, or is there a way to take an image of the control in the application and print that?

A: 

I found that the best way to do it was to use the ImageSnapshot.captureBitmapData() method to get an image of the map as bitmap data, and then, if necessary, clip it into another BitMapData object using the copyPixels() method.

Once I'd done that, adding the template to the print job was simple:

Application.application.addChild(printTemplate);
printJob.addObject(printTemplate,FlexPrintJobScaleType.SHOW_ALL);
//printJob.printAsBitmap();
Application.application.removeChild(printTemplate);
Dan Monego