Question

If I print an AdvancedDataGrid that is more than a single page, all is fine. If, however, there is less than a page to print the last row always ends up at the top of a second page.

The method doing the print jop is listed below. Am I missing something if not what can I do to make it work properly with a single page.

Thanks

const printJob:FlexPrintJob = new FlexPrintJob();

if ( printJob.start() ) {
    const printDataGrid:PrintAdvancedDataGrid = new PrintAdvancedDataGrid();
    printDataGrid.width = printJob.pageWidth;
    printDataGrid.height = printJob.pageHeight;
    printDataGrid.columns = districtVolunteers_dg.columns;
    printDataGrid.dataProvider = districtVolunteersXML.copy();
    printDataGrid.setStyle("fontSize", 8);
    printDataGrid.setStyle("fontFamily", 'Times');
    printDataGrid.sizeToPage;
    printDataGrid.visible = false;
    FlexGlobals.topLevelApplication.addChild(printDataGrid);
    while (printDataGrid.validNextPage) {
        printDataGrid.nextPage();
        printJob.addObject(printDataGrid);

    }
    printJob.send();
    FlexGlobals.topLevelApplication.removeChild(printDataGrid);
}
Was it helpful?

Solution

I solved this problem by adding the first page outside of the while loop and setting the scale type to none...

printJob.addObject(printDataGrid, FlexPrintJobScaleType.NONE);
while (printDataGrid.validNextPage) {
    printDataGrid.nextPage();
    printJob.addObject(printDataGrid, FlexPrintJobScaleType.NONE);

}
printJob.send();

If you are interested in my full solution to printing a datagrid, see the answer to my question about adding a top margin to the print job... 19164992

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top