Printing Custom Flex components using PrintJob

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.

<mx:Application xmlns:mx="" xmlns="*">
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();
delete printJob;
<mx:Button label="print" click="testPrintJob();"/>
<mx:VBox xmlns:mx="">
<mx:Label id="_lbl" text="Hello I am Help...."/>
<mx:Button label="Button in Help..."/>
  • RBKB

    How can createChild() be used in Flex 3?

  • Razak

    could you please give an example of printing plain text with flex . In java we will write to output stream and convert it to printstream that will achieve printing. How could I do it with the support of flex?

  • kannan

    Is it possible to get multipage printout from AdvancedDataGrid?

  • @kannan: I think so, have not tried though.

  • Blake

    Have you guys tried BentBit Report? It is great at generating reports in Flex and it even lets your users view the pages, select the paper size and orientation, and it supports custom components. The website is