Friday, August 26, 2011

Printing image in Flex

This is a very simple excercise to do in Flex. The following code snippet demonstrates it.


private function printImage(component:UIComponent):void
{
if (component)
{
var printJob:FlexPrintJob = new FlexPrintJob();
if (printJob.start())
{
printJob.addObject(component, FlexPrintJobScaleType.FILL_PAGE);
printJob.send();
}
}
}


Explanation:

The code essentially takes the reference of the component which is to be printed. FlexPrintJob starts a new job.
printJob.start() checks whether the system is connected to a printer and that the printer is ready
FlexPrintJobScaleType sets the type of scaling that is required. NONE does not scale anything.

No comments :