Hello,
I'm working on a print function for a Flex 2 app. When my print button is
clicked I only want to print a portion of the page, and I need
to manipulate the layout first to make sure the output looks good. From what
I've read everybody recommends creating a new Canvas,
adding the components to canvas, and then adding the Canvas to my print job.
What I want to print is the contents of a Grid control (which is only a portion
of the visible content). Each GridItem is a custom
component where the contents of the custom component is a Panel containing a
chart or data grid.
The problem with the 'create a new Canvas to hold all the components' technique
is that all the grid items are lifted out of their normal
on-screen display location and moved to the Canvas. When I add the Canvas to
the Application, the print layout is visible to the user
and the area that used to hold the Grid is empty.
Is there a way to create a custom print layout without affecting the display on
screen?
My code (with a little hand-waving) looks something like this:
var pj:FlexPrintJob = new FlexPrintJob();
if (pj.start())
{
var page1:Canvas = new Canvas();
var header:PrintHeader = new PrintHeader(); // custom component
var charts:Array = getChartsInChartState(); // array of GridItems
var dataGrids:Array = getChartsInDrillDownState(); // array of GridItems
page1.addChild(header);
page1.addChildren(charts);
page1.addChildren(dataGrids);
Application.application.addChild(page1);
page1.height = pj.pageHeight;
page1.width = pj.pageWidth;
pj.addObject(page1);
pj.send();
}
Thanks, Jesse