Printing Custom Flex components using PrintJob
06 Apr 2005
Someone on flexcoders asked about printing a Custom component using PrintJob.
I wrote a quick and dirty example. The idea is to create instance of component in main application, print it and delete it when printing is done.
##PrinJobExample.mxml###
[CDATA[
import Help;
var helpRef;
function testPrintJob():Void
{
helpRef= createChild(Help, "help");
//wait untill help is created & rendered completely...
helpRef.addEventListener("creationComplete",mx.utils.Delegate.create(this, printHelp));
}
function printHelp()
{
var printJob:PrintJob= new PrintJob();
printJob.start();
printJob.addPage(helpRef);
printJob.send();
delete printJob;
destroyChild(helpRef);
}
]]
##Help.mxml###