How to Print contents of a Container (Canvas) ?

Here iam having two Two containers (canvas) with my data in it and now I want to print the contents of the canvas as a whole.

Two containers [canvas] à PrintPreviewL,PrintPreviewR
Now I want to print the contents of these containers.

The function which does the print is :

public function doPrint():void
{
// Create a FlexPrintJob instance.
var printJob:FlexPrintJob = new FlexPrintJob();

// Start the print job.
if(printJob.start()) {
// Create a PrintView control as a child
// of the current view.
var formPrintViewL:PrintPreviewL = new PrintPreviewL ();
var formPrintViewR: PrintPreviewR = new PrintPreviewR();
addChild(formPrintViewL);
addChild(formPrintViewR);
// Add the SimplePrintview control to the print job.
// For comparison, try setting the
// second parameter to “none”.
printJob.addObject(formPrintViewL);
printJob.addObject(formPrintViewR);
// Send the job to the printer.
printJob.send();

// Remove the print-specific control to free memory.
removeChild(formPrintView);
removeChild(formPrintViewT);
}

}

This will print the contents of the two canvas in sequence as we send to the printJob.As you can see.

Can go through the classes to learn the Basics and start. All the Best.

Enjoy the code ! :-) , leave me comments for queries.

One Response to “How to Print contents of a Container (Canvas) ?”

  1. Flex, How to Print Canvas and its contents. « Nitin Goel Says:

    [...] http://flexonblog.wordpress.com/2008/07/03/how-to-print-contents-of-a-container-canvas/ [...]

Leave a Reply